From 061dfd0e19f85cddb1b237e662c448696cdd4a87 Mon Sep 17 00:00:00 2001 From: Yeregorix Date: Sat, 21 Dec 2024 21:24:52 +0100 Subject: [PATCH] Fix SpongeForge attack and furnace mixins --- ...AbstractFurnaceBlockEntityMixin_Forge.java | 24 ++++++++++--------- .../entity/LivingEntityMixin_Attack_Impl.java | 11 +++------ 2 files changed, 16 insertions(+), 19 deletions(-) diff --git a/forge/src/mixins/java/org/spongepowered/forge/mixin/core/world/level/block/entity/AbstractFurnaceBlockEntityMixin_Forge.java b/forge/src/mixins/java/org/spongepowered/forge/mixin/core/world/level/block/entity/AbstractFurnaceBlockEntityMixin_Forge.java index 34cab814694..5a8394cd809 100644 --- a/forge/src/mixins/java/org/spongepowered/forge/mixin/core/world/level/block/entity/AbstractFurnaceBlockEntityMixin_Forge.java +++ b/forge/src/mixins/java/org/spongepowered/forge/mixin/core/world/level/block/entity/AbstractFurnaceBlockEntityMixin_Forge.java @@ -27,10 +27,11 @@ import net.minecraft.core.BlockPos; import net.minecraft.core.NonNullList; import net.minecraft.core.RegistryAccess; +import net.minecraft.server.level.ServerLevel; import net.minecraft.util.Mth; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.crafting.RecipeHolder; -import net.minecraft.world.level.Level; +import net.minecraft.world.item.crafting.SingleRecipeInput; import net.minecraft.world.level.block.entity.AbstractFurnaceBlockEntity; import net.minecraft.world.level.block.state.BlockState; import org.objectweb.asm.Opcodes; @@ -69,7 +70,7 @@ public abstract class AbstractFurnaceBlockEntityMixin_Forge implements AbstractF // @formatter:off @Shadow protected NonNullList items; @Shadow int cookingProgress; - @Shadow private boolean shadow$canBurn(RegistryAccess registryAccess, @Nullable RecipeHolder recipe, NonNullList slots, int maxStackSize) { + @Shadow private boolean shadow$canBurn(RegistryAccess registryAccess, @Nullable RecipeHolder recipe, SingleRecipeInput input, NonNullList slots, int maxStackSize) { throw new UnsupportedOperationException("Shadowed canBurn"); } // @formatter:on @@ -79,15 +80,16 @@ public abstract class AbstractFurnaceBlockEntityMixin_Forge implements AbstractF // Tick up and Start @Redirect(method = "serverTick", at = @At(value = "INVOKE", - target = "Lnet/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity;canBurn(Lnet/minecraft/core/RegistryAccess;Lnet/minecraft/world/item/crafting/RecipeHolder;Lnet/minecraft/core/NonNullList;I)Z", + target = "Lnet/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity;canBurn(Lnet/minecraft/core/RegistryAccess;Lnet/minecraft/world/item/crafting/RecipeHolder;Lnet/minecraft/world/item/crafting/SingleRecipeInput;Lnet/minecraft/core/NonNullList;I)Z", ordinal = 1)) private static boolean forge$checkIfCanSmelt(final AbstractFurnaceBlockEntity entityIn, - final RegistryAccess registryAccess, - final RecipeHolder recipe, - final NonNullList slots, - final int maxStackSize) { + final RegistryAccess registryAccess, + final RecipeHolder recipe, + final SingleRecipeInput input, + final NonNullList slots, + final int maxStackSize) { final var entity = (AbstractFurnaceBlockEntityMixin_Forge) (Object) (entityIn); - if (!entity.shadow$canBurn(registryAccess, recipe, slots, maxStackSize)) { + if (!entity.shadow$canBurn(registryAccess, recipe, input, slots, maxStackSize)) { return false; } @@ -111,7 +113,7 @@ public abstract class AbstractFurnaceBlockEntityMixin_Forge implements AbstractF // Tick down @Redirect(method = "serverTick", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/Mth;clamp(III)I")) private static int forge$resetCookTimeIfCancelled(final int newCookTime, final int zero, final int totalCookTime, - final Level level, final BlockPos entityPos, final BlockState state, final AbstractFurnaceBlockEntity entityIn) { + final ServerLevel level, final BlockPos entityPos, final BlockState state, final AbstractFurnaceBlockEntity entityIn) { final int clampedCookTime = Mth.clamp(newCookTime, zero, totalCookTime); final var entity = (AbstractFurnaceBlockEntityMixin_Forge) (Object) entityIn; final ItemStackSnapshot fuel = ItemStackUtil.snapshotOf(entity.items.get(1)); @@ -133,7 +135,7 @@ public abstract class AbstractFurnaceBlockEntityMixin_Forge implements AbstractF slice = @Slice( from = @At(value = "FIELD", target = "Lnet/minecraft/world/level/block/Blocks;WET_SPONGE:Lnet/minecraft/world/level/block/Block;", opcode = Opcodes.GETSTATIC) )) - private void forge$captureBucketFill(final RegistryAccess registryAccess, final RecipeHolder recipe, final NonNullList slots, final int maxStackSize, final CallbackInfoReturnable cir) { + private void forge$captureBucketFill(final RegistryAccess registryAccess, final RecipeHolder recipe, final SingleRecipeInput input, final NonNullList slots, final int maxStackSize, final CallbackInfoReturnable cir) { this.forge$filledWaterBucket = true; } @@ -142,7 +144,7 @@ public abstract class AbstractFurnaceBlockEntityMixin_Forge implements AbstractF locals = LocalCapture.CAPTURE_FAILHARD, at = @At(value = "INVOKE", target = "Lnet/minecraft/world/item/ItemStack;shrink(I)V")) private void forge$afterSmeltItem( - final RegistryAccess registryAccess, final RecipeHolder recipe, + final RegistryAccess registryAccess, final RecipeHolder recipe, final SingleRecipeInput input, final NonNullList slots, final int maxStackSize, final CallbackInfoReturnable cir, final ItemStack itemIn, final ItemStack recipeResult, final ItemStack itemOut diff --git a/src/mixins/java/org/spongepowered/common/mixin/core/world/entity/LivingEntityMixin_Attack_Impl.java b/src/mixins/java/org/spongepowered/common/mixin/core/world/entity/LivingEntityMixin_Attack_Impl.java index 8bce4b1a806..0835f4869de 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/core/world/entity/LivingEntityMixin_Attack_Impl.java +++ b/src/mixins/java/org/spongepowered/common/mixin/core/world/entity/LivingEntityMixin_Attack_Impl.java @@ -43,7 +43,6 @@ import org.spongepowered.asm.mixin.injection.*; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import org.spongepowered.asm.mixin.injection.callback.LocalCapture; import org.spongepowered.common.SpongeCommon; import org.spongepowered.common.bridge.world.entity.LivingEntityBridge; import org.spongepowered.common.event.tracking.PhaseTracker; @@ -170,14 +169,10 @@ public abstract class LivingEntityMixin_Attack_Impl extends EntityMixin implemen * After calling #actuallyHurt (even when invulnerable), if cancelled return early or is still invulnerable * and reset {@link #lastHurt} and {@link #invulnerableTime} */ - @Inject(method = "hurtServer", locals = LocalCapture.CAPTURE_FAILHARD, cancellable = true, + @Inject(method = "hurtServer", cancellable = true, at = @At(value = "INVOKE", shift = At.Shift.AFTER, ordinal = 0, target = "Lnet/minecraft/world/entity/LivingEntity;actuallyHurt(Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/world/damagesource/DamageSource;F)V")) - private void attackImpl$afterActuallyHurt1( - final ServerLevel level, final DamageSource source, final float damageTaken, - final CallbackInfoReturnable cir, final float dealtDamage, final boolean isBlocked, - float $$5, boolean wasHurt - ) { + private void attackImpl$afterActuallyHurt1(final ServerLevel level, final DamageSource source, final float damageTaken, final CallbackInfoReturnable cir) { if (this.attackImpl$actuallyHurtCancelled || damageTaken <= this.lastHurt) { this.invulnerableTime = this.attackImpl$InvulnerableTime; this.lastHurt = this.attackImpl$lastHurt; @@ -189,7 +184,7 @@ public abstract class LivingEntityMixin_Attack_Impl extends EntityMixin implemen * After calling #actuallyHurt, if cancelled return early * Also reset values */ - @Inject(method = "hurtServer",cancellable = true, + @Inject(method = "hurtServer", cancellable = true, at = @At(value = "INVOKE", shift = At.Shift.AFTER, ordinal = 1, target = "Lnet/minecraft/world/entity/LivingEntity;actuallyHurt(Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/world/damagesource/DamageSource;F)V")) private void attackImpl$afterActuallyHurt2(ServerLevel $$0, DamageSource $$1, float $$2, CallbackInfoReturnable cir) {