Jump to content

Recommended Posts

Posted

I have a server running my mod, and I've had this crash about three times over several days of playing. The crash completely shuts down the server when it happens. I can't figure out what's causing it or what it means.

 

The full crash report:

Spoiler

---- Minecraft Crash Report ----
// I feel sad now :(

Time: 3/29/17 10:01 PM
Description: Watching Server

java.lang.Error
	at net.minecraft.world.chunk.Chunk.func_177414_a(Chunk.java:904)
	at net.minecraft.world.World.func_175674_a(World.java:2971)
	at net.minecraft.world.World.func_72839_b(World.java:2954)
	at net.minecraft.world.World.func_184144_a(World.java:1356)
	at net.minecraft.entity.Entity.func_70091_d(Entity.java:706)
	at com.jayavery.jjmod.entities.FallingTreeBlock.func_70071_h_(FallingTreeBlock.java:112)
	at net.minecraft.world.World.func_72866_a(World.java:1961)
	at net.minecraft.world.WorldServer.func_72866_a(WorldServer.java:840)
	at net.minecraft.world.World.func_72870_g(World.java:1931)
	at net.minecraft.world.World.func_72939_s(World.java:1747)
	at net.minecraft.world.WorldServer.func_72939_s(WorldServer.java:621)
	at net.minecraft.server.MinecraftServer.func_71190_q(MinecraftServer.java:720)
	at net.minecraft.server.dedicated.DedicatedServer.func_71190_q(DedicatedServer.java:384)
	at net.minecraft.server.MinecraftServer.func_71217_p(MinecraftServer.java:624)
	at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:482)
	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: Server Watchdog
Stacktrace:
	at net.minecraft.world.chunk.Chunk.func_177414_a(Chunk.java:904)
	at net.minecraft.world.World.func_175674_a(World.java:2971)
	at net.minecraft.world.World.func_72839_b(World.java:2954)
	at net.minecraft.world.World.func_184144_a(World.java:1356)
	at net.minecraft.entity.Entity.func_70091_d(Entity.java:706)
	at com.jayavery.jjmod.entities.FallingTreeBlock.func_70071_h_(FallingTreeBlock.java:112)
	at net.minecraft.world.World.func_72866_a(World.java:1961)
	at net.minecraft.world.WorldServer.func_72866_a(WorldServer.java:840)
	at net.minecraft.world.World.func_72870_g(World.java:1931)
	at net.minecraft.world.World.func_72939_s(World.java:1747)
	at net.minecraft.world.WorldServer.func_72939_s(WorldServer.java:621)
	at net.minecraft.server.MinecraftServer.func_71190_q(MinecraftServer.java:720)
	at net.minecraft.server.dedicated.DedicatedServer.func_71190_q(DedicatedServer.java:384)
	at net.minecraft.server.MinecraftServer.func_71217_p(MinecraftServer.java:624)

-- Thread Dump --
Details:
	Threads: "Netty Epoll Server IO #3" Id=36 RUNNABLE (in native)
	at io.netty.channel.epoll.Native.epollWait(Native Method)
	at io.netty.channel.epoll.EpollEventLoop.epollWait(EpollEventLoop.java:194)
	at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:219)
	at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:116)
	at java.lang.Thread.run(Unknown Source)


"Chunk I/O Executor Thread-1" Id=96 WAITING on java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject@5ca7b411
	at sun.misc.Unsafe.park(Native Method)
	-  waiting on java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject@5ca7b411
	at java.util.concurrent.locks.LockSupport.park(Unknown Source)
	at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(Unknown Source)
	at java.util.concurrent.LinkedBlockingQueue.take(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor.getTask(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)


"Netty Epoll Server IO #2" Id=35 RUNNABLE (in native)
	at io.netty.channel.epoll.Native.epollWait(Native Method)
	at io.netty.channel.epoll.EpollEventLoop.epollWait(EpollEventLoop.java:194)
	at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:219)
	at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:116)
	at java.lang.Thread.run(Unknown Source)


"Netty Epoll Server IO #1" Id=34 RUNNABLE (in native)
	at io.netty.channel.epoll.Native.epollWait(Native Method)
	at io.netty.channel.epoll.EpollEventLoop.epollWait(EpollEventLoop.java:194)
	at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:219)
	at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:116)
	at java.lang.Thread.run(Unknown Source)


"File IO Thread" Id=83 TIMED_WAITING
	at java.lang.Thread.sleep(Native Method)
	at net.minecraft.world.storage.ThreadedFileIOBase.func_75736_b(SourceFile:51)
	at net.minecraft.world.storage.ThreadedFileIOBase.run(SourceFile:30)
	at java.lang.Thread.run(Unknown Source)


"Server Watchdog" Id=81 RUNNABLE
	at sun.management.ThreadImpl.dumpThreads0(Native Method)
	at sun.management.ThreadImpl.dumpAllThreads(Unknown Source)
	at net.minecraft.server.dedicated.ServerHangWatchdog.run(ServerHangWatchdog.java:46)
	at java.lang.Thread.run(Unknown Source)


"Netty Epoll Server IO #0" Id=33 RUNNABLE
	at io.netty.channel.epoll.Native.epollWait(Native Method)
	at io.netty.channel.epoll.EpollEventLoop.epollWait(EpollEventLoop.java:194)
	at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:219)
	at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:116)
	at java.lang.Thread.run(Unknown Source)


