Jump to content

Recommended Posts

Posted (edited)

Ok so I am trying to get the mobs around the player. However I cant do that because the entity is Ticking. I have solved many of these problems in the past, however I dont know how to solve this one.

	public void playerTick(PlayerTickEvent event)
	{
		entities = event.player.getEntityWorld().getEntitiesWithinAABBExcludingEntity(event.player, event.player.getCollisionBoundingBox().expand(5.0D, 5.0D, 5.0D));
		for(Entity entity : entities){

 

Edited by SecondAmendment
Posted

"Ticking entity" is just a generic message used for any crash report that happens when an entity is being ticked. It doesn't say anything about what caused the crash report.

 

If your code is crashing, post the crash report (or read it yourself and figure out why it's happening).

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted (edited)
[11:31:16] [Server thread/ERROR] [FML]: Exception caught during firing event net.minecraftforge.fml.common.gameevent.TickEvent$PlayerTickEvent@1618ea3f:
java.lang.NullPointerException
	at com.vivabenfica4ps3.gmail.DungeonRealmsMod.playerTick(DungeonRealmsMod.java:63) ~[DungeonRealmsMod.class:?]
	at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_6_DungeonRealmsMod_playerTick_PlayerTickEvent.invoke(.dynamic) ~[?:?]
	at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90) ~[ASMEventHandler.class:?]
	at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:185) [EventBus.class:?]
	at net.minecraftforge.fml.common.FMLCommonHandler.onPlayerPreTick(FMLCommonHandler.java:360) [FMLCommonHandler.class:?]
	at net.minecraft.entity.player.EntityPlayer.onUpdate(EntityPlayer.java:215) [EntityPlayer.class:?]
	at net.minecraft.entity.player.EntityPlayerMP.onUpdateEntity(EntityPlayerMP.java:341) [EntityPlayerMP.class:?]
	at net.minecraft.network.NetHandlerPlayServer.update(NetHandlerPlayServer.java:174) [NetHandlerPlayServer.class:?]
	at net.minecraftforge.fml.common.network.handshake.NetworkDispatcher$1.update(NetworkDispatcher.java:216) [NetworkDispatcher$1.class:?]
	at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:308) [NetworkManager.class:?]
	at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:195) [NetworkSystem.class:?]
	at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:806) [MinecraftServer.class:?]
	at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:687) [MinecraftServer.class:?]
	at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:156) [IntegratedServer.class:?]
	at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:536) [MinecraftServer.class:?]
	at java.lang.Thread.run(Unknown Source) [?:1.8.0_65]
[11:31:16] [Server thread/ERROR] [FML]: Index: 1 Listeners:
[11:31:16] [Server thread/ERROR] [FML]: 0: NORMAL
[11:31:16] [Server thread/ERROR] [FML]: 1: ASM: com.vivabenfica4ps3.gmail.DungeonRealmsMod@158774d3 playerTick(Lnet/minecraftforge/fml/common/gameevent/TickEvent$PlayerTickEvent;)V
[11:31:16] [Server thread/ERROR]: Encountered an unexpected exception
net.minecraft.util.ReportedException: Ticking player
	at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:210) ~[NetworkSystem.class:?]
	at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:806) ~[MinecraftServer.class:?]
	at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:687) ~[MinecraftServer.class:?]
	at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:156) ~[IntegratedServer.class:?]
	at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:536) [MinecraftServer.class:?]
	at java.lang.Thread.run(Unknown Source) [?:1.8.0_65]
Caused by: java.lang.NullPointerException
	at com.vivabenfica4ps3.gmail.DungeonRealmsMod.playerTick(DungeonRealmsMod.java:63) ~[DungeonRealmsMod.class:?]
	at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_6_DungeonRealmsMod_playerTick_PlayerTickEvent.invoke(.dynamic) ~[?:?]
	at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90) ~[ASMEventHandler.class:?]
	at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:185) ~[EventBus.class:?]
	at net.minecraftforge.fml.common.FMLCommonHandler.onPlayerPreTick(FMLCommonHandler.java:360) ~[FMLCommonHandler.class:?]
	at net.minecraft.entity.player.EntityPlayer.onUpdate(EntityPlayer.java:215) ~[EntityPlayer.class:?]
	at net.minecraft.entity.player.EntityPlayerMP.onUpdateEntity(EntityPlayerMP.java:341) ~[EntityPlayerMP.class:?]
	at net.minecraft.network.NetHandlerPlayServer.update(NetHandlerPlayServer.java:174) ~[NetHandlerPlayServer.class:?]
	at net.minecraftforge.fml.common.network.handshake.NetworkDispatcher$1.update(NetworkDispatcher.java:216) ~[NetworkDispatcher$1.class:?]
	at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:308) ~[NetworkManager.class:?]
	at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:195) ~[NetworkSystem.class:?]
	... 5 more
[11:31:16] [Server thread/ERROR]: This crash report has been saved to: D:\DRMod\run\.\crash-reports\crash-2017-02-18_11.31.16-server.txt
[11:31:16] [Server thread/INFO]: Stopping server
[11:31:16] [Server thread/INFO]: Saving players
[11:31:16] [Client thread/INFO] [STDOUT]: [net.minecraft.init.Bootstrap:printToSYSOUT:649]: ---- Minecraft Crash Report ----
// Surprise! Haha. Well, this is awkward.

Time: 2/18/17 11:31 AM
Description: Ticking player

