Summary:
When used on a campfire block, /item replace
says "Target position (x,y,z) is not a container" and does nothing
Steps to reproduce:
/setblock ~ ~ ~ campfire
/item replace block ~ ~ ~ container.0 with porkchop
Observed results:
Error.
Expected results:
Porkchop is placed on campfire, just like if you right-clicked on it.
Linked issues
Comments 5
Campfires are not containers as stated in the error, is this not expected behavior?
Looking at the code, the four items within a campfire are stored in a list and not an inventory like the player, or a tile entity for example.
private final NonNullList<ItemStack> items = NonNullList.withSize(4, ItemStack.EMPTY);
Looking at modifyBlockItem in ItemCommands.java, there is a check to see if the target is a container or not, and it throws the error you got if it is not.
private static int modifyBlockItem(CommandSourceStack sourceStack, BlockPos pos, int i, LootItemFunction lootItemFunction) throws CommandSyntaxException {
Container container = getContainer(sourceStack, pos, *ERROR_TARGET_NOT_A_CONTAINER*);
if (i >= 0 && i < container.getContainerSize()) {
ItemStack itemstack = applyModifier(sourceStack, lootItemFunction, container.getItem(i));
container.setItem(i, itemstack);
sourceStack.sendSuccess(() -> {
return Component.translatable("commands.item.block.set.success", pos.getX(), pos.getY(), pos.getZ(), itemstack.getDisplayName());
}, true);
return 1;
} else {
throw ERROR_TARGET_INAPPLICABLE_SLOT.create(i);
}
}
/item can change item frames, jukeboxes, lecterns, etc. none of which have an inventory, just an item contained, campfires fall in the same category.
All those blocks (and item frames) not being able to be modified with /item were valid reports.
Current state of code is not a reason for WAI, or everything would be WAI.
Confirmed!