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

[SOLVED][1.7.10] question about preventing entity "despawning"


jabelar
 Share

Recommended Posts

I put "despawning" in quotes because I think my problem isn't true despawning as I'll explain below.

 

I have a custom eagle entity which is working quite well -- it can fly up to a soaring height, then soar around high in the air, dive to attack prey, find perches and even be tamed.

 

However, one problem I'm having I can't seem to figure out. I think it has to do with de-spawning.

 

Basically if the eagle is far away it disappears. I believe this is standard de-spawn behavior. I don't want this for two reasons -- due to the eagle already being high up it seems to disappear frequently (I think because the distance is greater due to it being in the air) and also don't want it to despawn when tamed.

 

So I thought it would be as simple as overrideing the canDespawn() method, checking for being tamed and distance and only calling super method if I'm willing to allow despawn.

 

It still seemed to despawn though, so I tried to print console statements in the canDespawn() method but that spammed the console because it is checked every tick. So instead I overrode the setDead() method and just put in a console statement there and found something interesting -- the setDead() was only being called on the client when the entity was disappearing. I thought that was odd, because I expect setting dead would originate on server. It also causes real problems because the server continues to send packets for that entity which now can't be found on the client.

 

Furthermore it was interesting that it was being called at all because I had the canDespawn() returning false.

 

So basically it seems that the setDead() method is being called on the client by something other than the despawn code. Any theories on why the client would setDead() on its own while the server continues to think entity is alive and no despawn check called?

 

To further investigate I overrode the setDead() to not call super method -- i.e never set dead. When that happens, if the eagle is far away it suddenly stops in mid-air, then if I get closer a duplicate appears that is flying where it should be!

 

All this seems to indicate that client is setting dead when the player is at some distance from the player, but server doesn't agree and keeps entity alive.

 

I'm probably missing something fundamental -- but I really thought that simply overriding canDespawn() would be sufficient. I also tried overrideing the AllowDespawn event to give result.DENY but the entity still got set dead.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Link to comment
Share on other sites

You can also call 'func_110163_bv()' in your entity constructor to make it persistent. In 1.8, this is aptly named 'enablePersistence()'.

 

That's interesting, thanks.

 

However my problem actually wasn't despawning. I think despawning is server side deciding to cull unneeded entities based on distance from player and age, etc. However the client also seems to use the tracking range parameter in the entity registration to independently (not through despawn methods) set the entity to dead, just on the client side.

 

In other words, I think the entity is still existing on the server but was just killed on the server. When you get close enough (within tracking range I guess), the client seems to create a new entity to track the one that the server had kept.

 

It kinda makes sense, but was a surprise to me.

 

Basically the trace was like this:

- constructs successfully on both server and client when spawned with egg.

- packets happily sync the entity AI state on the client as long as you stay close

- server checks despawn every tick as evidenced by event and canDespawn() method both being called. client doesn't do any despawn check.

