From 969806314963c55c7974463ef4572d82e35b1119 Mon Sep 17 00:00:00 2001 From: alongstringofnumbers Date: Fri, 23 Feb 2024 15:01:27 -0700 Subject: [PATCH] In progress fixes, doesn't all work yet --- gradle.properties | 2 +- .../minecraft/RecipeRepairItemMixin.java | 61 +++++++++++-------- .../RegionRenderCacheBuilderMixin.java | 2 +- 3 files changed, 36 insertions(+), 29 deletions(-) diff --git a/gradle.properties b/gradle.properties index f051122a86e..c3d30adcc47 100644 --- a/gradle.properties +++ b/gradle.properties @@ -68,7 +68,7 @@ forceEnableMixins=true # diff to see exactly what your ASM or Mixins are changing in the target file. # Optionally can be specified with the 'CORE_MOD_DEBUG' env var. Will output a lot of files! # TODO, change this to false before merging -enableCoreModDebug=false +enableCoreModDebug=true # Adds CurseMaven, Modrinth Maven, BlameJared maven, and some more well-known 1.12.2 repositories includeWellKnownRepositories=true # Adds JEI and TheOneProbe to your development environment. Adds them as 'implementation', meaning they will diff --git a/src/main/java/gregtech/mixins/minecraft/RecipeRepairItemMixin.java b/src/main/java/gregtech/mixins/minecraft/RecipeRepairItemMixin.java index 6af27aa2b23..bc4716c6c8a 100644 --- a/src/main/java/gregtech/mixins/minecraft/RecipeRepairItemMixin.java +++ b/src/main/java/gregtech/mixins/minecraft/RecipeRepairItemMixin.java @@ -12,10 +12,9 @@ import net.minecraftforge.common.ForgeHooks; import net.minecraftforge.event.ForgeEventFactory; +import com.llamalad7.mixinextras.injector.ModifyReturnValue; import com.llamalad7.mixinextras.injector.WrapWithCondition; import com.llamalad7.mixinextras.sugar.Local; -import com.llamalad7.mixinextras.sugar.ref.LocalIntRef; -import com.llamalad7.mixinextras.sugar.ref.LocalRef; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -25,59 +24,67 @@ public class RecipeRepairItemMixin { @Inject(method = "matches(Lnet/minecraft/inventory/InventoryCrafting;Lnet/minecraft/world/World;)Z", - at = @At(value = "INVOKE_ASSIGN", target = "Ljava/util/List;get(I)Ljava/lang/Object;"), + at = @At(value = "INVOKE", + target = "Ljava/util/List;get(I)Ljava/lang/Object;", + shift = At.Shift.BY, + by = 3), cancellable = true) public void gregtechCEu$matches(InventoryCrafting inv, World worldIn, CallbackInfoReturnable cir, - @Local LocalRef itemstack, @Local LocalRef itemstack1) { - if (itemstack.get().getItem() instanceof IGTTool first && - itemstack1.get().getItem() instanceof IGTTool second) { + @Local ItemStack itemstack, @Local(ordinal = 1) ItemStack itemstack1) { + if (itemstack.getItem() instanceof IGTTool first && + itemstack1.getItem() instanceof IGTTool second) { if (first.isElectric() || second.isElectric()) { cir.setReturnValue(false); } else { - cir.setReturnValue(first.getToolMaterial(itemstack.get()) == second.getToolMaterial(itemstack1.get())); + cir.setReturnValue(first.getToolMaterial(itemstack) == second.getToolMaterial(itemstack1)); } } } @Inject(method = "getCraftingResult(Lnet/minecraft/inventory/InventoryCrafting;)Lnet/minecraft/item/ItemStack;", - at = @At(value = "INVOKE_ASSIGN", target = "Ljava/util/List;get(I)Ljava/lang/Object;", ordinal = 0), + at = @At(value = "INVOKE", + target = "Ljava/util/List;get(I)Ljava/lang/Object;", + ordinal = 0, + shift = At.Shift.AFTER), cancellable = true) public void gregtechCEu$getCraftingResultFirst(InventoryCrafting inv, CallbackInfoReturnable cir, - @Local(ordinal = 0) LocalRef itemstack, - @Local(ordinal = 1) LocalRef itemstack1) { - if (itemstack.get().getItem() instanceof IGTTool tool && tool.isElectric()) { + @Local(ordinal = 0) ItemStack itemstack, + @Local(ordinal = 1) ItemStack itemstack1) { + if (itemstack.getItem() instanceof IGTTool tool && tool.isElectric()) { cir.setReturnValue(ItemStack.EMPTY); - } else if (itemstack1.get().getItem() instanceof IGTTool tool && tool.isElectric()) { + } else if (itemstack1.getItem() instanceof IGTTool tool && tool.isElectric()) { cir.setReturnValue(ItemStack.EMPTY); } } - @Inject(method = "getCraftingResult(Lnet/minecraft/inventory/InventoryCrafting;)Lnet/minecraft/item/ItemStack;", + /*@Inject(method = "getCraftingResult(Lnet/minecraft/inventory/InventoryCrafting;)Lnet/minecraft/item/ItemStack;", at = @At(value = "RETURN", ordinal = 1), - cancellable = true) - public void gregtechCEu$getCraftingResultSecond(InventoryCrafting inv, CallbackInfoReturnable cir, - @Local(ordinal = 4) LocalIntRef i1, - @Local(ordinal = 2) LocalRef itemstack2, - @Local(ordinal = 3) LocalRef itemstack3) { - if (itemstack2.get().getItem() instanceof IGTTool first && itemstack3.get().getItem() instanceof IGTTool) { + cancellable = true)*/ + @ModifyReturnValue(method = "getCraftingResult", at = @At(value = "RETURN", ordinal = 1)) + public ItemStack gregtechCEu$getCraftingResultSecond(ItemStack originalResult, InventoryCrafting inv, + @Local(ordinal = 4) int itemDamage, + @Local(ordinal = 2) ItemStack itemstack2, + @Local(ordinal = 3) ItemStack itemstack3) { + if (itemstack2.getItem() instanceof IGTTool first && itemstack3.getItem() instanceof IGTTool) { // do not allow repairing tools if both are full durability - if (itemstack2.get().getItemDamage() == 0 && itemstack3.get().getItemDamage() == 0) { - cir.setReturnValue(ItemStack.EMPTY); + if (itemstack2.getItemDamage() == 0 && itemstack3.getItemDamage() == 0) { + return ItemStack.EMPTY; } else { - ItemStack output = first.get(first.getToolMaterial(itemstack2.get())); + ItemStack output = first.get(first.getToolMaterial(itemstack2)); NBTTagCompound outputTag = ToolHelper.getToolTag(output); - outputTag.setInteger(ToolHelper.DURABILITY_KEY, i1.get()); - cir.setReturnValue(output); + outputTag.setInteger(ToolHelper.DURABILITY_KEY, itemDamage); + return output; } } - } - // Can't use @Share, since ItemStack is not on the LocalRef group + return originalResult; + } @Inject(method = "getRemainingItems", at = @At(value = "INVOKE", target = "Lnet/minecraft/inventory/InventoryCrafting;getStackInSlot(I)Lnet/minecraft/item/ItemStack;", - shift = At.Shift.AFTER)) + shift = At.Shift.BY, + by = 2)) public void gregtechCEu$getRemainingItemsInject(InventoryCrafting inv, CallbackInfoReturnable> cir, @Local ItemStack itemStack) { diff --git a/src/main/java/gregtech/mixins/minecraft/RegionRenderCacheBuilderMixin.java b/src/main/java/gregtech/mixins/minecraft/RegionRenderCacheBuilderMixin.java index dd080b2f912..52b73576d86 100644 --- a/src/main/java/gregtech/mixins/minecraft/RegionRenderCacheBuilderMixin.java +++ b/src/main/java/gregtech/mixins/minecraft/RegionRenderCacheBuilderMixin.java @@ -21,6 +21,6 @@ public class RegionRenderCacheBuilderMixin { @Inject(method = "", at = @At("TAIL")) public void initBloom(CallbackInfo ci) { - worldRenderers[BloomEffectUtil.BLOOM.ordinal()] = new BufferBuilder(131072); + worldRenderers[BloomEffectUtil.getBloomLayer().ordinal()] = new BufferBuilder(131072); } }