Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[SOLVED] Crash when placing a block with Tile Entity


Chuck.
 Share

Recommended Posts

Hello everyone,

as the title says everytime I place a block (in this case a crate block) the game crashes with this error:

java.lang.NullPointerException: Registry Object not present: (MOD_ID):crate

 

I'm new to forge modding so I don't really know how to fix that.

Below I posted the code and the crash log

Please help me :(😢 :(

 

SOLUTION:

First of all I deleted the RegistryHandler class, I created an initialization class for each thing to initialize (items, blocks and tile entity types)

In every class I created an init method, this is what I wrote for the TileEntityType class:

//imports

public class InitTileEntityTypes {

	public static final DeferredRegister<TileEntityType<?>> TILE_ENTITY_TYPES = DeferredRegister.create(ForgeRegistries.TILE_ENTITIES, (MAIN_CLASS).MOD_ID);
	
	public static void init() {
		TILE_ENTITY_TYPES.register(FMLJavaModLoadingContext.get().getModEventBus());
	}
	
	//CRATE
	public static final RegistryObject<TileEntityType<CrateTileEntity>> CRATE = TILE_ENTITY_TYPES.register("crate", () -> TileEntityType.Builder.create(CrateTileEntity::new, SIABlocks.CRATE.get()).build(null));
}

Many thanks to diesieben07❤️

Error

[m[1;31m[15:19:32] [Server thread/FATAL] [minecraft/ThreadTaskExecutor]: Error executing task on Server
java.lang.NullPointerException: Registry Object not present: (MOD_ID):crate
	at java.util.Objects.requireNonNull(Objects.java:348) ~[?:?] {}
	at net.minecraftforge.fml.RegistryObject.get(RegistryObject.java:120) ~[?:?] {re:classloading}
	at com.(MOD_FOLDER).blocks.BlockCrate.createTileEntity(BlockCrate.java:76) ~[?:?] {re:classloading}
	at net.minecraftforge.common.extensions.IForgeBlockState.createTileEntity(IForgeBlockState.java:120) ~[?:?] {re:classloading}
	at net.minecraft.world.chunk.Chunk.createNewTileEntity(Chunk.java:377) ~[?:?] {re:classloading}
	at net.minecraft.world.chunk.Chunk.getTileEntity(Chunk.java:404) ~[?:?] {re:classloading}
	at net.minecraft.world.World.getTileEntity(World.java:649) ~[?:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraftforge.common.ForgeHooks.onBlockBreakEvent(ForgeHooks.java:552) ~[?:?] {re:classloading}
	at net.minecraft.server.management.PlayerInteractionManager.tryHarvestBlock(PlayerInteractionManager.java:239) ~[?:?] {re:classloading}
	at net.minecraft.server.management.PlayerInteractionManager.func_229860_a_(PlayerInteractionManager.java:226) ~[?:?] {re:classloading}
	at net.minecraft.server.management.PlayerInteractionManager.func_225416_a(PlayerInteractionManager.java:155) ~[?:?] {re:classloading}
	at net.minecraft.network.play.ServerPlayNetHandler.processPlayerDigging(ServerPlayNetHandler.java:888) ~[?:?] {re:classloading}
	at net.minecraft.network.play.client.CPlayerDiggingPacket.processPacket(CPlayerDiggingPacket.java:50) ~[?:?] {re:classloading}
	at net.minecraft.network.play.client.CPlayerDiggingPacket.processPacket(CPlayerDiggingPacket.java:12) ~[?:?] {re:classloading}
	at net.minecraft.network.PacketThreadUtil.lambda$checkThreadAndEnqueue$0(PacketThreadUtil.java:19) ~[?:?] {re:classloading}
	at net.minecraft.util.concurrent.TickDelayedTask.run(TickDelayedTask.java:20) ~[?:?] {re:classloading}
	at net.minecraft.util.concurrent.ThreadTaskExecutor.run(ThreadTaskExecutor.java:139) ~[?:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.util.concurrent.RecursiveEventLoop.run(RecursiveEventLoop.java:22) ~[?:?] {re:classloading}
	at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:755) ~[?:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:156) ~[?:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.util.concurrent.ThreadTaskExecutor.driveOne(ThreadTaskExecutor.java:109) ~[?:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.server.MinecraftServer.driveOneInternal(MinecraftServer.java:738) ~[?:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.server.MinecraftServer.driveOne(MinecraftServer.java:732) ~[?:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.util.concurrent.ThreadTaskExecutor.drainTasks(ThreadTaskExecutor.java:97) ~[?:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.server.MinecraftServer.runScheduledTasks(MinecraftServer.java:717) ~[?:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.server.MinecraftServer.func_240802_v_(MinecraftServer.java:664) ~[?:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.server.MinecraftServer.lambda$func_240784_a_$0(MinecraftServer.java:230) ~[?:?] {re:classloading,pl:accesstransformer:B}
	at java.lang.Thread.run(Thread.java:832) [?:?] {}

 

Edited by Chuck.
Link to comment
Share on other sites

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
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.

 Share



×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.