Update as of 15w51a: Double chests are still affected. Also, hoppers, when opened by a spectator, generate their own loot and the loot of containers above themselves. However this does not happen when the hopper is above a container or when a HopperMinecart is used.
If you open a chest with a loot table as a spectator, it will generate it's contents affecting gameplay for other survival/adventure players on the map.
Somebody with bad luck or luck effects that open a chest will have better/worse chance of getting good items from chests. A spectator could open all chests and make their contents fixed/unchangeable.
What should happen: A chest that has a loot table with a unspecified lootTableSeed should show a question mark in the chest and NOT generate the items. If the chest has fixed seed or fixed items inside that won't matter.
OR: a gamerule the allows spectators to generate loot in chests and other storage when opened.
Summarized:
Spectators influence loot table chests
Fix: Chests with loot table and random lootTableSeed will not generate items when opened by spectator
Alternate fix: /gamerule spectatorsGenerateLoot true/false. This will make spectators not generate any loot when they open chests/furnaces etc.
Code analysis by @unknown can be found in this comment.
Linked issues
relates to 2
Comments 10
Confirmed for
15w51b
Not fixed for:
Double chests
Hoppers: They generate their own loot and the loot of containers above themselves. However this does not happen when the hopper is above a container or when a HopperMinecart is used.
Please reopen
Reopened, am I understanding you right that hoppers generate their own loot and that of containers above only when opened by a spectator, but not completely on their own?
Yes you understood that with hoppers correctly. The only container which seems to be still affected is the double chest (also trapped version), there the loot is not created when the chests combine but only when the chest is opened
Please link to this comment in the description
The following is based on a decompiled version of Minecraft 1.9 using MCP 9.24 beta.
The reason for this is that the class net.minecraft.inventory.InventoryLargeChest
is not implementing the interface net.minecraft.world.storage.loot.ILootContainer
.
Note: The method net.minecraft.world.storage.loot.ILootContainer.getLootTable()
should be replaced with a method like boolean hasLootTable()
or such a method should be added and called by the methods net.minecraft.entity.player.EntityPlayerMP.displayGui(IInteractionObject)
and net.minecraft.entity.player.EntityPlayerMP.displayGUIChest(IInventory)
. Else there might be problems because a double chest can only return the loot table of one of the chests.
Confirmed for 15w50a.