Jump to content

Recommended Posts

Posted

I am trying to get into forge modding, and I have a semi functional mod. it is based off mcJTY's youtube tutorials, and i am trying to implement a generator that consumes diamonds. However, whenever I try to access the GUI, the game crashes with the following messages in the server crash folder.

(here is my source code) I believe the problem is in src.main.java.com.Uebbels.MyFirstMod.blocks.FirstBlock.onBlockActivated()

 

---- Minecraft Crash Report ----
// There are four lights!

Time: 5/18/20 9:12 PM
Description: Ticking entity

java.lang.NullPointerException: Ticking entity
	at com.Uebbels.MyFirstMod.blocks.FirstBlockContainer.getEnergy(FirstBlockContainer.java:60) ~[?:?] {re:classloading}
	at com.Uebbels.MyFirstMod.blocks.FirstBlockContainer$1.get(FirstBlockContainer.java:48) ~[?:?] {re:classloading}
	at net.minecraft.util.IntReferenceHolder.isDirty(IntReferenceHolder.java:49) ~[?:?] {re:classloading}
	at net.minecraft.inventory.container.Container.detectAndSendChanges(Container.java:144) ~[?:?] {re:classloading}
	at net.minecraft.entity.player.ServerPlayerEntity.tick(ServerPlayerEntity.java:335) ~[?:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.world.server.ServerWorld.updateEntity(ServerWorld.java:615) ~[?:?] {re:classloading}
	at net.minecraft.world.World.guardEntityTick(World.java:586) ~[?:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.world.server.ServerWorld.tick(ServerWorld.java:404) ~[?:?] {re:classloading}
	at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:886) ~[?:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:821) ~[?:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:120) ~[?:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:662) [?:?] {re:classloading,pl:accesstransformer:B}
	at java.lang.Thread.run(Thread.java:748) [?:1.8.0_251] {}


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

-- Head --
Thread: Server thread
Stacktrace:
	at com.Uebbels.MyFirstMod.blocks.FirstBlockContainer.getEnergy(FirstBlockContainer.java:60)
	at com.Uebbels.MyFirstMod.blocks.FirstBlockContainer$1.get(FirstBlockContainer.java:48)
	at net.minecraft.util.IntReferenceHolder.isDirty(IntReferenceHolder.java:49)
	at net.minecraft.inventory.container.Container.detectAndSendChanges(Container.java:144)
	at net.minecraft.entity.player.ServerPlayerEntity.tick(ServerPlayerEntity.java:335)
	at net.minecraft.world.server.ServerWorld.updateEntity(ServerWorld.java:615)

-- Entity being ticked --
Details:
	Entity Type: minecraft:player (net.minecraft.entity.player.ServerPlayerEntity)
	Entity ID: 169
	Entity Name: Dev
	Entity's Exact location: -250.01, 88.00, 216.26
	Entity's Block location: World: (-251,88,216), Chunk: (at 5,5,8 in -16,13; contains blocks -256,0,208 to -241,255,223), Region: (-1,0; contains chunks -32,0 to -1,31, blocks -512,0,0 to -1,255,511)
	Entity's Momentum: 0.00, -0.08, 0.00
	Entity's Passengers: []
	Entity's Vehicle: ~~ERROR~~ NullPointerException: null
Stacktrace:
	at net.minecraft.world.World.guardEntityTick(World.java:586)
	at net.minecraft.world.server.ServerWorld.tick(ServerWorld.java:404)

-- Affected level --
Details:
	All players: 1 total; [ServerPlayerEntity['Dev'/169, l='New World', x=-250.01, y=88.00, z=216.26]]
	Chunk stats: ServerChunkCache: 2209
	Level dimension: DimensionType{minecraft:overworld}
	Level name: New World
	Level seed: -2928448136515668876
	Level generator: ID 00 - default, ver 1. Features enabled: true
	Level generator options: {}
	Level spawn location: World: (-256,82,208), Chunk: (at 0,5,0 in -16,13; contains blocks -256,0,208 to -241,255,223), Region: (-1,0; contains chunks -32,0 to -1,31, blocks -512,0,0 to -1,255,511)
	Level time: 24081 game time, 24081 day time
	Known server brands: forge
	Level was modded: true
	Level storage version: 0x04ABD - Anvil
	Level weather: Rain time: 174 (now: false), thunder time: 121248 (now: false)
	Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: true
Stacktrace:
	at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:886)
	at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:821)
	at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:120)
	at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:662)
	at java.lang.Thread.run(Thread.java:748)

