From 6d01f99073406b59554c04a15665146c97c38f3e Mon Sep 17 00:00:00 2001 From: yurisuika Date: Sun, 20 Feb 2022 19:01:39 -0800 Subject: [PATCH] possible ticking world exception fix --- gradle.properties | 2 +- .../com/yurisuika/blossom/block/FloweringLeavesBlock.java | 4 +--- .../com/yurisuika/blossom/mixin/block/LeavesBlockMixin.java | 5 +++-- .../mixin/entity/passive/BeeEntityGrowCropsGoalMixin.java | 5 +++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/gradle.properties b/gradle.properties index 62230cd..b5c2300 100644 --- a/gradle.properties +++ b/gradle.properties @@ -8,7 +8,7 @@ org.gradle.jvmargs=-Xmx1G loader_version=0.12.12 # Mod Properties - mod_version = 1.0.2 + mod_version = 1.0.3 maven_group = com.yurisuika.blossom archives_base_name = blossom diff --git a/src/main/java/com/yurisuika/blossom/block/FloweringLeavesBlock.java b/src/main/java/com/yurisuika/blossom/block/FloweringLeavesBlock.java index 2425605..ae1b2bf 100644 --- a/src/main/java/com/yurisuika/blossom/block/FloweringLeavesBlock.java +++ b/src/main/java/com/yurisuika/blossom/block/FloweringLeavesBlock.java @@ -140,10 +140,8 @@ private static BlockState updateDistanceFromLogs(BlockState state, WorldAccess w private static int getDistanceFromLog(BlockState state) { if (state.isIn(BlockTags.LOGS)) { return 0; - } else if (state.isIn(BlockTags.LEAVES)) { - return state.get(DISTANCE); } else { - return 7; + return (state.getBlock() instanceof LeavesBlock || state.getBlock() instanceof FloweringLeavesBlock) ? state.get(DISTANCE) : 7; } } diff --git a/src/main/java/com/yurisuika/blossom/mixin/block/LeavesBlockMixin.java b/src/main/java/com/yurisuika/blossom/mixin/block/LeavesBlockMixin.java index 0207bc7..200ecc9 100644 --- a/src/main/java/com/yurisuika/blossom/mixin/block/LeavesBlockMixin.java +++ b/src/main/java/com/yurisuika/blossom/mixin/block/LeavesBlockMixin.java @@ -1,5 +1,6 @@ package com.yurisuika.blossom.mixin.block; +import com.yurisuika.blossom.block.FloweringLeavesBlock; import net.minecraft.block.BlockState; import net.minecraft.block.LeavesBlock; import net.minecraft.tag.BlockTags; @@ -17,8 +18,8 @@ public class LeavesBlockMixin { private static void injectDistance(BlockState state, CallbackInfoReturnable info) { if (state.isIn(BlockTags.LOGS)) { info.setReturnValue(0); - } else if (state.isIn(BlockTags.LEAVES)) { - info.setReturnValue(state.get(DISTANCE)); + } else if (state.getBlock() instanceof LeavesBlock || state.getBlock() instanceof FloweringLeavesBlock) { + info.setReturnValue((Integer)state.get(DISTANCE)); } else { info.setReturnValue(7); } diff --git a/src/main/java/com/yurisuika/blossom/mixin/entity/passive/BeeEntityGrowCropsGoalMixin.java b/src/main/java/com/yurisuika/blossom/mixin/entity/passive/BeeEntityGrowCropsGoalMixin.java index 60124e1..77ae5c3 100644 --- a/src/main/java/com/yurisuika/blossom/mixin/entity/passive/BeeEntityGrowCropsGoalMixin.java +++ b/src/main/java/com/yurisuika/blossom/mixin/entity/passive/BeeEntityGrowCropsGoalMixin.java @@ -41,7 +41,8 @@ private void injectTick(CallbackInfo ci) { bl = true; intProperty = floweringLeavesBlock.getAgeProperty(); } - } else if (block instanceof LeavesBlock leavesBlock) { + } + else if (block instanceof LeavesBlock leavesBlock) { if (leavesBlock == Blocks.OAK_LEAVES) { bl = true; } @@ -54,7 +55,7 @@ private void injectTick(CallbackInfo ci) { .with(PERSISTENT, blockState.get(PERSISTENT)) ); } - else { + else if (block instanceof FloweringLeavesBlock) { entity.world.setBlockState(blockPos, blockState.with(intProperty, blockState.get(intProperty) + 1)); } entity.addCropCounter();