The bug
When one turtle egg is cracked, you can place more on the same block and they will be cracked, too.
To reproduce
Reproduction steps provided by @unknown:
Generate world
Use command /setblock ~ ~ ~ minecraft:turtle_egg[eggs=1,hatch=1]
Grab Turtle Egg from inventory
Place another egg by right-clicking
Observe issue
Code analysis
Code analysis and fix by @unknown can be found in this comment.
Attachments
Comments 17
With the block states that turtle eggs have it isn’t possible to fix this. Fix would require making different turtle eggs on the same block have different hatch states somehow.
I believe the easiest fix would be to just disallow placing turtle eggs on already hatched turtle eggs. This could be done by adding a new condition to check the HATCH
value inside TurtleEggBlock#canBeReplaced(...)
:
...
@Override
public boolean canBeReplaced(BlockState $$0, BlockPlaceContext $$1) {
if (!$$1.isSecondaryUseActive() && $$1.getItemInHand().is(this.asItem()) && $$0.getValue(EGGS) < 4 && $$0.getValue(HATCH) == 0) {
return true;
}
return super.canBeReplaced($$0, $$1);
}
...
Repro steps
Generate world
Use command /setblock ~ ~ ~ minecraft:turtle_egg[eggs=1,hatch=1]
Grab Turtle Egg from inventory
Place another egg by right-clicking
Observe issue