Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

Hello everyone, 

I created an Entity for my Mod. It works fine, but when I create a new registry inside the NewRegistry-Event, summoning the Entity will result in an error. I have this code: 

@GameRegistry.ObjectHolder(WizardItemsMod.MOD_ID)
public static class ENTITY_ENTRIES {
	public static int ID = 0;
	public static EntityEntry FLYING_BROOMSTICK = EntityEntryBuilder.create()
			.entity(EntityFlyingBroomstick.class)
			.tracker(64, 20, true)
			.id("wizarditems:flying_broomstick", ID++)
			.name("flying_broomstick").build();
}
// ...
@SubscribeEvent
public static void registerEntities(RegistryEvent.Register<EntityEntry> event) {
	event.getRegistry().register(ENTITY_ENTRIES.FLYING_BROOMSTICK);
}
@SubscribeEvent
public static void newRegistry(RegistryEvent.NewRegistry event) {
	// when I add the following code, using the Entity will fail
	SPELL_REGISTRY = new RegistryBuilder<Spell>()
			.setName(new ResourceLocation("wizarditems", "magic_spells"))
			.setType(Spell.class)
			.setIDRange(0, SPELLS4REGISTRY.length).create();
}

When I try to summon the Entity using /summon wizarditems:flying_broomstick, I get this error (although the chat displays "Object successfully summoned"): 

Spoiler

 


[Server thread/ERROR] [minecraft/EntityTracker]: "Silently" catching entity tracking error.
net.minecraft.util.ReportedException: Adding entity to track
	at net.minecraft.entity.EntityTracker.track(EntityTracker.java:261) [EntityTracker.class:?]
	at net.minecraftforge.fml.common.registry.EntityRegistry.tryTrackingEntity(EntityRegistry.java:369) [EntityRegistry.class:?]
	at net.minecraft.entity.EntityTracker.track(EntityTracker.java:82) [EntityTracker.class:?]
	at net.minecraft.world.ServerWorldEventHandler.onEntityAdded(ServerWorldEventHandler.java:43) [ServerWorldEventHandler.class:?]
	at net.minecraft.world.World.onEntityAdded(World.java:1326) [World.class:?]
	at net.minecraft.world.WorldServer.onEntityAdded(WorldServer.java:1175) [WorldServer.class:?]
	at net.minecraft.world.World.spawnEntity(World.java:1317) [World.class:?]
	at net.minecraft.world.WorldServer.spawnEntity(WorldServer.java:1121) [WorldServer.class:?]
	at net.minecraft.world.chunk.storage.AnvilChunkLoader.readWorldEntityPos(AnvilChunkLoader.java:606) [AnvilChunkLoader.class:?]
	at net.minecraft.command.server.CommandSummon.execute(CommandSummon.java:109) [CommandSummon.class:?]
	at net.minecraft.command.CommandHandler.tryExecute(CommandHandler.java:126) [CommandHandler.class:?]
	at net.minecraft.command.CommandHandler.executeCommand(CommandHandler.java:98) [CommandHandler.class:?]
	at net.minecraft.network.NetHandlerPlayServer.handleSlashCommand(NetHandlerPlayServer.java:1003) [NetHandlerPlayServer.class:?]
	at net.minecraft.network.NetHandlerPlayServer.processChatMessage(NetHandlerPlayServer.java:979) [NetHandlerPlayServer.class:?]
	at net.minecraft.network.play.client.CPacketChatMessage.processPacket(CPacketChatMessage.java:47) [CPacketChatMessage.class:?]
	at net.minecraft.network.play.client.CPacketChatMessage.processPacket(CPacketChatMessage.java:8) [CPacketChatMessage.class:?]
	at net.minecraft.network.PacketThreadUtil$1.run(PacketThreadUtil.java:21) [PacketThreadUtil$1.class:?]
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_201]
	at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_201]
	at net.minecraft.util.Util.runTask(Util.java:53) [Util.class:?]
	at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:798) [MinecraftServer.class:?]
	at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:743) [MinecraftServer.class:?]
	at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:192) [IntegratedServer.class:?]
	at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:592) [MinecraftServer.class:?]
	at java.lang.Thread.run(Thread.java:748) [?:1.8.0_201]
