Um-Mitternacht / Bewitchment

Mod inspired by Witchery
118 stars 69 forks source link

Tool Poppet dupe #620

Closed focamacho closed 4 years ago

focamacho commented 4 years ago

I couldn't find a better way to do this, so maybe you can improve the code. I did some tests and it seems to have worked well.

I will explain what I did and why: Forge is sending a "PlayerDestroyItemEvent" when a block is placed on the floor, and when an item is placed in a item frame. This means that anything can be duplicated using the Poppet.

Using if(original.getMaxDamage() == 0) return; fixes dupes using blocks #587 #590.

For item frames, the best way I found is to collect all instances of EntityItemFrame near the player, and make a check to see if the item in it is the same as the item that was "broken". If so, then Poppet will do nothing, avoiding dupe