diff --git a/src/main/java/com/simibubi/create/content/contraptions/actors/harvester/HarvesterMovementBehaviour.java b/src/main/java/com/simibubi/create/content/contraptions/actors/harvester/HarvesterMovementBehaviour.java index 9d1d1d8bfb..715c91a242 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/actors/harvester/HarvesterMovementBehaviour.java +++ b/src/main/java/com/simibubi/create/content/contraptions/actors/harvester/HarvesterMovementBehaviour.java @@ -4,6 +4,7 @@ import com.simibubi.create.compat.farmersdelight.FarmersDelightCompat; +import net.minecraft.world.level.block.CaveVines; import net.minecraft.world.level.block.MushroomBlock; import org.jetbrains.annotations.Nullable; @@ -91,8 +92,10 @@ public void visitNewPosition(MovementContext context, BlockPos pos) { MutableBoolean seedSubtracted = new MutableBoolean(notCropButCuttable); BlockState state = stateVisited; BlockHelper.destroyBlockAs(world, pos, null, item, effectChance, stack -> { - if (AllConfigs.server().kinetics.harvesterReplants.get() && !seedSubtracted.getValue() - && ItemHelper.sameItem(stack, new ItemStack(state.getBlock()))) { + if (AllConfigs.server().kinetics.harvesterReplants.get() + && !seedSubtracted.getValue() + && ItemHelper.sameItem(stack, new ItemStack(state.getBlock())) + && !ItemHelper.sameItem(stack, new ItemStack(Items.GLOW_BERRIES))) { stack.shrink(1); seedSubtracted.setTrue(); } @@ -107,6 +110,13 @@ public boolean isValidCrop(Level world, BlockPos pos, BlockState state) { boolean harvestPartial = AllConfigs.server().kinetics.harvestPartiallyGrown.get(); boolean replant = AllConfigs.server().kinetics.harvesterReplants.get(); + if (state.getBlock() instanceof CaveVines) { + if (harvestPartial) + return true; + return state.getValue(BlockStateProperties.BERRIES); + } + + if (state.getBlock() instanceof CropBlock crop) { if (harvestPartial) return state != crop.getStateForAge(0) || !replant; @@ -144,6 +154,8 @@ public boolean isValidOther(Level world, BlockPos pos, BlockState state) { return true; if (state.getBlock() instanceof CocoaBlock) return state.getValue(CocoaBlock.AGE) == CocoaBlock.MAX_AGE; + if (state.getBlock() instanceof CaveVines) + return false; if (state.getCollisionShape(world, pos) .isEmpty()) { @@ -174,15 +186,25 @@ public boolean isValidOther(Level world, BlockPos pos, BlockState state) { } private BlockState cutCrop(Level world, BlockPos pos, BlockState state) { - if (!AllConfigs.server().kinetics.harvesterReplants.get()) { - if (state.getFluidState() - .isEmpty()) - return Blocks.AIR.defaultBlockState(); - return state.getFluidState() - .createLegacyBlock(); - } + boolean replant = AllConfigs.server().kinetics.harvesterReplants.get(); + boolean harvestPartial = AllConfigs.server().kinetics.harvestPartiallyGrown.get(); Block block = state.getBlock(); + + if (block instanceof CaveVines) { + if (harvestPartial || !replant) + return removeBlockKeepingFluid(state); + + if (state.hasProperty(BlockStateProperties.BERRIES)) + return state.setValue(BlockStateProperties.BERRIES, false); + + return state; + } + + if (!replant) { + return removeBlockKeepingFluid(state); + } + if (block instanceof CropBlock crop) { BlockState newState = crop.getStateForAge(0); if (!newState.is(block)) @@ -194,11 +216,7 @@ private BlockState cutCrop(Level world, BlockPos pos, BlockState state) { return state.setValue(BlockStateProperties.AGE_3, Integer.valueOf(1)); } if (AllBlockTags.SUGAR_CANE_VARIANTS.matches(block) || block instanceof GrowingPlantBlock) { - if (state.getFluidState() - .isEmpty()) - return Blocks.AIR.defaultBlockState(); - return state.getFluidState() - .createLegacyBlock(); + return removeBlockKeepingFluid(state); } if (state.getCollisionShape(world, pos) .isEmpty() || block instanceof CocoaBlock) { @@ -212,9 +230,14 @@ private BlockState cutCrop(Level world, BlockPos pos, BlockState state) { } } + return removeBlockKeepingFluid(state); + } + + private BlockState removeBlockKeepingFluid(BlockState state) { if (state.getFluidState() .isEmpty()) return Blocks.AIR.defaultBlockState(); + return state.getFluidState() .createLegacyBlock(); }