Vincent Lee: 2 Extract HornItem.canHarvest from HornItem.breakGrass Prevent Horn of the Canopy from breaking persistent leaves 2 files changed, 31 insertions(+), 12 deletions(-)
botania/patches/linux.yml: SUCCESS in 19m44s [Extract HornItem.canHarvest from HornItem.breakGrass][0] from [Vincent Lee][1] [0]: https://lists.sr.ht/~williewillus/violet-moon/patches/41445 [1]: mailto:vincent@vincent-lee.net ✓ #997094 SUCCESS botania/patches/linux.yml https://builds.sr.ht/~williewillus/job/997094
Both commits look good
Copy & paste the following snippet into your terminal to import this patchset into git:
curl -s https://lists.sr.ht/~williewillus/violet-moon/patches/41445/mbox | git am -3Learn more about email & git
No functional change, refactor for next commit diff --git a/Xplat/src/main/java/vazkii/botania/common/item/HornItem.java b/Xplat/src/main/java/vazkii/botania/common/item/HornItem.java --- a/Xplat/src/main/java/vazkii/botania/common/item/HornItem.java +++ b/Xplat/src/main/java/vazkii/botania/common/item/HornItem.java @@ -19,7 +19,6 @@ import net.minecraft.world.item.ItemUtils; import net.minecraft.world.item.UseAnim; import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.BushBlock; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.state.BlockState; @@ -70,6 +69,27 @@ } } + private static boolean canHarvest(Level level, ItemStack stack, BlockPos pos, + @Nullable LivingEntity user, EnumHornType type) { + BlockState state = level.getBlockState(pos); + BlockEntity be = level.getBlockEntity(pos); + + HornHarvestable harvestable = XplatAbstractions.INSTANCE.findHornHarvestable(level, pos, state, be); + if (harvestable != null) { + return harvestable.canHornHarvest(level, pos, stack, type, user); + } else { + switch (type) { + default: + case WILD: + return state.getBlock() instanceof BushBlock && !state.is(BotaniaTags.Blocks.SPECIAL_FLOWERS); + case CANOPY: + return state.is(BotaniaTags.Blocks.HORN_OF_THE_CANOPY_BREAKABLE); + case COVERING: + return state.is(BotaniaTags.Blocks.HORN_OF_THE_COVERING_BREAKABLE); + } + } + } + public static void breakGrass(Level world, ItemStack stack, BlockPos srcPos, @Nullable LivingEntity user) { EnumHornType type = null; if (stack.is(BotaniaItems.grassHorn)) { @@ -86,19 +106,11 @@ for (BlockPos pos : BlockPos.betweenClosed(srcPos.offset(-range, -rangeY, -range), srcPos.offset(range, rangeY, range))) { - BlockState state = world.getBlockState(pos); - Block block = state.getBlock(); - BlockEntity be = world.getBlockEntity(pos); - HornHarvestable harvestable = XplatAbstractions.INSTANCE.findHornHarvestable(world, pos, state, be); - if (BergamuteBlockEntity.isBergamuteNearby(world, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5)) { continue; } - if (harvestable != null - ? harvestable.canHornHarvest(world, pos, stack, type, user) - : type == EnumHornType.WILD && block instanceof BushBlock && !state.is(BotaniaTags.Blocks.SPECIAL_FLOWERS) - || type == EnumHornType.CANOPY && state.is(BotaniaTags.Blocks.HORN_OF_THE_CANOPY_BREAKABLE) - || type == EnumHornType.COVERING && state.is(BotaniaTags.Blocks.HORN_OF_THE_COVERING_BREAKABLE)) { + + if (HornItem.canHarvest(world, stack, pos, user, type)) { coords.add(pos.immutable()); } }
Likely a regression from the tag migration. Closes #4379 diff --git a/Xplat/src/main/java/vazkii/botania/common/item/HornItem.java b/Xplat/src/main/java/vazkii/botania/common/item/HornItem.java --- a/Xplat/src/main/java/vazkii/botania/common/item/HornItem.java +++ b/Xplat/src/main/java/vazkii/botania/common/item/HornItem.java @@ -20,6 +20,7 @@ import net.minecraft.world.item.UseAnim; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.BushBlock; +import net.minecraft.world.level.block.LeavesBlock; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.state.BlockState; @@ -82,8 +83,14 @@ default: case WILD: return state.getBlock() instanceof BushBlock && !state.is(BotaniaTags.Blocks.SPECIAL_FLOWERS); - case CANOPY: + case CANOPY: { + if (state.getBlock() instanceof LeavesBlock + && state.getValue(LeavesBlock.PERSISTENT)) { + return false; + } + return state.is(BotaniaTags.Blocks.HORN_OF_THE_CANOPY_BREAKABLE); + } case COVERING: return state.is(BotaniaTags.Blocks.HORN_OF_THE_COVERING_BREAKABLE); }
builds.sr.ht <builds@sr.ht>botania/patches/linux.yml: SUCCESS in 19m44s [Extract HornItem.canHarvest from HornItem.breakGrass][0] from [Vincent Lee][1] [0]: https://lists.sr.ht/~williewillus/violet-moon/patches/41445 [1]: mailto:vincent@vincent-lee.net ✓ #997094 SUCCESS botania/patches/linux.yml https://builds.sr.ht/~williewillus/job/997094
Artemis System <theartemissystem@gmail.com>Both commits look good