mojira.dev

Aloi

Assigned

No issues.

Reported

View all
MC-306074 Clicking on a map extending recipe's result when the item is not a filled map crashes the game Confirmed MC-306072 The game now crashes when viewing the tooltip of a bundle containing an item stack with incompatible data Confirmed MC-303119 Feeding a cat or wolf in Survival mode with only one item in the selected item slot does not restore as much health as it should Fixed

Comments

Based on the code analysis, it's only possible if:

  • The villager is sleeping

  • The villager is making is trading

  • Or, the item is a villager_spawn_egg

It's also necessary that the item doesn't have any other effect when interacting with the villager. For example, if it's a villager spawn egg by default, it will summon a baby villager, but it's possible to remove minecraft:entity_data.

Try using, for example:

/give @s minecraft:villager_spawn_egg[minecraft:equippable={equip_on_interact:true,slot:head,swappable:false},!minecraft:entity_data,minecraft:item_model=big_dripleaf,minecraft:item_name={translate: "block.minecraft.big_dripleaf"}] 1

Can confirm in 26.1 snap9

Code analysis

In SimpleContainer has:

public ItemStack removeItem(final int slot, final int count) {
		ItemStack result = ContainerHelper.removeItem(this.items, slot, count);
		if (!result.isEmpty()) {
			this.setChanged();
		}

		return result;
	}

And in HopperBlockEntity

private static boolean tryTakeInItemFromSlot(final Hopper hopper, final Container container, final int slot, final Direction direction) {
    ItemStack itemStack = container.getItem(slot);
    if (!itemStack.isEmpty() && canTakeItemFromContainer(hopper, container, itemStack, slot, direction)) {
       int originalCount = itemStack.getCount();
       ItemStack result = addItem(container, hopper, container.removeItem(slot, 1), null);
       if (result.isEmpty()) {
	       container.setChanged();
	       return true;
       }

Even if addItem(...) fails, simply calling it ends up calling removeItem(...) which calls this.setChanged().

The setChanged() empties the composter (in ComposterBlock.OutputContainer):

public void setChanged() {
    ComposterBlock.empty(null, this.state, this.level, this.pos);
    this.changed = true;
}

If the hopper is full (inventoryFull()), this doesn't happen because tryTakeInItemFromSlot(...)is not called.

The same thing happens when feeding a panda an item that is not in #panda_eats_from_ground. This significantly affects data packs with items in #panda_food that are not in #panda_eats_from_ground.

See https://minecraft.wiki/w/Item_tag_(Java_Edition)#panda_eats_from_ground%5D for a detailed explanation of the behavior.

This could be solved simply by removing the tag's condition from Panda.handleEating() on the line:

if (this.getEatCounter() > 100 && this.getItemBySlot(EquipmentSlot.MAINHAND).is(ItemTags.PANDA_EATS_FROM_GROUND)) {