Incorrect harvester interaction with Collector's reap
HarbingerOfCrazy opened this issue ยท 3 comments
Minecraft Version
1.20.1
Describe the Bug
for the upper half of the lime_bush and pomgranate_bush age:0 is an illegal state, it's minimum age is 2. For some reason (0 1 and one only grow in the lower block).
It also bugs out the growth behavior of the bush as the lower half is not reset in tandem:

Reproduction Steps
- grow lime_bush or pomgranate_bush
- harvest said bush via harvester contraption
Expected Result
(with replant on)
The bush state is set to age:2 for both half:upper and half:lower (Block.below)
As a Modpack enthusiast and user of kubejs and the like, can we have a data/event driven version of the CRHarvesterMovementBehaviorExtensions, so we can fix problems like that ourselves via datapack/scrip? (and add new harvestable blocks)
Debug Log
No response
fine_i_will_do_it_myself.jpg:
public static void harvestLimeBush(HarvesterMovementBehaviour behaviour,
MovementContext context,
BlockPos pos, BlockState state,
boolean replant, boolean partial)
{
if (!(state.getBlock() instanceof LimeBushBlock))
return;
- if (state.getValue(LimeBushBlock.STUNTED) || state.getValue(LimeBushBlock.HALF) == DoubleBlockHalf.LOWER)
+ if (state.getValue(LimeBushBlock.STUNTED))
return;
Level level = context.world;
boolean destroy = partial;
+ boolean isLowerHalf = state.getValue(LimeBushBlock.HALF) == DoubleBlockHalf.LOWER
if (state.getValue(AGE) == MAX_AGE) {
behaviour.dropItem(context, new ItemStack(CRItems.LIME.get(), 2 + level.random.nextInt(2)));
if (replant) {
level.playSound(null, pos, SoundEvents.SWEET_BERRY_BUSH_PICK_BERRIES, SoundSource.BLOCKS,
1.0F, 0.8F + level.random.nextFloat() * 0.4F);
- level.setBlockAndUpdate(pos, state.setValue(AGE, 0));
+ level.setBlockAndUpdate(pos, state.setValue(AGE, 2));
+ level.setBlockAndUpdate(isLowerHalf ? pos.above() : pos.below(), state.setValue(AGE, 2));
return;
}
destroy = true;
}
- BlockPos posBelow = pos.below();
+ BlockPos posBelow = isLowerHalf ? pos.above() : pos.below();
BlockState stateBelow = level.getBlockState(posBelow);
- if (destroy && stateBelow.is(state.getBlock()) && stateBelow.getValue(LimeBushBlock.HALF) == DoubleBlockHalf.LOWER) {
+ if (destroy && stateBelow.is(state.getBlock()) && stateBelow.getValue(LimeBushBlock.HALF) == isLowerHalf ? DoubleBlockHalf.UPPER: DoubleBlockHalf.LOWER) {
BlockHelper.destroyBlock(level, pos, 1, stack -> behaviour.dropItem(context, stack));
BlockHelper.destroyBlock(level, posBelow, 1, stack -> behaviour.dropItem(context, stack));
}
}
public static void harvestPomegranateBush(HarvesterMovementBehaviour behaviour,
MovementContext context,
BlockPos pos, BlockState state,
boolean replant, boolean partial)
{
if (!(state.getBlock() instanceof PomegranateBushBlock))
return;
- if (state.getValue(PomegranateBushBlock.HALF) == DoubleBlockHalf.LOWER)
+ if (state.getValue(PomegranateBushBlock.STUNTED))
return;
Level level = context.world;
boolean destroy = partial;
+ boolean isLowerHalf = state.getValue(PomegranateBushBlock.HALF) == DoubleBlockHalf.LOWER
if (state.getValue(AGE) == MAX_AGE) {
behaviour.dropItem(context, new ItemStack(CRItems.POMEGRANATE.get(), 1 + level.random.nextInt(2)));
if (replant) {
level.playSound(null, pos, SoundEvents.SWEET_BERRY_BUSH_PICK_BERRIES, SoundSource.BLOCKS,
1.0F, 0.8F + level.random.nextFloat() * 0.4F);
- level.setBlockAndUpdate(pos, state.setValue(AGE, 0));
+ level.setBlockAndUpdate(pos, state.setValue(AGE, 2));
+ level.setBlockAndUpdate(isLowerHalf ? pos.above() : pos.below(), state.setValue(AGE, 2));
return;
}
destroy = true;
}
- BlockPos posBelow = pos.below();
+ BlockPos posBelow = isLowerHalf ? pos.above() : pos.below();
BlockState stateBelow = level.getBlockState(posBelow);
- if (destroy && stateBelow.is(state.getBlock()) && stateBelow.getValue(PomegranateBushBlock.HALF) == DoubleBlockHalf.LOWER) {
+ if (destroy && stateBelow.is(state.getBlock()) && stateBelow.getValue(PomegranateBushBlock.HALF) == isLowerHalf ? DoubleBlockHalf.UPPER: DoubleBlockHalf.LOWER) {
BlockHelper.destroyBlock(level, pos, 1, stack -> behaviour.dropItem(context, stack));
BlockHelper.destroyBlock(level, posBelow, 1, stack -> behaviour.dropItem(context, stack));
}
}stateBelow should be changed to stateOther for consistency and readability, but i can't be further bothered.
just please fix this in the next build, it is really annoying.
And it breaks them now, my best guess is that, at least, the first block state change has to be done without the update.
For Reference the original code:
level.setBlock(pos, picked, 2); // Revert to pre-flowering
level.setBlock(pos.above(), picked.setValue(HALF, DoubleBlockHalf.UPPER), 2); // Revert upper to pre-flowering
level.gameEvent(GameEvent.BLOCK_CHANGE, pos, GameEvent.Context.of(player, picked));my bad