Shulker Box Tooltip [Fabric/Forge/NeoForge]

Shulker Box Tooltip [Fabric/Forge/NeoForge]

7M Downloads

Crash with [1.15 - 1.15.2] ShulkerBoxTooltip-1.4.4+1.15.0

AppDevMichael opened this issue ยท 6 comments

commented

The game crashes when I hover over a shulker box that contains a number of enchanted books that are in one stack.

I get the following report,

// Don't do that.

Time: 27/01/20 19:50
Description: Rendering screen

java.lang.ArrayIndexOutOfBoundsException: 27
	at java.util.Arrays$ArrayList.set(Arrays.java:3846)
	at net.minecraft.class_2371.set(class_2371.java:53)
	at com.misterpemodder.shulkerboxtooltip.api.provider.BlockEntityPreviewProvider.getInventory(BlockEntityPreviewProvider.java:72)
	at com.misterpemodder.shulkerboxtooltip.api.provider.BlockEntityPreviewProvider.addTooltip(BlockEntityPreviewProvider.java:104)
	at com.misterpemodder.shulkerboxtooltip.impl.ShulkerBoxTooltip.modifyStackTooltip(ShulkerBoxTooltip.java:203)
	at net.minecraft.class_1799.handler$zzo000$onGetTooltip(class_1799.java:1582)
	at net.minecraft.class_1799.method_7950(class_1799.java:734)
	at net.minecraft.class_437.getTooltipFromItem(class_437.java:120)
	at net.minecraft.class_437.renderTooltip(class_437.java:116)
	at net.minecraft.class_465.method_2380(class_465.java:170)
	at net.minecraft.class_476.render(class_476.java:29)
	at net.minecraft.class_757.method_3192(class_757.java:604)
	at net.minecraft.class_310.method_1523(class_310.java:989)
	at net.minecraft.class_310.method_1514(class_310.java:619)
	at net.minecraft.client.main.Main.main(Main.java:204)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:497)
	at net.fabricmc.loader.game.MinecraftGameProvider.launch(MinecraftGameProvider.java:193)
	at net.fabricmc.loader.launch.knot.Knot.init(Knot.java:138)
	at net.fabricmc.loader.launch.knot.KnotClient.main(KnotClient.java:26)


A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------

-- Head --
Thread: Render thread
Stacktrace:
	at java.util.Arrays$ArrayList.set(Arrays.java:3846)
	at net.minecraft.class_2371.set(class_2371.java:53)
	at com.misterpemodder.shulkerboxtooltip.api.provider.BlockEntityPreviewProvider.getInventory(BlockEntityPreviewProvider.java:72)
	at com.misterpemodder.shulkerboxtooltip.api.provider.BlockEntityPreviewProvider.addTooltip(BlockEntityPreviewProvider.java:104)
	at com.misterpemodder.shulkerboxtooltip.impl.ShulkerBoxTooltip.modifyStackTooltip(ShulkerBoxTooltip.java:203)
	at net.minecraft.class_1799.handler$zzo000$onGetTooltip(class_1799.java:1582)
	at net.minecraft.class_1799.method_7950(class_1799.java:734)
	at net.minecraft.class_437.getTooltipFromItem(class_437.java:120)
	at net.minecraft.class_437.renderTooltip(class_437.java:116)
	at net.minecraft.class_465.method_2380(class_465.java:170)
	at net.minecraft.class_476.render(class_476.java:29)

-- Screen render details --
Details:
	Screen name: net.minecraft.class_476
	Mouse location: Scaled: (488, 338). Absolute: (976.000000, 676.000000)
	Screen size: Scaled: (960, 540). Absolute: (1920, 1080). Scale factor of 2.000000

-- Affected level --
Details:
	All players: 2 total; [class_746['TrollyBashGuy'/127765, l='MpServer', x=269.65, y=1.00, z=2.29], class_745['BeachArcade'/23803, l='MpServer', x=272.51, y=1.00, z=0.45]]
	Chunk stats: Client Chunk Cache: 625, 399
	Level dimension: minecraft:the_end
	Level name: MpServer
	Level seed: 4639921003229686852
	Level generator: ID 00 - default, ver 1. Features enabled: false
	Level generator options: {}
	Level spawn location: World: (-5417,11,-501), Chunk: (at 7,0,11 in -339,-32; contains blocks -5424,0,-512 to -5409,255,-497), Region: (-11,-1; contains chunks -352,-32 to -321,-1, blocks -5632,0,-512 to -5121,255,-1)
	Level time: 126878 game time, 67165604 day time
	Known server brands: 
	Level was modded: false
	Level storage version: 0x00000 - Unknown?
	Level weather: Rain time: 0 (now: false), thunder time: 0 (now: false)
	Level game mode: Game mode: survival (ID 0). Hardcore: false. Cheats: false
	Server brand: Paper
	Server type: Non-integrated multiplayer server
