Carpet

Carpet

2M Downloads

Fake players with attack continuous can duplicate dragon eggs

Raffq opened this issue ยท 1 comments

commented

A fake player in survival mode that attacks continuously a dragon egg can duplicate the dragon egg.

Demonstration video:
https://youtu.be/ijtHXzqfe24

How to reproduce:

  1. spawn a fake player using "/player spawn" and make sure that it is not looking at any blocks
  2. use "/player attack continuous"
  3. place a dragon egg in front of the player.
    You will see that 2 eggs teleport instead of 1.

Also if you are testing with multiple eggs, make sure that you don't place the dragon egg in the same spot where the previous one was placed, otherwise the player will mine it and the dragon egg won't teleport (that should be a vanilla bug)

commented

Cause is here:

player.gameMode.handleBlockBreakAction(pos, ServerboundPlayerActionPacket.Action.START_DESTROY_BLOCK, side, player.getLevel().getMaxBuildHeight(), -1);
boolean notAir = !state.isAir();
if (notAir && ap.curBlockDamageMP == 0)
{
state.attack(player.level, pos, player);
}

ServerPlayerGameMode.handleBlockBreakAction() is calling attack() on the dragon egg blockstate, which teleports it. Back in Carpet code we check if (notAir && ap.curBlockDamageMP == 0) which will always be true and call it again, with it's original position, the teleport() code in DragonEggBlock dutifully finds an appropriate location and creates and new egg there, and 'removes' the blockstate at the original position (which is already air now) rather than the actual 'original' egg.

The second call to attack() would seem to be unneeded, but I can't say why it is there so I don't really know. The condition certainly seems invalid though, as the notAir var is set from the DragonEgg BlockState, which is no longer at pos.