From 14d570e04d36efb047dcec447463869c3f96d85b Mon Sep 17 00:00:00 2001 From: ACGaming <4818419+ACGaming@users.noreply.github.com> Date: Wed, 20 Mar 2024 16:06:33 +0100 Subject: [PATCH] Improve compatibility of Sapling Behavior tweak, fixes #408 --- .../tweaks/blocks/sapling/mixin/UTSaplingMixin.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/main/java/mod/acgaming/universaltweaks/tweaks/blocks/sapling/mixin/UTSaplingMixin.java b/src/main/java/mod/acgaming/universaltweaks/tweaks/blocks/sapling/mixin/UTSaplingMixin.java index cbf197f2..2ab47fef 100644 --- a/src/main/java/mod/acgaming/universaltweaks/tweaks/blocks/sapling/mixin/UTSaplingMixin.java +++ b/src/main/java/mod/acgaming/universaltweaks/tweaks/blocks/sapling/mixin/UTSaplingMixin.java @@ -11,8 +11,10 @@ import mod.acgaming.universaltweaks.config.UTConfigTweaks; import mod.acgaming.universaltweaks.util.UTRandomUtil; import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Overwrite; import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(BlockSapling.class) public abstract class UTSaplingMixin extends BlockBush @@ -20,17 +22,14 @@ public abstract class UTSaplingMixin extends BlockBush @Shadow public abstract void grow(World worldIn, BlockPos pos, IBlockState state, Random rand); - /** - * @author ACGaming - * @reason Optimized + customizable sapling update tick - */ - @Overwrite - public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand) + @Inject(method = "updateTick", at = @At("HEAD"), cancellable = true) + public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand, CallbackInfo ci) { if (!worldIn.isRemote) { super.updateTick(worldIn, pos, state, rand); if (UTRandomUtil.chance(UTConfigTweaks.BLOCKS.SAPLING_BEHAVIOR.utSaplingGrowthChance) && worldIn.isAreaLoaded(pos, 1) && worldIn.getLightFromNeighbors(pos.up()) >= UTConfigTweaks.BLOCKS.SAPLING_BEHAVIOR.utSaplingLightLevel) this.grow(worldIn, pos, state, rand); } + ci.cancel(); } } \ No newline at end of file