"Server console handler" Id=27 RUNNABLE (in native)
	at java.io.FileInputStream.readBytes(Native Method)
	at java.io.FileInputStream.read(Unknown Source)
	at java.io.BufferedInputStream.read1(Unknown Source)
	at java.io.BufferedInputStream.read(Unknown Source)
	-  locked java.io.BufferedInputStream@526051f5
	at sun.nio.cs.StreamDecoder.readBytes(Unknown Source)
	at sun.nio.cs.StreamDecoder.implRead(Unknown Source)
	at sun.nio.cs.StreamDecoder.read(Unknown Source)
	-  locked java.io.InputStreamReader@565fdf61
	at java.io.InputStreamReader.read(Unknown Source)
	...


"DestroyJavaVM" Id=26 RUNNABLE


"Server thread" Id=24 RUNNABLE
	at net.minecraft.world.chunk.Chunk.func_177414_a(Chunk.java:904)
	at net.minecraft.world.World.func_175674_a(World.java:2971)
	at net.minecraft.world.World.func_72839_b(World.java:2954)
	at net.minecraft.world.World.func_184144_a(World.java:1356)
	at net.minecraft.entity.Entity.func_70091_d(Entity.java:706)
	at com.jayavery.jjmod.entities.FallingTreeBlock.func_70071_h_(FallingTreeBlock.java:112)
	at net.minecraft.world.World.func_72866_a(World.java:1961)
	at net.minecraft.world.WorldServer.func_72866_a(WorldServer.java:840)
	...


"Server Infinisleeper" Id=23 TIMED_WAITING
	at java.lang.Thread.sleep(Native Method)
	at net.minecraft.server.dedicated.DedicatedServer$1.run(DedicatedServer.java:78)


"Snooper Timer" Id=22 TIMED_WAITING on java.util.TaskQueue@135d5bce
	at java.lang.Object.wait(Native Method)
	-  waiting on java.util.TaskQueue@135d5bce
	at java.util.TimerThread.mainLoop(Unknown Source)
	at java.util.TimerThread.run(Unknown Source)


"Signal Dispatcher" Id=5 RUNNABLE


"Finalizer" Id=3 WAITING on java.lang.ref.ReferenceQueue$Lock@72bb6288
	at java.lang.Object.wait(Native Method)
	-  waiting on java.lang.ref.ReferenceQueue$Lock@72bb6288
	at java.lang.ref.ReferenceQueue.remove(Unknown Source)
	at java.lang.ref.ReferenceQueue.remove(Unknown Source)
	at java.lang.ref.Finalizer$FinalizerThread.run(Unknown Source)


"Reference Handler" Id=2 WAITING on java.lang.ref.Reference$Lock@22046ad3
	at java.lang.Object.wait(Native Method)
	-  waiting on java.lang.ref.Reference$Lock@22046ad3
	at java.lang.Object.wait(Unknown Source)
	at java.lang.ref.Reference.tryHandlePending(Unknown Source)
	at java.lang.ref.Reference$ReferenceHandler.run(Unknown Source)



Stacktrace:
	at net.minecraft.server.dedicated.ServerHangWatchdog.run(ServerHangWatchdog.java:63)
	at java.lang.Thread.run(Unknown Source)

-- System Details --
Details:
	Minecraft Version: 1.11.2
	Operating System: Linux (amd64) version 2.6.32-642.6.2.el6.x86_64
	Java Version: 1.8.0_111, Oracle Corporation
	Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
	Memory: 456719920 bytes (435 MB) / 1037959168 bytes (989 MB) up to 1037959168 bytes (989 MB)
	JVM Flags: 5 total; -Xmx1024M -Xms1024M -XX:+UseConcMarkSweepGC -XX:+CMSClassUnloadingEnabled -XX:MaxMetaspaceSize=256M
	IntCache: cache: 0, tcache: 0, allocated: 12, tallocated: 94
	FML: MCP 9.38 Powered by Forge 13.20.0.2228 5 mods loaded, 5 mods active
	States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored
	UCHIJAAAA	minecraft{1.11.2} [Minecraft] (minecraft.jar) 
	UCHIJAAAA	mcp{9.19} [Minecraft Coder Pack] (minecraft.jar) 
	UCHIJAAAA	FML{8.0.99.99} [Forge Mod Loader] (forge-1.11.2-13.20.0.2228-universal.jar) 
	UCHIJAAAA	forge{13.20.0.2228} [Minecraft Forge] (forge-1.11.2-13.20.0.2228-universal.jar) 
	UCHIJAAAA	jjmod{0.5.1} [JJ Mod] (jjmod-0.5.1-mc1.11.2.jar) 
	Loaded coremods (and transformers): 
	Profiler Position: N/A (disabled)
	Player Count: 1 / 25; [EntityPlayerMP['Viridian77'/4876, l='world6', x=214.32, y=72.00, z=233.34]]
	Is Modded: Definitely; Server brand changed to 'fml,forge'
	Type: Dedicated Server (map_server.txt)

 

I've figured out a deobfuscated version of that stack trace to save the trouble:

java.lang.Error
	at net.minecraft.world.chunk.Chunk.getEntitiesWithinAABBForEntity(Chunk.java:904)
	at net.minecraft.world.World.getEntitiesInAABBexcluding(World.java:2971)
	at net.minecraft.world.World.getEntitiesWithinAABBExcludingEntity(World.java:2954)
	at net.minecraft.world.World.getCollisionBoxes(World.java:1356)
	at net.minecraft.entity.Entity.move(Entity.java:706)
	at com.jayavery.jjmod.entities.FallingTreeBlock.onUpdate(FallingTreeBlock.java:112)
	at net.minecraft.world.World.updateEntityWithOptionalForce(World.java:1961)
	at net.minecraft.world.WorldServer.updateEntityWithOptionalForce(WorldServer.java:840)
	at net.minecraft.world.World.updateEntity(World.java:1931)
	at net.minecraft.world.World.updateEntities(World.java:1747)
	at net.minecraft.world.WorldServer.updateEntities(WorldServer.java:621)
	at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:720)
	at net.minecraft.server.dedicated.DedicatedServer.updateTimeLightAndEntities(DedicatedServer.java:384)
	at net.minecraft.server.MinecraftServer.func_71217_p(MinecraftServer.java:624)
	at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:482)
	at java.lang.Thread.run(Unknown Source)

 

My FallingTreeBlock entity class is on github: https://github.com/JayAvery/jjmod/blob/develop/src/java/com/jayavery/jjmod/entities/FallingTreeBlock.java

 