-- System Details --
Details:
	Minecraft Version: 1.15.2
	Minecraft Version ID: 1.15.2
	Operating System: Windows 10 (amd64) version 10.0
	Java Version: 1.8.0_251, Oracle Corporation
	Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
	Memory: 1043184952 bytes (994 MB) / 3592421376 bytes (3426 MB) up to 7624720384 bytes (7271 MB)
	CPUs: 12
	JVM Flags: 1 total; -XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump
	ModLauncher: 5.1.0+69+master.79f13f7
	ModLauncher launch target: fmluserdevclient
	ModLauncher naming: mcp
	ModLauncher services: 
		/eventbus-2.2.0-service.jar eventbus PLUGINSERVICE 
		/forge-1.15.2-31.2.0_mapped_snapshot_20200514-1.15.1-launcher.jar object_holder_definalize PLUGINSERVICE 
		/forge-1.15.2-31.2.0_mapped_snapshot_20200514-1.15.1-launcher.jar runtime_enum_extender PLUGINSERVICE 
		/accesstransformers-2.1.1-shadowed.jar accesstransformer PLUGINSERVICE 
		/forge-1.15.2-31.2.0_mapped_snapshot_20200514-1.15.1-launcher.jar capability_inject_definalize PLUGINSERVICE 
		/forge-1.15.2-31.2.0_mapped_snapshot_20200514-1.15.1-launcher.jar runtimedistcleaner PLUGINSERVICE 
		/forge-1.15.2-31.2.0_mapped_snapshot_20200514-1.15.1-launcher.jar fml TRANSFORMATIONSERVICE 
	FML: 31.2
	Forge: net.minecraftforge:31.2.0
	FML Language Providers: 
		[email protected]
		minecraft@1
	Mod List: 
		client-extra.jar Minecraft {[email protected] DONE}
		forge-1.15.2-31.2.0_mapped_snapshot_20200514-1.15.1-recomp.jar Forge {[email protected] DONE}
		main My First Mod {myfirstmod@NONE DONE}
	Player Count: 1 / 8; [ServerPlayerEntity['Dev'/169, l='New World', x=-250.01, y=88.00, z=216.26]]
	Data Packs: vanilla, mod:forge (incompatible), mod:myfirstmod
	Type: Integrated Server (map_client.txt)
	Is Modded: Definitely; Client brand changed to 'forge'

 

Posted
21 minutes ago, Uebbels said:

java.lang.NullPointerException: Ticking entity at com.Uebbels.MyFirstMod.blocks.FirstBlockContainer.getEnergy(FirstBlockContainer.java:60) ~[?:?] {re:classloading}

You know it tells you your error. Your tile entity is throwing a null value on the server at a specific line in a specific class. I think you should write your get method for the reference holder correctly.

Quote

@Override

public Container createMenu(int i, PlayerInventory playerInventory, PlayerEntity playerEntity) {

     return new FirstBlockContainer(i, world, pos, playerInventory, playerEntity);

}

You also realize this is completely redundant. Why are you getting the current tile entity in the container from the world rather than passing in the tile entity? These two should tell you exactly how to solve your problem.

  • Thanks 1
Posted

So the crash occurs when get() is called for the IntRefrenceHolder, which calls getEnergy(). So getEnergy() produces null when called on the server. My knowledge of server versus client side is pretty limited, what in getEnergy() cannot occur on the server?

 

As for createMenu(), what about it is redundant? My understanding is that it is to make sure that the Container created is of type FIrstBlockContainer, instead of just Container. And i could pass through the TE in the constructor, but wouldn't that just mean I need 

TileEntity tileEntity = world.getTileEntity(pos);

in createMenu rather than the constructor? would that make a difference?

 

(I'm pretty new to java as well, sorry if i am misunderstanding this)

Posted

Actually, the problem I described is wrong, so apologies. I missed a single line of code. First, the actual problem is that your global variable of your tile entity is not initialized since you decided to make a local variable in your constructor instead (lines 28 and 34).

 

For your method, my understanding is that you should not mix methods outside the realm of the reference holder with the variables inside. You can, but it might lead to a problem later on when dealing with some client server syncing. I'm not sure, but I just tend to avoid it.

 

Second, calling that method inside your tileentity class is just redundant when you are already literally in your instance of a tileentity. You can literally pass in your tileentity by simply using 'this' instead of passing in two variables you only use once.

  • Thanks 1

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.