mojira.dev
MC-268011

Hoppers leak the last world they sucked item on

Hoppers leak the last world they sucked item on and can keep the unloaded world in the memory until new item is sucked on in a loaded world. This seem to be due to the call to setItem(ItemStack.EMPTY) just before discarding the item. This ends up calling the ItemStack#setEntityRepresentation which then roots the entity to the static ItemStack.EMPTY.

The fix would be to remove this call and/or adding a guard or a assert to ItemStack#setEntityRepresentation to ignore ItemStack.EMPTY.

HopperBlockEntity:

public static boolean addItem(Container $$0, ItemEntity $$1) {
	boolean $$2 = false;
	ItemStack $$3 = $$1.getItem().copy();
	ItemStack $$4 = addItem((Container)null, $$0, $$3, (Direction)null);
	if ($$4.isEmpty()) {
		$$2 = true;
		$$1.setItem(ItemStack.EMPTY); //Remove this?
		$$1.discard();
	} else {
		$$1.setItem($$4);
	}

	return $$2;
}

 

ItemEntity:

public void setItem(ItemStack $$0) {
	this.getEntityData().set(DATA_ITEM, $$0);
}

@Override
public void onSyncedDataUpdated(EntityDataAccessor<?> $$0) {
	super.onSyncedDataUpdated($$0);
	if (DATA_ITEM.equals($$0)) {
		this.getItem().setEntityRepresentation(this);
	}
}

 

ItemStack:

public void setEntityRepresentation(@Nullable Entity $$0) {
	//Add guard here? Or assert?
	this.entityRepresentation = $$0;
}

Comments 0

No comments.

isokissa3

gegy

Plausible

Platform

Normal

Performance

1.20.4, 24w03b

24w09a

Retrieved