Stacktrace:
	at net.minecraft.class_638.method_8538(class_638.java:450)
	at net.minecraft.class_310.method_1587(class_310.java:1921)
	at net.minecraft.class_310.method_1514(class_310.java:634)
	at net.minecraft.client.main.Main.main(Main.java:204)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:497)
	at net.fabricmc.loader.game.MinecraftGameProvider.launch(MinecraftGameProvider.java:193)
	at net.fabricmc.loader.launch.knot.Knot.init(Knot.java:138)
	at net.fabricmc.loader.launch.knot.KnotClient.main(KnotClient.java:26)
commented

Can you tell me what was the exact contents of the box?
I think the crash is caused by an invalid NBT tag that the mod doesn't check.

commented
{id: "minecraft:purple_shulker_box", Count: 1b, tag: {BlockEntityTag: {Items: [{Slot: 0b, id: "minecraft:bell", Count: 4b}, {Slot: 1b, id: "minecraft:oak_log", Count: 3b}, {Slot: 2b, id: "minecraft:chest", Count: 57b}, {Slot: 3b, id: "minecraft:enchanting_table", Count: 2b}, {Slot: 4b, id: "minecraft:stonecutter", Count: 31b}, {Slot: 5b, id: "minecraft:crafting_table", Count: 16b}, {Slot: 6b, id: "minecraft:diamond_hoe", Count: 1b, tag: {Damage: 231}}, {Slot: 7b, id: "minecraft:anvil", Count: 64b}, {Slot: 8b, id: "minecraft:ender_pearl", Count: 10b}, {Slot: 9b, id: "minecraft:coal", Count: 44b}, {Slot: 10b, id: "minecraft:enchanted_book", Count: 19b, tag: {StoredEnchantments: [{lvl: 1s, id: "minecraft:mending"}]}}]}}}
commented

I only crash when in survival.

Edit: I now know that you crash in all gamemodes when the shulker is mined in survival. Weird...

commented

Ok, I fixed it, the problem is that breaking a shulker box in survival checks for invalid stacked items.
If it finds a stack that exceeds the stack limit, it splits the stack without checking the inventory size limit In this case, the stack of 19 enchanted books creates two books that in the slots 27 and 28, but the last slot is 26.

commented
commented

When mined in survival the shulkers data is this,

