Item duplication exploit with movement code + hopper logic
When an ItemEntity runs Entity#checksInsideBlocks(), it may be contained in more than 1 hopper block. There are setups to make this happen perfectly 100% of the time. So this is not a random issue that may or may not occur. The HopperBlock#entityInside will try move the item into the hopper, however the code to do this has a fault:
if (itemstack1.isEmpty()) { flag = true; itemEntity.discard(); } else { itemEntity.setItem(itemstack1); }
When the item count is reduced to 0, it does not update the ItemStack contained in the ItemEntity. The next hopper that the ItemEntity will check will be able to move the item in, creating a duplication. This exploit only works for single count items, but people can easily use this with shulker items which of course can hold up to 1728 items in total.
Players are able to create machines to perform this duplication once every 60 ticks automatically, while they idle nearby. One machine can dupe 2 million items per hour, and that's just one machine. So, the duplication exploit is pretty significant, probably one of the biggest in the past few years.
This should be fixed by making the setItem call regardless of whether the new itemstack is empty. Additionally, the hopper logic should check if the item entity is removed before trying to use it.
And finally, I see this code pattern in many other areas (refusing to update the ItemEntity stack if the new stack is empty). As such, only adjusting the hopper code is ineffective. This needs to be done for all areas.
2023-08-27, 02:32 AM
2023-08-30, 09:27 AM
2023-08-30, 09:27 AM
2
2