The crash report seems to be about the most useless crash I've ever seen?? Just 'Error'? I have made some changes to the way collision boxes are calculated for my custom entity, so I'm sure that the problem is something to do with that. But I have no idea how to find out exactly what. The crash is extremely intermittent (it certainly doesn't happen every time my custom entity is spawned or moved). And the stack trace doesn't explicitly refer to any of the places where I've messed with collision boxes - it just happens in the collision box checks of the general Entity#move method.

 

Does anyone have any ideas?

Posted

The things I want to change are aspects of the main methods in EntityFallingBlock. If I extended it, I'd end up with pretty much the same result - I'd have to recreate most of the methods anyway in order to add my tweaks.

Posted

This is a crash induced by ServerHangWatchdog because a tick took longer than the maximum tick time (1 minute by default). You'll probably have to do some profiling to figure out what's taking so long.

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

I have no idea about profiling - do you have any advice on where to begin or learn?

 

But also, wouldn't that suggest it was a general lag issue? There doesn't seem to be significant lag generally, only when this crash happens (things stop responding for a few seconds before the server shuts down, which is presumably while the game is trying to run the tick that ends up taking a minute). So even if I do look at how long things are taking, it might not give me any useful information unless I am watching when the crash happens, which is currently completely unpredictable and very intermittent.

Posted
3 hours ago, Jay Avery said:

I have no idea about profiling - do you have any advice on where to begin or learn?

 

Not really, I don't know much about it myself. I've seen people recommend VisualVM for this sort of thing, you may also be able to use Minecraft's Profiler class.

 

 

3 hours ago, Jay Avery said:

But also, wouldn't that suggest it was a general lag issue? There doesn't seem to be significant lag generally, only when this crash happens (things stop responding for a few seconds before the server shuts down, which is presumably while the game is trying to run the tick that ends up taking a minute). So even if I do look at how long things are taking, it might not give me any useful information unless I am watching when the crash happens, which is currently completely unpredictable and very intermittent.

 

If you enable profiling in Minecraft (/debug start), you may be able to add a shutdown hook (Runtime#addShutdownHook) that saves the profiling output to a file (e.g. by running /debug stop). This would allow you to see what took so long after the server is stopped by the watchdog.

  • Like 1

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
getEntitiesWithinAABBForEntity

 

 Does the error always have the same stack trace? If so, how big is the AABB that that is checked for bounding box collisions during the move?

 

I agree that stepping through this process, even when not in error, could alert you to a potential pitfall. You might also try adding a temporary exception handler so you can break within it and poke at more variables surrounding the error.

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

Posted
4 minutes ago, jeffryfisher said:

getEntitiesWithinAABBForEntity

 

 Does the error always have the same stack trace? If so, how big is the AABB that that is checked for bounding box collisions during the move?

 

I agree that stepping through this process, even when not in error, could alert you to a potential pitfall. You might also try adding a temporary exception handler so you can break within it and poke at more variables surrounding the error.

So far, the crash has happened three times, and it's been the same stack trace each time. The AABB is the same size as a vanilla falling block entity (0.98x0.98), so nothing extreme. And again, if that was the problem - wouldn't the crash (or at least very severe lag) happen any time the entity is spawned or moved?

 

I just tried to step through the method in the debugger but the server shut down because it thought it was crashed. Is there an easy workaround for that?

Posted

Well, I have an update... but it's not good news. :S

 

The crash happened again today, but with a difference. When it crashed, I restarted the server (as I've done previously) but the crash happened again immediately on reconnecting. Repeated this again and the same thing happened again. But then, I tried connecting with a different client (Mac instead of Windows, if that could possibly be relevant??) and the crash didn't happen. Back to the first (Windows) client, and reconnecting triggered the crash again.

 

I didn't know it was even possible for a client to cause a server to crash, but that is definitely what seems to be happening. I thought the whole point of the server-client relationship was that the server is in control and the client is basically just receiving information and presenting it to the player?! :S And I can't think of anything different between the two clients other than the operating system - exact same version of the mod, forge, etc.

 

I used the debug profiling thing and got the following debug report when the server crashed. I don't really know how to interpret anything useful from this but if anyone has insight:

Spoiler

---- Minecraft Profiler Results ----
// Now with the same numbers

Time span: 3496318 ms
Tick span: 68660 ticks
// This is approximately 19.64 ticks per second. It should be 20 ticks per second

--- BEGIN PROFILE DUMP ---

[00] levels - 92.26%/92.26%
[01] |   world - 99.81%/92.08%
[02] |   |   tick - 97.70%/89.96%
[03] |   |   |   entities - 53.91%/48.50%
[04] |   |   |   |   regular - 99.25%/48.14%
[05] |   |   |   |   |   tick - 99.53%/49.18%
[06] |   |   |   |   |   |   travel - 27.06%/13.31%
[07] |   |   |   |   |   |   |   move - 59.32%/7.90%
[07] |   |   |   |   |   |   |   unspecified - 21.13%/2.81%
[07] |   |   |   |   |   |   |   rest - 19.55%/2.60%
[08] |   |   |   |   |   |   |   |   unspecified - 99.92%/2.60%
[08] |   |   |   |   |   |   |   |   checkLight - 0.08%/0.00%
[09] |   |   |   |   |   |   |   |   |   checkedPosition < toCheckCount - 97.59%/0.00%
[09] |   |   |   |   |   |   |   |   |   getBrightness - 1.33%/0.00%
[09] |   |   |   |   |   |   |   |   |   unspecified - 1.09%/0.00%
[06] |   |   |   |   |   |   unspecified - 25.25%/12.42%
[06] |   |   |   |   |   |   ai - 24.78%/12.19%
[07] |   |   |   |   |   |   |   newAi - 94.63%/11.54%
[08] |   |   |   |   |   |   |   |   unspecified - 29.18%/3.37%
[08] |   |   |   |   |   |   |   |   goalSelector - 23.39%/2.70%
[09] |   |   |   |   |   |   |   |   |   goalSetup - 65.89%/1.78%
[10] |   |   |   |   |   |   |   |   |   |   unspecified - 90.96%/1.62%
[10] |   |   |   |   |   |   |   |   |   |   pathfind - 9.04%/0.16%
[11] |   |   |   |   |   |   |   |   |   |   |   unspecified - 87.42%/0.14%
[11] |   |   |   |   |   |   |   |   |   |   |   checkLight - 3.87%/0.01%
[12] |   |   |   |   |   |   |   |   |   |   |   |   checkedPosition < toCheckCount - 69.86%/0.00%
[12] |   |   |   |   |   |   |   |   |   |   |   |   getBrightness - 17.85%/0.00%
[12] |   |   |   |   |   |   |   |   |   |   |   |   unspecified - 12.29%/0.00%
[11] |   |   |   |   |   |   |   |   |   |   |   checkedPosition < toCheckCount - 3.70%/0.01%
[11] |   |   |   |   |   |   |   |   |   |   |   recheckGaps - 3.62%/0.01%
[12] |   |   |   |   |   |   |   |   |   |   |   |   unspecified - 71.41%/0.00%
[12] |   |   |   |   |   |   |   |   |   |   |   |   getBrightness - 23.89%/0.00%
[12] |   |   |   |   |   |   |   |   |   |   |   |   checkedPosition < toCheckCount - 4.70%/0.00%
[11] |   |   |   |   |   |   |   |   |   |   |   getBrightness - 1.40%/0.00%
[09] |   |   |   |   |   |   |   |   |   unspecified - 29.70%/0.80%
[09] |   |   |   |   |   |   |   |   |   goalTick - 4.40%/0.12%
[10] |   |   |   |   |   |   |   |   |   |   unspecified - 95.74%/0.11%
[10] |   |   |   |   |   |   |   |   |   |   pathfind - 4.26%/0.01%
[10] |   |   |   |   |   |   |   |   |   |   checkLight - 0.00%/0.00%
[11] |   |   |   |   |   |   |   |   |   |   |   unspecified - 39.41%/0.00%
[11] |   |   |   |   |   |   |   |   |   |   |   getBrightness - 36.06%/0.00%
[11] |   |   |   |   |   |   |   |   |   |   |   checkedPosition < toCheckCount - 24.52%/0.00%
[10] |   |   |   |   |   |   |   |   |   |   checkedPosition < toCheckCount - 0.00%/0.00%
[10] |   |   |   |   |   |   |   |   |   |   getBrightness - 0.00%/0.00%
[08] |   |   |   |   |   |   |   |   controls - 19.51%/2.25%
[09] |   |   |   |   |   |   |   |   |   unspecified - 63.00%/1.42%
[09] |   |   |   |   |   |   |   |   |   look - 13.67%/0.31%
[09] |   |   |   |   |   |   |   |   |   move - 13.50%/0.30%
[09] |   |   |   |   |   |   |   |   |   jump - 9.83%/0.22%
[08] |   |   |   |   |   |   |   |   targetSelector - 14.74%/1.70%
[09] |   |   |   |   |   |   |   |   |   goalSetup - 57.02%/0.97%
[10] |   |   |   |   |   |   |   |   |   |   unspecified - 92.84%/0.90%
[10] |   |   |   |   |   |   |   |   |   |   canSee - 7.16%/0.07%
[09] |   |   |   |   |   |   |   |   |   unspecified - 42.98%/0.73%
[09] |   |   |   |   |   |   |   |   |   goalTick - 0.00%/0.00%
[08] |   |   |   |   |   |   |   |   navigation - 6.37%/0.73%
[09] |   |   |   |   |   |   |   |   |   unspecified - 99.98%/0.73%
[09] |   |   |   |   |   |   |   |   |   pathfind - 0.02%/0.00%
[08] |   |   |   |   |   |   |   |   checkDespawn - 3.21%/0.37%
[08] |   |   |   |   |   |   |   |   mob tick - 2.20%/0.25%
[09] |   |   |   |   |   |   |   |   |   unspecified - 100.00%/0.25%
[09] |   |   |   |   |   |   |   |   |   chunkCheck - 0.00%/0.00%
[08] |   |   |   |   |   |   |   |   sensing - 1.39%/0.16%
[07] |   |   |   |   |   |   |   unspecified - 5.37%/0.65%
[06] |   |   |   |   |   |   move - 7.78%/3.83%
[06] |   |   |   |   |   |   entityBaseTick - 5.66%/2.78%
[07] |   |   |   |   |   |   |   unspecified - 94.72%/2.64%
[07] |   |   |   |   |   |   |   portal - 5.28%/0.15%
[06] |   |   |   |   |   |   livingEntityBaseTick - 5.01%/2.46%
[06] |   |   |   |   |   |   push - 1.59%/0.78%
[06] |   |   |   |   |   |   rest - 0.65%/0.32%
[06] |   |   |   |   |   |   mobBaseTick - 0.60%/0.29%
[06] |   |   |   |   |   |   headTurn - 0.55%/0.27%
[06] |   |   |   |   |   |   chunkCheck - 0.34%/0.17%
[06] |   |   |   |   |   |   jump - 0.19%/0.10%
[06] |   |   |   |   |   |   rangeChecks - 0.19%/0.09%
[06] |   |   |   |   |   |   looting - 0.16%/0.08%
[06] |   |   |   |   |   |   checkLight - 0.08%/0.04%
[07] |   |   |   |   |   |   |   checkedPosition < toCheckCount - 42.01%/0.02%
[07] |   |   |   |   |   |   |   getBrightness - 35.82%/0.01%
[07] |   |   |   |   |   |   |   unspecified - 22.17%/0.01%
[06] |   |   |   |   |   |   checkedPosition < toCheckCount - 0.06%/0.03%
[06] |   |   |   |   |   |   getBrightness - 0.03%/0.02%
[06] |   |   |   |   |   |   portal - 0.00%/0.00%
[05] |   |   |   |   |   remove - 0.47%/0.23%
[05] |   |   |   |   |   chunkCheck - 0.00%/0.00%
[04] |   |   |   |   players - 0.36%/0.17%
[05] |   |   |   |   |   tick - 90.71%/0.16%
[06] |   |   |   |   |   |   unspecified - 98.34%/0.15%
[06] |   |   |   |   |   |   chunkCheck - 1.65%/0.00%
[06] |   |   |   |   |   |   checkedPosition < toCheckCount - 0.00%/0.00%
[06] |   |   |   |   |   |   getBrightness - 0.00%/0.00%
[06] |   |   |   |   |   |   checkLight - 0.00%/0.00%
[07] |   |   |   |   |   |   |   unspecified - 47.88%/0.00%
[07] |   |   |   |   |   |   |   getBrightness - 34.35%/0.00%
[07] |   |   |   |   |   |   |   checkedPosition < toCheckCount - 17.76%/0.00%
[05] |   |   |   |   |   unspecified - 8.76%/0.02%
[05] |   |   |   |   |   remove - 0.53%/0.00%
[04] |   |   |   |   blockEntities - 0.29%/0.14%
[05] |   |   |   |   |   unspecified - 85.77%/0.12%
[05] |   |   |   |   |   TileEntityMobSpawner - 9.92%/0.01%
[05] |   |   |   |   |   TileEntityChest - 4.16%/0.01%
[05] |   |   |   |   |   TECraftingKnapping - 0.16%/0.00%
[04] |   |   |   |   remove - 0.05%/0.02%
[04] |   |   |   |   unspecified - 0.05%/0.02%
[04] |   |   |   |   global - 0.00%/0.00%
[04] |   |   |   |   pendingBlockEntities - 0.00%/0.00%
[03] |   |   |   tickBlocks - 42.11%/37.89%
[04] |   |   |   |   pollingChunks - 99.72%/37.78%
[05] |   |   |   |   |   tickChunk - 66.77%/25.22%
[06] |   |   |   |   |   |   unspecified - 71.44%/18.02%
[06] |   |   |   |   |   |   getBrightness - 20.64%/5.21%
[06] |   |   |   |   |   |   recheckGaps - 6.42%/1.62%
[07] |   |   |   |   |   |   |   unspecified - 70.39%/1.14%
[07] |   |   |   |   |   |   |   getBrightness - 22.17%/0.36%
[07] |   |   |   |   |   |   |   checkedPosition < toCheckCount - 7.44%/0.12%
[06] |   |   |   |   |   |   checkedPosition < toCheckCount - 1.51%/0.38%
[05] |   |   |   |   |   tickBlocks - 23.26%/8.79%
[06] |   |   |   |   |   |   unspecified - 76.46%/6.72%
[06] |   |   |   |   |   |   randomTick - 23.54%/2.07%
[07] |   |   |   |   |   |   |   unspecified - 99.06%/2.05%
[07] |   |   |   |   |   |   |   checkLight - 0.52%/0.01%
[08] |   |   |   |   |   |   |   |   checkedPosition < toCheckCount - 77.57%/0.01%
[08] |   |   |   |   |   |   |   |   getBrightness - 18.19%/0.00%
[08] |   |   |   |   |   |   |   |   unspecified - 4.24%/0.00%
[07] |   |   |   |   |   |   |   checkedPosition < toCheckCount - 0.35%/0.01%
[07] |   |   |   |   |   |   |   getBrightness - 0.08%/0.00%
[05] |   |   |   |   |   unspecified - 7.59%/2.87%
[05] |   |   |   |   |   regularChunkLoading - 1.07%/0.40%
[05] |   |   |   |   |   iceandsnow - 0.54%/0.20%
[05] |   |   |   |   |   getChunk - 0.32%/0.12%
[05] |   |   |   |   |   thunder - 0.22%/0.08%
[05] |   |   |   |   |   checkNextLight - 0.20%/0.08%
[05] |   |   |   |   |   forcedChunkLoading - 0.03%/0.01%
[04] |   |   |   |   playerCheckLight - 0.20%/0.07%
[05] |   |   |   |   |   getBrightness - 50.77%/0.04%
[05] |   |   |   |   |   unspecified - 47.01%/0.03%
[05] |   |   |   |   |   checkedPosition < toCheckCount - 2.22%/0.00%
[04] |   |   |   |   unspecified - 0.09%/0.03%
[03] |   |   |   chunkMap - 1.93%/1.74%
[04] |   |   |   |   unspecified - 92.59%/1.61%
[04] |   |   |   |   checkedPosition < toCheckCount - 3.34%/0.06%
[04] |   |   |   |   checkLight - 2.59%/0.04%
[05] |   |   |   |   |   checkedPosition < toCheckCount - 61.85%/0.03%
[05] |   |   |   |   |   unspecified - 19.28%/0.01%
[05] |   |   |   |   |   getBrightness - 18.87%/0.01%
[04] |   |   |   |   getBrightness - 1.49%/0.03%
[03] |   |   |   mobSpawner - 1.19%/1.07%
[03] |   |   |   tickPending - 0.48%/0.43%
[04] |   |   |   |   ticking - 88.64%/0.38%
[05] |   |   |   |   |   unspecified - 53.84%/0.20%
[05] |   |   |   |   |   checkLight - 38.79%/0.15%
[06] |   |   |   |   |   |   checkedPosition < toCheckCount - 76.56%/0.11%
[06] |   |   |   |   |   |   getBrightness - 21.60%/0.03%
[06] |   |   |   |   |   |   unspecified - 1.84%/0.00%
[05] |   |   |   |   |   checkedPosition < toCheckCount - 5.50%/0.02%
[05] |   |   |   |   |   getBrightness - 1.86%/0.01%
[05] |   |   |   |   |   pathfind - 0.01%/0.00%
[04] |   |   |   |   unspecified - 6.45%/0.03%
[04] |   |   |   |   cleaning - 4.91%/0.02%
[03] |   |   |   chunkSource - 0.22%/0.20%
[03] |   |   |   unspecified - 0.14%/0.12%
[03] |   |   |   village - 0.01%/0.01%
[03] |   |   |   portalForcer - 0.00%/0.00%
[02] |   |   tracker - 2.25%/2.07%
[02] |   |   unspecified - 0.04%/0.04%
[02] |   |   timeSync - 0.00%/0.00%
[01] |   unspecified - 0.19%/0.17%
[01] |   checkedPosition < toCheckCount - 0.00%/0.00%
[01] |   checkLight - 0.00%/0.00%
[02] |   |   checkedPosition < toCheckCount - 49.20%/0.00%
[02] |   |   unspecified - 27.67%/0.00%
[02] |   |   getBrightness - 23.12%/0.00%
[01] |   getBrightness - 0.00%/0.00%
[01] |   recheckGaps - 0.00%/0.00%
[02] |   |   unspecified - 70.42%/0.00%
[02] |   |   getBrightness - 25.45%/0.00%
[02] |   |   checkedPosition < toCheckCount - 4.14%/0.00%
[00] connection - 6.57%/6.57%
[01] |   unspecified - 97.02%/6.38%
[01] |   travel - 1.76%/0.12%
[02] |   |   move - 45.77%/0.05%
[02] |   |   unspecified - 32.64%/0.04%
[02] |   |   rest - 21.60%/0.02%
[01] |   livingEntityBaseTick - 0.38%/0.02%
[01] |   entityBaseTick - 0.37%/0.02%
[02] |   |   unspecified - 88.05%/0.02%
[02] |   |   portal - 11.95%/0.00%
[01] |   ai - 0.21%/0.01%
[02] |   |   unspecified - 70.45%/0.01%
[02] |   |   newAi - 29.55%/0.00%
[01] |   push - 0.13%/0.01%
[01] |   headTurn - 0.06%/0.00%
[01] |   keepAlive - 0.06%/0.00%
[01] |   rangeChecks - 0.01%/0.00%
[01] |   jump - 0.01%/0.00%
[00] save - 0.92%/0.92%
[00] jobs - 0.18%/0.18%
[01] |   unspecified - 78.84%/0.14%
[01] |   rest - 10.77%/0.02%
[01] |   move - 10.13%/0.02%
[01] |   checkLight - 0.17%/0.00%
[02] |   |   checkedPosition < toCheckCount - 48.43%/0.00%
[02] |   |   getBrightness - 36.08%/0.00%
[02] |   |   unspecified - 15.49%/0.00%
[01] |   getBrightness - 0.05%/0.00%
[01] |   checkedPosition < toCheckCount - 0.04%/0.00%
[01] |   pathfind - 0.01%/0.00%
[00] unspecified - 0.06%/0.06%
[00] dim_unloading - 0.00%/0.00%
[00] players - 0.00%/0.00%
[00] tallying - 0.00%/0.00%
[00] snooper - 0.00%/0.00%
[00] tickables - 0.00%/0.00%
--- END PROFILE DUMP ---

 

 

Posted

If you need help with a crash, find the log file (not console) and post it. If there's a client issue, post its log too. Since the debugger seems to be giving you difficulty, you may need to insert some statements to produce more informative text output.

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Version 1.19 - Forge 41.0.63 I want to create a wolf entity that I can ride, so far it seems to be working, but the problem is that when I get on the wolf, I can’t control it. I then discovered that the issue is that the server doesn’t detect that I’m riding the wolf, so I’m struggling with synchronization. However, it seems to not be working properly. As I understand it, the server receives the packet but doesn’t register it correctly. I’m a bit new to Java, and I’ll try to provide all the relevant code and prints *The comments and prints are translated by chatgpt since they were originally in Spanish* Thank you very much in advance No player is mounted, or the passenger is not a player. No player is mounted, or the passenger is not a player. No player is mounted, or the passenger is not a player. No player is mounted, or the passenger is not a player. No player is mounted, or the passenger is not a player. MountableWolfEntity package com.vals.valscraft.entity; import com.vals.valscraft.network.MountSyncPacket; import com.vals.valscraft.network.NetworkHandler; import net.minecraft.client.Minecraft; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.Mob; import net.minecraft.world.entity.ai.attributes.AttributeSupplier; import net.minecraft.world.entity.ai.attributes.Attributes; import net.minecraft.world.entity.animal.Wolf; import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.Entity; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; import net.minecraft.world.level.Level; import net.minecraft.world.phys.Vec3; import net.minecraftforge.event.TickEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.network.PacketDistributor; public class MountableWolfEntity extends Wolf { private boolean hasSaddle; private static final EntityDataAccessor<Byte> DATA_ID_FLAGS = SynchedEntityData.defineId(MountableWolfEntity.class, EntityDataSerializers.BYTE); public MountableWolfEntity(EntityType<? extends Wolf> type, Level level) { super(type, level); this.hasSaddle = false; } @Override protected void defineSynchedData() { super.defineSynchedData(); this.entityData.define(DATA_ID_FLAGS, (byte)0); } public static AttributeSupplier.Builder createAttributes() { return Wolf.createAttributes() .add(Attributes.MAX_HEALTH, 20.0) .add(Attributes.MOVEMENT_SPEED, 0.3); } @Override public InteractionResult mobInteract(Player player, InteractionHand hand) { ItemStack itemstack = player.getItemInHand(hand); if (itemstack.getItem() == Items.SADDLE && !this.hasSaddle()) { if (!player.isCreative()) { itemstack.shrink(1); } this.setSaddle(true); return InteractionResult.SUCCESS; } else if (!level.isClientSide && this.hasSaddle()) { player.startRiding(this); MountSyncPacket packet = new MountSyncPacket(true); // 'true' means the player is mounted NetworkHandler.CHANNEL.sendToServer(packet); // Ensure the server handles the packet return InteractionResult.SUCCESS; } return InteractionResult.PASS; } @Override public void travel(Vec3 travelVector) { if (this.isVehicle() && this.getControllingPassenger() instanceof Player) { System.out.println("The wolf has a passenger."); System.out.println("The passenger is a player."); Player player = (Player) this.getControllingPassenger(); // Ensure the player is the controller this.setYRot(player.getYRot()); this.yRotO = this.getYRot(); this.setXRot(player.getXRot() * 0.5F); this.setRot(this.getYRot(), this.getXRot()); this.yBodyRot = this.getYRot(); this.yHeadRot = this.yBodyRot; float forward = player.zza; float strafe = player.xxa; if (forward <= 0.0F) { forward *= 0.25F; } this.flyingSpeed = this.getSpeed() * 0.1F; this.setSpeed((float) this.getAttributeValue(Attributes.MOVEMENT_SPEED) * 1.5F); this.setDeltaMovement(new Vec3(strafe, travelVector.y, forward).scale(this.getSpeed())); this.calculateEntityAnimation(this, false); } else { // The wolf does not have a passenger or the passenger is not a player System.out.println("No player is mounted, or the passenger is not a player."); super.travel(travelVector); } } public boolean hasSaddle() { return this.hasSaddle; } public void setSaddle(boolean hasSaddle) { this.hasSaddle = hasSaddle; } @Override protected void dropEquipment() { super.dropEquipment(); if (this.hasSaddle()) { this.spawnAtLocation(Items.SADDLE); this.setSaddle(false); } } @SubscribeEvent public static void onServerTick(TickEvent.ServerTickEvent event) { if (event.phase == TickEvent.Phase.START) { MinecraftServer server = net.minecraftforge.server.ServerLifecycleHooks.getCurrentServer(); if (server != null) { for (ServerPlayer player : server.getPlayerList().getPlayers()) { if (player.isPassenger() && player.getVehicle() instanceof MountableWolfEntity) { MountableWolfEntity wolf = (MountableWolfEntity) player.getVehicle(); System.out.println("Tick: " + player.getName().getString() + " is correctly mounted on " + wolf); } } } } } private boolean lastMountedState = false; @Override public void tick() { super.tick(); if (!this.level.isClientSide) { // Only on the server boolean isMounted = this.isVehicle() && this.getControllingPassenger() instanceof Player; // Only print if the state changed if (isMounted != lastMountedState) { if (isMounted) { Player player = (Player) this.getControllingPassenger(); // Verify the passenger is a player System.out.println("Server: Player " + player.getName().getString() + " is now mounted."); } else { System.out.println("Server: The wolf no longer has a passenger."); } lastMountedState = isMounted; } } } @Override public void addPassenger(Entity passenger) { super.addPassenger(passenger); if (passenger instanceof Player) { Player player = (Player) passenger; if (!this.level.isClientSide && player instanceof ServerPlayer) { // Send the packet to the server to indicate the player is mounted NetworkHandler.CHANNEL.send(PacketDistributor.PLAYER.with(() -> (ServerPlayer) player), new MountSyncPacket(true)); } } } @Override public void removePassenger(Entity passenger) { super.removePassenger(passenger); if (passenger instanceof Player) { Player player = (Player) passenger; if (!this.level.isClientSide && player instanceof ServerPlayer) { // Send the packet to the server to indicate the player is no longer mounted NetworkHandler.CHANNEL.send(PacketDistributor.PLAYER.with(() -> (ServerPlayer) player), new MountSyncPacket(false)); } } } @Override public boolean isControlledByLocalInstance() { Entity entity = this.getControllingPassenger(); return entity instanceof Player; } @Override public void positionRider(Entity passenger) { if (this.hasPassenger(passenger)) { double xOffset = Math.cos(Math.toRadians(this.getYRot() + 90)) * 0.4; double zOffset = Math.sin(Math.toRadians(this.getYRot() + 90)) * 0.4; passenger.setPos(this.getX() + xOffset, this.getY() + this.getPassengersRidingOffset() + passenger.getMyRidingOffset(), this.getZ() + zOffset); } } } MountSyncPacket package com.vals.valscraft.network; import com.vals.valscraft.entity.MountableWolfEntity; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.player.Player; import net.minecraftforge.network.NetworkEvent; import java.util.function.Supplier; public class MountSyncPacket { private final boolean isMounted; public MountSyncPacket(boolean isMounted) { this.isMounted = isMounted; } public void encode(FriendlyByteBuf buffer) { buffer.writeBoolean(isMounted); } public static MountSyncPacket decode(FriendlyByteBuf buffer) { return new MountSyncPacket(buffer.readBoolean()); } public void handle(NetworkEvent.Context context) { context.enqueueWork(() -> { ServerPlayer player = context.getSender(); // Get the player from the context if (player != null) { // Verifies if the player has dismounted if (!isMounted) { Entity vehicle = player.getVehicle(); if (vehicle instanceof MountableWolfEntity wolf) { // Logic to remove the player as a passenger wolf.removePassenger(player); System.out.println("Server: Player " + player.getName().getString() + " is no longer mounted."); } } } }); context.setPacketHandled(true); // Marks the packet as handled } } networkHandler package com.vals.valscraft.network; import com.vals.valscraft.valscraft; import net.minecraft.resources.ResourceLocation; import net.minecraftforge.network.NetworkRegistry; import net.minecraftforge.network.simple.SimpleChannel; import net.minecraftforge.network.NetworkEvent; import java.util.function.Supplier; public class NetworkHandler { private static final String PROTOCOL_VERSION = "1"; public static final SimpleChannel CHANNEL = NetworkRegistry.newSimpleChannel( new ResourceLocation(valscraft.MODID, "main"), () -> PROTOCOL_VERSION, PROTOCOL_VERSION::equals, PROTOCOL_VERSION::equals ); public static void init() { int packetId = 0; // Register the mount synchronization packet CHANNEL.registerMessage( packetId++, MountSyncPacket.class, MountSyncPacket::encode, MountSyncPacket::decode, (msg, context) -> msg.handle(context.get()) // Get the context with context.get() ); } }  
    • Do you use features of inventory profiles next (ipnext) or is there a change without it?
    • Remove rubidium - you are already using embeddium, which is a fork of rubidium
  • Topics

×
×
  • Create New...

Important Information

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