{id: "minecraft:purple_shulker_box", Count: 1b, tag: {BlockEntityTag: {Items: [{Slot: 0b, id: "minecraft:bell", Count: 4b}, {Slot: 1b, id: "minecraft:oak_log", Count: 3b}, {Slot: 2b, id: "minecraft:chest", Count: 57b}, {Slot: 3b, id: "minecraft:enchanting_table", Count: 2b}, {Slot: 4b, id: "minecraft:stonecutter", Count: 31b}, {Slot: 5b, id: "minecraft:crafting_table", Count: 16b}, {Slot: 6b, id: "minecraft:diamond_hoe", Count: 1b, tag: {Damage: 231}}, {Slot: 7b, id: "minecraft:anvil", Count: 64b}, {Slot: 8b, id: "minecraft:ender_pearl", Count: 10b}, {Slot: 9b, id: "minecraft:coal", Count: 44b}, {Slot: 10b, id: "minecraft:enchanted_book", Count: 1b, tag: {StoredEnchantments: [{lvl: 1s, id: "minecraft:mending"}]}}, {Slot: 11b, id: "minecraft:enchanted_book", Count: 1b, tag: {StoredEnchantments: [{lvl: 1s, id: "minecraft:mending"}]}}, {Slot: 12b, id: "minecraft:enchanted_book", Count: 1b, tag: {StoredEnchantments: [{lvl: 1s, id: "minecraft:mending"}]}}, {Slot: 13b, id: "minecraft:enchanted_book", Count: 1b, tag: {StoredEnchantments: [{lvl: 1s, id: "minecraft:mending"}]}}, {Slot: 14b, id: "minecraft:enchanted_book", Count: 1b, tag: {StoredEnchantments: [{lvl: 1s, id: "minecraft:mending"}]}}, {Slot: 15b, id: "minecraft:enchanted_book", Count: 1b, tag: {StoredEnchantments: [{lvl: 1s, id: "minecraft:mending"}]}}, {Slot: 16b, id: "minecraft:enchanted_book", Count: 1b, tag: {StoredEnchantments: [{lvl: 1s, id: "minecraft:mending"}]}}, {Slot: 17b, id: "minecraft:enchanted_book", Count: 1b, tag: {StoredEnchantments: [{lvl: 1s, id: "minecraft:mending"}]}}, {Slot: 18b, id: "minecraft:enchanted_book", Count: 1b, tag: {StoredEnchantments: [{lvl: 1s, id: "minecraft:mending"}]}}, {Slot: 19b, id: "minecraft:enchanted_book", Count: 1b, tag: {StoredEnchantments: [{lvl: 1s, id: "minecraft:mending"}]}}, {Slot: 20b, id: "minecraft:enchanted_book", Count: 1b, tag: {StoredEnchantments: [{lvl: 1s, id: "minecraft:mending"}]}}, {Slot: 21b, id: "minecraft:enchanted_book", Count: 1b, tag: {StoredEnchantments: [{lvl: 1s, id: "minecraft:mending"}]}}, {Slot: 22b, id: "minecraft:enchanted_book", Count: 1b, tag: {StoredEnchantments: [{lvl: 1s, id: "minecraft:mending"}]}}, {Slot: 23b, id: "minecraft:enchanted_book", Count: 1b, tag: {StoredEnchantments: [{lvl: 1s, id: "minecraft:mending"}]}}, {Slot: 24b, id: "minecraft:enchanted_book", Count: 1b, tag: {StoredEnchantments: [{lvl: 1s, id: "minecraft:mending"}]}}, {Slot: 25b, id: "minecraft:enchanted_book", Count: 1b, tag: {StoredEnchantments: [{lvl: 1s, id: "minecraft:mending"}]}}, {Slot: 26b, id: "minecraft:enchanted_book", Count: 1b, tag: {StoredEnchantments: [{lvl: 1s, id: "minecraft:mending"}]}}, {Slot: 27b, id: "minecraft:enchanted_book", Count: 1b, tag: {StoredEnchantments: [{lvl: 1s, id: "minecraft:mending"}]}}, {Slot: 28b, id: "minecraft:enchanted_book", Count: 1b, tag: {StoredEnchantments: [{lvl: 1s, id: "minecraft:mending"}]}}, {Slot: 29b, id: "minecraft:enchanted_book", Count: 1b, tag: {StoredEnchantments: [{lvl: 1s, id: "minecraft:mending"}]}}, {Slot: 30b, id: "minecraft:enchanted_book", Count: 1b, tag: {StoredEnchantments: [{lvl: 1s, id: "minecraft:mending"}]}}, {Slot: 31b, id: "minecraft:enchanted_book", Count: 1b, tag: {StoredEnchantments: [{lvl: 1s, id: "minecraft:mending"}]}}, {Slot: 32b, id: "minecraft:enchanted_book", Count: 1b, tag: {StoredEnchantments: [{lvl: 1s, id: "minecraft:mending"}]}}, {Slot: 33b, id: "minecraft:enchanted_book", Count: 1b, tag: {StoredEnchantments: [{lvl: 1s, id: "minecraft:mending"}]}}, {Slot: 34b, id: "minecraft:enchanted_book", Count: 1b, tag: {StoredEnchantments: [{lvl: 1s, id: "minecraft:mending"}]}}, {Slot: 35b, id: "minecraft:enchanted_book", Count: 1b, tag: {StoredEnchantments: [{lvl: 1s, id: "minecraft:mending"}]}}, {Slot: 36b, id: "minecraft:enchanted_book", Count: 1b, tag: {StoredEnchantments: [{lvl: 1s, id: "minecraft:mending"}]}}, {Slot: 37b, id: "minecraft:enchanted_book", Count: 1b, tag: {StoredEnchantments: [{lvl: 1s, id: "minecraft:mending"}]}}, {Slot: 38b, id: "minecraft:enchanted_book", Count: 1b, tag: {StoredEnchantments: [{lvl: 1s, id: "minecraft:mending"}]}}, {Slot: 39b, id: "minecraft:enchanted_book", Count: 1b, tag: {StoredEnchantments: [{lvl: 1s, id: "minecraft:mending"}]}}, {Slot: 40b, id: "minecraft:enchanted_book", Count: 1b, tag: {StoredEnchantments: [{lvl: 1s, id: "minecraft:mending"}]}}, {Slot: 41b, id: "minecraft:enchanted_book", Count: 1b, tag: {StoredEnchantments: [{lvl: 1s, id: "minecraft:mending"}]}}, {Slot: 42b, id: "minecraft:enchanted_book", Count: 1b, tag: {StoredEnchantments: [{lvl: 1s, id: "minecraft:mending"}]}}, {Slot: 43b, id: "minecraft:enchanted_book", Count: 1b, tag: {StoredEnchantments: [{lvl: 1s, id: "minecraft:mending"}]}}]}}}