mojira.dev
MC-161692

Hopper creating a furnace blockentity by transferring an item crashes the game

Loading a chunk with a hopper and a furnace will crash the game if the hopper transfers an item into the furnace under rare circumstances.

If the furnace blockentity doesn't exist for some reason, the hopper's getBlockEntity call will create the missing blockentity and add it to the pending blockentity list (as currently iterating over blockentities). As the world field is only initialized later, the hopper accessing the world field of the furnace causes a null pointer exception.

The defect seems to be that the world field of a block entity may not be initialized, even though it is accessible to things that happen in the world. There are probably more bugs related to the world field not being initialized and being used without a nullcheck. A simple nullcheck in the furnace code is likely not enough, as other blockentities (e.g. beacons playing their sound when broken) might be affected by this (not limited to hopper interactions) as well.

Suggested fix: Make sure that all newly created blockentities have their world field initialized when/before becoming accessible to the rest of the world. I suggest doing this always at the same time as setting their blockPos field.

 

Edit: I attached a worlddownload with a region file that demonstrates this crash. (Furnace block without blockentity accessed by a hopper that tries to transfer an item)

Note: Updated worlddownload to an equivalent world that was created with vanilla server and client only.

Crash report

19w38b: crash-2019-09-23_16.29.14-server.txt

Description: Ticking block entity

java.lang.NullPointerException: Ticking block entity
	at bve.h(SourceFile:359)
	at bve.a(SourceFile:434)
	at bwd.a(SourceFile:310)
	at bwd.a(SourceFile:274)
	at bwd.t(SourceFile:180)
	at bwd.a(SourceFile:122)
	at bwd.Y_(SourceFile:109)
	at bjc.K(SourceFile:597)
	at wq.a(SourceFile:407)
	at net.minecraft.server.MinecraftServer.b(SourceFile:843)
	at net.minecraft.server.MinecraftServer.a(SourceFile:782)
	at ebv.a(SourceFile:128)
	at net.minecraft.server.MinecraftServer.run(SourceFile:650)
	at java.lang.Thread.run(Thread.java:748)

Attachments

Comments 2

confirmed in 19w40a

confirmed for 1.13

does not occur in 1.12.2 with the given furnace + hopper setup

This means the 1.13 furnace rewrite makes this bug surface, even though the furnace rewrite is not the source of the bug

 

2No2Name

boq

Confirmed

Very Important

Crash

19w38b, 19w40a

19w41a

Retrieved