java.lang.NullPointerException: Ticking player
	at com.vivabenfica4ps3.gmail.DungeonRealmsMod.playerTick(DungeonRealmsMod.java:63)
	at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_6_DungeonRealmsMod_playerTick_PlayerTickEvent.invoke(.dynamic)
	at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90)
	at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:185)
	at net.minecraftforge.fml.common.FMLCommonHandler.onPlayerPreTick(FMLCommonHandler.java:360)
	at net.minecraft.entity.player.EntityPlayer.onUpdate(EntityPlayer.java:215)
	at net.minecraft.entity.player.EntityPlayerMP.onUpdateEntity(EntityPlayerMP.java:341)
	at net.minecraft.network.NetHandlerPlayServer.update(NetHandlerPlayServer.java:174)
	at net.minecraftforge.fml.common.network.handshake.NetworkDispatcher$1.update(NetworkDispatcher.java:216)
	at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:308)
	at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:195)
	at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:806)
	at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:687)
	at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:156)
	at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:536)
	at java.lang.Thread.run(Unknown Source)


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

-- Head --
Thread: Client thread
Stacktrace:
	at com.vivabenfica4ps3.gmail.DungeonRealmsMod.playerTick(DungeonRealmsMod.java:63)
	at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_6_DungeonRealmsMod_playerTick_PlayerTickEvent.invoke(.dynamic)
	at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90)
	at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:185)
	at net.minecraftforge.fml.common.FMLCommonHandler.onPlayerPreTick(FMLCommonHandler.java:360)
	at net.minecraft.entity.player.EntityPlayer.onUpdate(EntityPlayer.java:215)

-- Player being ticked --
Details:
	Entity Type: null (net.minecraft.entity.player.EntityPlayerMP)
	Entity ID: 135
	Entity Name: Player287
	Entity's Exact location: 54.27, 83.00, 77.70
	Entity's Block location: World: (54,83,77), Chunk: (at 6,5,13 in 3,4; contains blocks 48,0,64 to 63,255,79), Region: (0,0; contains chunks 0,0 to 31,31, blocks 0,0,0 to 511,255,511)
	Entity's Momentum: 0.00, -0.08, 0.00
	Entity's Passengers: []
	Entity's Vehicle: ~~ERROR~~ NullPointerException: null
Stacktrace:
	at net.minecraft.entity.player.EntityPlayerMP.onUpdateEntity(EntityPlayerMP.java:341)
	at net.minecraft.network.NetHandlerPlayServer.update(NetHandlerPlayServer.java:174)
	at net.minecraftforge.fml.common.network.handshake.NetworkDispatcher$1.update(NetworkDispatcher.java:216)
	at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:308)

-- Ticking connection --
Details:
	Connection: net.minecraft.network.NetworkManager@bf0b82a
Stacktrace:
	at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:195)
	at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:806)
	at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:687)
	at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:156)
	at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:536)
	at java.lang.Thread.run(Unknown Source)

This is the crash report/stacktrace

 

The crash occurs right after I join a world.

 

Here is the whole area where it occurs:

	@SideOnly(Side.CLIENT)
	@SubscribeEvent
	public void playerTick(PlayerTickEvent event)
	{
		entities = event.player.getEntityWorld().getEntitiesWithinAABBExcludingEntity(event.player, event.player.getCollisionBoundingBox().expand(5.0D, 5.0D, 5.0D));
		for(Entity entity : entities){
			event.player.addChatMessage(((EntityLivingBase) entity).getHeldItemMainhand().getTextComponent());
		}
}

 

The variable entities is defined  earlier as follows: 

	List<Entity> entities;

 

Edited by SecondAmendment
Posted (edited)
9 minutes ago, diesieben07 said:
  • Why is entities a field and not a local variable?
  • I assume you are still on a version before 1.11.x, in which case ItemStacks can still be null, which means getHeldItemMainhand will return null if the entity is not holding an item. You then try to call getTextComponent on null.

I know, I still have to add a check for a null getItemMainHand but I already tried commenting that out and the problem still occured on the line where it states: 

player.getEntityWorld().getEntitiesWithinAABBExcludingEntity(event.player, event.player.getCollisionBoundingBox().expand(5.0D, 5.0D, 5.0D));

as for the entities field not being a local variable 

I changed it: 

	@SideOnly(Side.CLIENT)
	@SubscribeEvent
	public void playerTick(PlayerTickEvent event)
	{
		List<Entity> entities = event.player.getEntityWorld().getEntitiesWithinAABBExcludingEntity(event.player, event.player.getCollisionBoundingBox().expand(5.0D, 5.0D, 5.0D));
		for(Entity entity : entities){
			event.player.addChatMessage(((EntityLivingBase) entity).getHeldItemMainhand().getTextComponent());
		}
			if(event.player.getLastAttacker() != null && !event.player.getLastAttacker().equals(previousentity) && (event.player.getLastAttacker().getHeldItemMainhand() != null)){
				event.player.addChatMessage(event.player.getLastAttacker().getHeldItemMainhand().getTextComponent());
				previousentity = (Entity) event.player.getLastAttacker();
		}
	}

Problem still occurs. Same line

 

I just didn't have the variable locally because I might want to use it for later in some other method.

Edited by SecondAmendment
  • 3 years later...
Posted
4 minutes ago, Hamilegit said:

I am also having a problem like this but with a player

 

https://pastebin.com/T85CPPFM

 

wont let me insert the url

This thread is over 3 years old, and very likely not the same as your issue.

You should make your own thread, posting complete logs.

  • Guest locked this topic
Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

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