Skip to content

Commit

Permalink
Fix Soul Shard combining
Browse files Browse the repository at this point in the history
Fixed Soul Shards not being able to be combined in an anvil.
  • Loading branch information
crashniels committed May 18, 2021
1 parent 521fddd commit ab6427c
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 20 deletions.
5 changes: 0 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,3 @@

A fork of the 1.15 fabric version to run with 1.16.5.

# Currently broken:

- Fusing SoulShards
- Texture not rendering purple
- probably something else as well
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
plugins {
//id "com.matthewprenger.cursegradle" version "1.4.0"
id 'fabric-loom' version '0.6-SNAPSHOT'
//id "maven-publish"
id 'fabric-loom' version '0.7-SNAPSHOT'
id "maven-publish"
}

sourceCompatibility = 1.8
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import info.tehnut.soulshards.item.ItemSoulShard;
import net.minecraft.screen.AnvilScreenHandler;
import net.minecraft.screen.Property;
import net.minecraft.inventory.CraftingResultInventory;
import net.minecraft.inventory.Inventory;
import net.minecraft.item.ItemStack;
import org.spongepowered.asm.mixin.Final;
Expand All @@ -17,25 +16,19 @@
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(AnvilScreenHandler.class)
public class MixinAnvilContainer {
public class MixinAnvilScreenHandler extends MixinForgingScreenHandler{

@Shadow
@Final
private Inventory inventory;
@Shadow
@Final
private Property levelCost;
@Shadow
@Final
private CraftingResultInventory result;


@Inject(method = "updateResult", at = @At("HEAD"), cancellable = true)
public void soulshards$updateResult(CallbackInfo callbackInfo) {
if (!SoulShards.CONFIG.getBalance().allowShardCombination())
return;

ItemStack leftStack = inventory.getStack(0);
ItemStack rightStack = inventory.getStack(1);
ItemStack leftStack = this.input.getStack(0);
ItemStack rightStack = this.input.getStack(1);

if (leftStack.getItem() instanceof ItemSoulShard && rightStack.getItem() instanceof ItemSoulShard) {
Binding left = ((ItemSoulShard) leftStack.getItem()).getBinding(leftStack);
Expand All @@ -47,7 +40,7 @@ public class MixinAnvilContainer {
if (left.getBoundEntity() != null && left.getBoundEntity().equals(right.getBoundEntity())) {
ItemStack output = new ItemStack(RegistrarSoulShards.SOUL_SHARD);
((ItemSoulShard) output.getItem()).updateBinding(output, left.addKills(right.getKills()));
result.setStack(0, output);
this.output.setStack(0, output);
levelCost.set(left.getTier().getIndex() * 6);
callbackInfo.cancel();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package info.tehnut.soulshards.core.mixin;

import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;

import net.minecraft.inventory.CraftingResultInventory;
import net.minecraft.inventory.Inventory;
import net.minecraft.screen.ForgingScreenHandler;

@Mixin(ForgingScreenHandler.class)
public class MixinForgingScreenHandler {

@Shadow
@Final
protected CraftingResultInventory output;

@Shadow
@Final
protected Inventory input;
}
4 changes: 3 additions & 1 deletion src/main/resources/soulshards.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
"refmap": "soulshards-refmap.json",
"mixins": [
"MixinEntityLiving",
"MobSpawnerLogicEntityId"
"MobSpawnerLogicEntityId",
"MixinAnvilScreenHandler",
"MixinForgingScreenHandler"
],
"client": [
"client.MixinItemRenderer"
Expand Down

0 comments on commit ab6427c

Please sign in to comment.