mojira.dev
MC-218528

Turtle eggs can become broken by placing them in the same block as some already broken eggs

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:

  1. Generate world

  2. Use command /setblock ~ ~ ~ minecraft:turtle_egg[eggs=1,hatch=1]

  3. Grab Turtle Egg from inventory

  4. Place another egg by right-clicking

  5. Observe issue

Code analysis

Code analysis and fix by @unknown can be found in this comment.

Attachments

Comments 17

Repro steps

  1. Generate world

  2. Use command /setblock ~ ~ ~ minecraft:turtle_egg[eggs=1,hatch=1]

  3. Grab Turtle Egg from inventory

  4. Place another egg by right-clicking

  5. Observe issue

Video attached. Also affects 21w10a.

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.

Or, another option would be to not let players place turtle eggs on cracked turtle eggs.

Can confirm in 21w11a.

7 more comments

Can confirm in 1.18.2.

Can confirm in 1.19.

Can confirm in 1.19.2.

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);
    }
...

Can confirm in 1.19.3

Jacob Robin

(Unassigned)

Confirmed

Block states, Items

1.16.5, 21w08b, 21w10a, 21w11a, 21w13a, ..., 1.19.3, 1.19.4, 23w14a, 1.20.1, 1.20.4

Retrieved