Caused by: java.lang.NullPointerException
	at net.minecraftforge.fml.common.network.internal.FMLMessage$EntitySpawnMessage.<init>(FMLMessage.java:148) ~[FMLMessage$EntitySpawnMessage.class:?]
	at net.minecraftforge.fml.common.network.internal.FMLNetworkHandler.getEntitySpawningPacket(FMLNetworkHandler.java:134) ~[FMLNetworkHandler.class:?]
	at net.minecraft.entity.EntityTrackerEntry.createSpawnPacket(EntityTrackerEntry.java:523) ~[EntityTrackerEntry.class:?]
	at net.minecraft.entity.EntityTrackerEntry.updatePlayerEntity(EntityTrackerEntry.java:399) ~[EntityTrackerEntry.class:?]
	at net.minecraft.entity.EntityTrackerEntry.updatePlayerEntities(EntityTrackerEntry.java:509) ~[EntityTrackerEntry.class:?]
	at net.minecraft.entity.EntityTracker.track(EntityTracker.java:235) ~[EntityTracker.class:?]
	... 24 more

When I load an existing world containing the entity, the game crashes: 

Spoiler

[Server thread/ERROR] [minecraft/MinecraftServer]: Encountered an unexpected exception
net.minecraft.util.ReportedException: Exception ticking world
	at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:837) ~[MinecraftServer.class:?]
	at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:743) ~[MinecraftServer.class:?]
	at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:192) ~[IntegratedServer.class:?]
	at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:592) [MinecraftServer.class:?]
	at java.lang.Thread.run(Thread.java:748) [?:1.8.0_201]
Caused by: java.lang.NullPointerException
	at net.minecraftforge.fml.common.network.internal.FMLMessage$EntitySpawnMessage.<init>(FMLMessage.java:148) ~[FMLMessage$EntitySpawnMessage.class:?]
	at net.minecraftforge.fml.common.network.internal.FMLNetworkHandler.getEntitySpawningPacket(FMLNetworkHandler.java:134) ~[FMLNetworkHandler.class:?]
	at net.minecraft.entity.EntityTrackerEntry.createSpawnPacket(EntityTrackerEntry.java:523) ~[EntityTrackerEntry.class:?]
	at net.minecraft.entity.EntityTrackerEntry.updatePlayerEntity(EntityTrackerEntry.java:399) ~[EntityTrackerEntry.class:?]
	at net.minecraft.entity.EntityTracker.sendLeashedEntitiesInChunk(EntityTracker.java:401) ~[EntityTracker.class:?]
	at net.minecraft.server.management.PlayerChunkMapEntry.sendToPlayers(PlayerChunkMapEntry.java:166) ~[PlayerChunkMapEntry.class:?]
	at net.minecraft.server.management.PlayerChunkMap.tick(PlayerChunkMap.java:212) ~[PlayerChunkMap.class:?]
	at net.minecraft.world.WorldServer.tick(WorldServer.java:236) ~[WorldServer.class:?]
	at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:831) ~[MinecraftServer.class:?]
	... 4 more

 

As I said, this only happens when I add the code for creating the new registry. Does anyone know why this is happening, because creating a new registry shouldn't affect Entities??? Am I doing anything wrong?

I found out that this could have something to do with the ModContainer and calling Loader.instance().activeModContainer(). 

(Interestingly, I had to add my Mod-ID to every registry name (Blocks, Items, ...) once I added the code for the new registry, because suddenly the domain name wasn't automatically set to my Mod's ID.)

Thanks in advance!

 

49 minutes ago, CubeFlo said:

I found out that this could have something to do with the ModContainer and calling Loader.instance().activeModContainer(). 

Don't use static intializers. instantinate the registry entries in the appropriate registry event.

Edited by V0idWa1k3r

  • Author

Thanks, it should work now. I think I read somewhere it was okay to use static initializers if you added the ObjectHolder-annotation (not only for injecting values). I probably misunderstood this. 

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.