Create

Create

86M Downloads

Item Dupe Early Game [MC 1.16.4] [version: 1.16.3_v0.3b]

Sandman-ivan opened this issue ยท 3 comments

commented

No other mod interaction, Survival world.

What was I doing:
I was seeing if I can make a Mechanical Belt feed into an Andersite Funnel after an item had passed through a water fan. After I dropped a gear on the belt I noticed it was not picking up, but the chest was starting to stack more and more of them. I thought for a second maybe I just had multiple that I dropped. So I tested with an empty inventory and a single caucus. And sure enough it's duping the items. I don't know if it's the fan or the belt doing this. But I figured I would report it just in case.

Video: https://streamable.com/ngqwkk

commented

I have replicated the bug on mc1.16.3_v0.3b, as pictured below:
image

The following conditions are necessary to trigger the item duplication glitch:

  • The conveyor belt must be diagonal.
  • The block directly in front of the end of the belt must be a non-full block.
    • This includes slabs, fences, air, etc. (although top slabs will sometimes cause the item on the belt to drop and enter the inventory at the same time).
  • The funnel must be placed 1 block in front of the end of the belt and 1 block above the belt (i.e. above the transparent block).
  • The glitch only occurs on a laterally descending belt (i.e. in the picture above, reversing the direction of the belt and moving the funnel to the top of the belt would not cause the duplication glitch.

There are, as far as I can tell, no other conditions for the duplication glitch to occur. The setup can be reliably duplicated to verify these results.

commented

Documenting further investigation here:

The item(s) on the belt are being ejected as the belt determines that the edge of the belt is not blocked (due to the space directly in front of the belt being open).

The resulting ItemEntity then collides with both the belt and the funnel in the same tick. Strictly speaking, it collides with the belt before colliding with the funnel.

This is important because in BeltBlock.onEntityCollision():190, the ItemEntity is only marked for removal - the underlying ItemStack is not updated:

ItemStack remainder = handler.insertItem(0, itemEntity.getItem()
.copy(), false);
if (remainder.isEmpty())
itemEntity.remove();

Compare with the equivalent code in FunnelBlock:

ItemStack remainder = tryInsert(worldIn, pos, toInsert, false);
if (remainder.isEmpty())
itemEntity.remove();
if (remainder.getCount() < toInsert.getCount())
itemEntity.setItem(remainder);

... noting how the passed-in ItemEntity is updated with the remainder ItemStack.

Entity.remove only removes the Entity from the world on the following tick, so the omission of updating the ItemEntity in BeltBlock is likely (definitely, see below) causing the duplication glitch.

UPDATE: Confirmed. Updating the ItemEntity with the (empty) ItemStack results in an interesting visual glitch, but no item duplication.

Glitch.Documentation.mp4
commented

Awesome job! I actually understood what you said there lol. I may not program for MC Mods, but I do get it. I'm glad you were able to figure out the solution!