- if you get far (which wasn't that far in my case due to high posY of the entity) the entity is setDead() only on client side, without going through the despawn event or canDespawn() method.

- packet system starts complaining that it can't find the entity I was sending info about.

- when I get close to the (now invisible) entity it re-appears on client.

- if I prevent the client from setting dead, instead of it going invisible it just stops in place, and when I get close it spawns a second entity which acts normally (but original is still "stuck" in place).

- setting the tracking range really large (800000) fixed all this.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Link to comment
Share on other sites

That's called "view distance culling."

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

That's called "view distance culling."

 

Yes, and it also seems to be to reduce network traffic as well since it is also a "tracking" distance. I had previously thought that despawning was used for view distance culling as well, but found that they are separate.

 

I think it is interesting that the client actually kills the entity when it does view distance culling though. I think most video games simply don't render it but would still keep it alive (but suspended). As mentioned the way the client actually kills the entity causes me some grief because the server keeps sending my custom packets assuming it is still there (since the entity is still alive on the server).

 

Oh well, now I know.

 

 

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Mr. diesieben07 und Mr. Luis_ST. Ich danke Ihnen für Ihre Geduld. Erst jetzt habe ich gelernt, dass "Listen Events" als Parameter zurückgegeben werden, also habe ich auch gelernt, dass man Methoden direkt mit Parametern aufrufen kann. Ich stelle den Ereigniscode zur Verfügung, weil es sich um ein geringfügiges Problem handelt und ich ein sehr schlechter Fragesteller wäre, wenn Sie auch für dieses Problem den Ereigniscode selbst durchgehen müssten. Ich verwende derzeit ein Übersetzungsgerät, um mit Ihnen zu kommunizieren, daher werden viele Wörter nicht klar und deutlich zu verstehen sein, und ich entschuldige mich für etwaige Missverständnisse. Ich bin Ihnen beiden dankbar, dass Sie sich trotz Ihres vollen Terminkalenders die Zeit genommen haben, um meine Fragen zu beantworten. Ich gebe Ihnen beiden ein Dankeschön, um meine Dankbarkeit auszudrücken. Ich danke Ihnen nochmals. :):)
    • Whenever I try to start my server I get this crash: [14:05:21] [main/FATAL]: Failed to start the minecraft server com.google.gson.JsonParseException: Error loading registry data: Not a valid resource location: #minecraft:infiniburn_end Non [a-z0-9_.-] character in namespace of location: #minecraft:infiniburn_end         at net.minecraft.core.RegistryAccess.m_175498_(RegistryAccess.java:156) ~[server-1.18.1-20211210.034407-srg.jar%2390!/:?]         at java.util.Optional.ifPresent(Optional.java:178) ~[?:?]         at net.minecraft.core.RegistryAccess.m_175503_(RegistryAccess.java:155) ~[server-1.18.1-20211210.034407-srg.jar%2390!/:?]         at net.minecraft.core.RegistryAccess.m_175500_(RegistryAccess.java:146) ~[server-1.18.1-20211210.034407-srg.jar%2390!/:?]         at net.minecraft.resources.RegistryReadOps.m_195841_(RegistryReadOps.java:37) ~[server-1.18.1-20211210.034407-srg.jar%2390!/:?]         at net.minecraft.resources.RegistryReadOps.m_179866_(RegistryReadOps.java:31) ~[server-1.18.1-20211210.034407-srg.jar%2390!/:?]         at net.minecraft.server.Main.main(Main.java:161) ~[server-1.18.1-20211210.034407-srg.jar%2390!/:?]         at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]         at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[?:?]         at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]         at java.lang.reflect.Method.invoke(Method.java:568) ~[?:?]         at net.minecraftforge.fml.loading.targets.CommonServerLaunchHandler.lambda$launchService$0(CommonServerLaunchHandler.java:46) ~[fmlloader-1.18.1-39.0.75.jar%2361!/:?]         at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37) ~[modlauncher-9.1.0.jar%2343!/:?]         at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:53) ~[modlauncher-9.1.0.jar%2343!/:?]         at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:71) ~[modlauncher-9.1.0.jar%2343!/:?]         at cpw.mods.modlauncher.Launcher.run(Launcher.java:106) ~[modlauncher-9.1.0.jar%2343!/:?]         at cpw.mods.modlauncher.Launcher.main(Launcher.java:77) ~[modlauncher-9.1.0.jar%2343!/:?]         at cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:26) ~[modlauncher-9.1.0.jar%2343!/:?]         at cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:23) ~[modlauncher-9.1.0.jar%2343!/:?]         at cpw.mods.bootstraplauncher.BootstrapLauncher.main(BootstrapLauncher.java:149) ~[bootstraplauncher-1.0.0.jar:?]         at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]         at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[?:?]         at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]         at java.lang.reflect.Method.invoke(Method.java:568) ~[?:?]         at org.jmt.mcmt.modlauncher.FastUtilTransformerService.argumentValues(FastUtilTransformerService.java:200) ~[jmt_mcmt-1.18.1-0.24.2-118-packaged.jar%2375!/:?]         at cpw.mods.modlauncher.TransformationServicesHandler.lambda$offerArgumentResultsToServices$5(TransformationServicesHandler.java:80) ~[modlauncher-9.1.0.jar%235!/:?]         at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183) ~[?:?]         at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197) ~[?:?]         at java.util.HashMap$ValueSpliterator.forEachRemaining(HashMap.java:1779) ~[?:?]         at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509) ~[?:?]         at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499) ~[?:?]         at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150) ~[?:?]         at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173) ~[?:?]         at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[?:?]         at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596) ~[?:?]         at cpw.mods.modlauncher.TransformationServicesHandler.offerArgumentResultsToServices(TransformationServicesHandler.java:80) ~[modlauncher-9.1.0.jar%235!/:?]         at cpw.mods.modlauncher.ArgumentHandler.processArguments(ArgumentHandler.java:71) [modlauncher-9.1.0.jar%235!/:?]         at cpw.mods.modlauncher.TransformationServicesHandler.processArguments(TransformationServicesHandler.java:68) [modlauncher-9.1.0.jar%235!/:?]         at cpw.mods.modlauncher.TransformationServicesHandler.initializeTransformationServices(TransformationServicesHandler.java:50) [modlauncher-9.1.0.jar%235!/:?]         at cpw.mods.modlauncher.Launcher.run(Launcher.java:87) [modlauncher-9.1.0.jar%235!/:?]         at cpw.mods.modlauncher.Launcher.main(Launcher.java:77) [modlauncher-9.1.0.jar%235!/:?]         at cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:26) [modlauncher-9.1.0.jar%235!/:?]         at cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:23) [modlauncher-9.1.0.jar%235!/:?]         at cpw.mods.bootstraplauncher.BootstrapLauncher.main(BootstrapLauncher.java:149) [bootstraplauncher-1.0.0.jar:?] container@pterodactyl~ Server marked as offline... [Game2 Daemon]: ---------- Detected server process in a crashed state! ---------- [Game2 Daemon]: Exit code: 1 [Game2 Daemon]: Out of memory: false [Game2 Daemon]: Aborting automatic restart, last crash occurred less than 120 seconds ago.
    • why, you have Event instance so call the getters we all have the code of the Event the Event exist to perform an action at a specific 'time'/'action' in the game what are you talking about
    • I am sorry, but I have zero idea what you are trying to say.
  • Topics

×
×
  • Create New...

Important Information

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