Fake players with attack continuous can duplicate dragon eggs
Raffq opened this issue ยท 1 comments
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:
- spawn a fake player using "/player spawn" and make sure that it is not looking at any blocks
- use "/player attack continuous"
- 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)
Cause is here:
fabric-carpet/src/main/java/carpet/helpers/EntityPlayerActionPack.java
Lines 414 to 419 in 29afb87
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.