Skip to content

Commit

Permalink
Improve compatibility of Sapling Behavior tweak, fixes #408
Browse files Browse the repository at this point in the history
  • Loading branch information
ACGaming committed Mar 20, 2024
1 parent 6ec569b commit 14d570e
Showing 1 changed file with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,25 @@
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
{
@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();
}
}

0 comments on commit 14d570e

Please sign in to comment.