Jump to content

[1.7.2] Custom Entity Error on Dimension Loading


delpi

Recommended Posts

I have create a fair number of custom entities without any errors or oddities popping up, except for this last one.

 

I created a CopyCat mob.  Basically it will pretend to be any player that has been on the server before.  It has their skin, gear, and displays their name. 

 

Everything works fine, but I get an error on minecraft whenever this mob's dimensions is unloaded and then reloaded.  The error states the entity is in an unexpected spot 0,0,0.

 

It doesn't crash the game or stop the mob from spawning, but I can't confirm whether it destroys instances of the mob that existed before unload or not.  Its a rare spawn and I just haven't witnessed it yet.

 

The differences in the code from my others mobs are that it extends entitymob instead of something line entitycreper and I added a datawatcher. 

 

Is there something that needs to be added like telling the mob to despawn or such? 

 

I'll be happy to post the code, but I dont' know what to post because I don't think the error is in what I have.  I think it is in what I don't have.  All that is there is the stuff to make the skin and gear initiate and the datwatcher.  The rest of the class is just empty as its using the stuff extended from entitymob.

 

 

Long time Bukkit & Forge Programmer

Happy to try and help

Link to comment
Share on other sites

I tried again tonight to combat this by modifying some of my setup code and strip it down.  Still getting the error.  It doesn't seem to crash the server or cause anything, but I don't like that much error spam. 

 

Anyone got an idea?

Long time Bukkit & Forge Programmer

Happy to try and help

Link to comment
Share on other sites

what happens when the entity is written/read from nbt?It should store its location but if you've messed that up somehow that'd explain why it thinks it is at 0, 0, 0

We need code and logs.

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Consider supporting the team on Patreon

Link to comment
Share on other sites

I'll dig some up.  That is what I was looking for was what part to grab. 

 

 

In grabbing the code, I think I see it.  Got trigger happy with the copy paste.  I'll delete the write from this and i bet it fixes it.

 

 

 

 

    @Override

    public void readFromNBT(NBTTagCompound tag) {

    //System.out.println("Reading from NBT Data");

   

    // Attempt to read custom NBT

    try {

   

    skin(tag.getString("name"));

   

    } catch(Exception e) {

   

    }

   

    // Call Parent

    super.writeToNBT(tag);

   

    // Call Parent

    super.readEntityFromNBT(tag);

   

    }   

 

 

 

 

 

Long time Bukkit & Forge Programmer

Happy to try and help

Link to comment
Share on other sites

I'll dig some up.  That is what I was looking for was what part to grab. 

 

 

In grabbing the code, I think I see it.  Got trigger happy with the copy paste.  I'll delete the write from this and i bet it fixes it.

 

 

 

 

    @Override

    public void readFromNBT(NBTTagCompound tag) {

    //System.out.println("Reading from NBT Data");

   

    // Attempt to read custom NBT

    try {

   

    skin(tag.getString("name"));

   

    } catch(Exception e) {

   

    }

   

    // Call Parent

    super.writeToNBT(tag);

   

    // Call Parent

    super.readEntityFromNBT(tag);

   

    }   

 

 

 

 

 

    	// Call Parent
    	super.writeToNBT(tag);
    	
    	// Call Parent
    	super.readEntityFromNBT(tag);

 

so, I see 2 problems here: in your readFromNBT method, you call super.writeToNBT and readEntityFromNBT. The first writes the position to the NBT, which in this state is still 0,0,0. Also readEntityFromNBT doesn't read the position AFAIK, and if it does, it would read the 0,0,0 you've wrote in your previous call.

 

I suggest not to override readFromNBT/writeToNBT methods in entities but rather use the readEntityFromNBT/writeEntityToNBT, an the first call in this method is the super call to the same method.

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

Link to comment
Share on other sites

Wow, I really messed that up.  Changing it per your suggestions and fixes.  Thank you, I've been looking at this for days and only seeing what I thought should be there.

 

A little history on it was that I started out with the read/write entity methods but changed in effort to get the name to the client.  I eventually used a datawatcher instead but never changed this back.

 

A couple questions:

  • Why the entity method verses the base one?  Had some experiences with it or does it not call get consistently?
  • In a setup like this, how could putting the super at beginning or end mess it up other than if I used the same variables in there?  But then that would mess up something either way.

 

 

This looks better?

 

 

 

 

    @Override

    public void writeEntityToNBT(NBTTagCompound tag) {

    //System.out.println("Writing to NBT Data");

   

    // Call Parent

    super.writeEntityToNBT(tag);   

   

    // Attempt to input custom NBT

    try {

   

    tag.setString("name", skin);

   

    } catch(Exception e) {

   

    }

           

    }

   

    @Override

    public void readEntityFromNBT(NBTTagCompound tag) {

    //System.out.println("Reading from NBT Data");

   

    // Call Parent

    super.readEntityFromNBT(tag);

   

    // Attempt to read custom NBT

    try {

   

    skin(tag.getString("name"));

   

    } catch(Exception e) {

   

    }   

   

    }

 

 

 

Long time Bukkit & Forge Programmer

Happy to try and help

Link to comment
Share on other sites

A couple questions:

  • Why the entity method verses the base one?  Had some experiences with it or does it not call get consistently?
  • In a setup like this, how could putting the super at beginning or end mess it up other than if I used the same variables in there?  But then that would mess up something either way.

 

 

This looks better?

 

 

 

 

    @Override

    public void writeEntityToNBT(NBTTagCompound tag) {

    //System.out.println("Writing to NBT Data");

   

    // Call Parent

    super.writeEntityToNBT(tag);   

   

    // Attempt to input custom NBT

    try {

   

    tag.setString("name", skin);

   

    } catch(Exception e) {

   

    }

           

    }

   

    @Override

    public void readEntityFromNBT(NBTTagCompound tag) {

    //System.out.println("Reading from NBT Data");

   

    // Call Parent

    super.readEntityFromNBT(tag);

   

    // Attempt to read custom NBT

    try {

   

    skin(tag.getString("name"));

   

    } catch(Exception e) {

   

    }   

   

    }

 

 

 

 

  • Just convenience, also every (at least AFAIK) vanilla entity only overrides the entity one. It doesn't mess anything up if you use the other one. Just make sure on both you call the super method.
  • Just more readable and convenience. You can put it anywhere in the method, but make sure it gets called every time.

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Ok, so my friend has been trying to enter my minecraft modded server but he keeps getting these errors: Internal Exception: java.lang.StringIndexOutOfBoundsException: offset 108, count 101, length 141 and Internal exception: net.minecraft.class_151: Non [a-z0-9/._-] Character in path of location: minecraft:daf\uFFFD\uFFFD\uFFFD\uFFFD\\U\uFFFD\u00115\u0011\uFFFDzK\uFFFDQo, \uFFFD\uFFFD)\uFFFd\uFFFD( Logs: https://mclo.gs/AQjtPE8
    • I figured out that the issues was due to using the wrong version of https://www.curseforge.com/minecraft/mc-mods/werewolves-become-a-beast  thank you Ughar for telling me that I sent the logs wrong, I will keep that in mind for next time I experience an issue
    • can someone help me out I'm trying to figure out why I cannot mind nothing with a pickaxe I tried every type of pickaxe and i'm still not get any material on mine a block plz help ps and i add Load My F***ing Tags and still nothing  
    • Hi! This is my first time creating a mod in Minecraft. It will be for personal use, and the goal is to play creepy/scary music at night. I want it to play without overlapping with Minecraft music (C418, etc.). I have almost finished it, but I don't know how to detect if Minecraft music is playing. I tried accessing a "currentMusic" variable in the MusicManager class via reflection, but it doesn't work.   Class<?> musicManagerClass = musicManager.getClass(); java.lang.reflect.Field currentMusicField = musicManagerClass.getDeclaredField("currentMusic"); currentMusicField.setAccessible(true); currentMusic = (SoundInstance) currentMusicField.get(musicManager); Does anyone know how to do it?
    • Please I need help if anyone can I will leave the log below         [15jun2024 18:11:44.134] [main/INFO] [cpw.mods.modlauncher.Launcher/MODLAUNCHER]: ModLauncher running: args [--username, {MINECRAFT_USERNAME}, --version, 1.16.5, --gameDir, C:\Users\{COMPUTER_USERNAME}\AppData\Roaming\com.modrinth.theseus\profiles\xD, --assetsDir, C:\Users\{COMPUTER_USERNAME}\AppData\Roaming\com.modrinth.theseus\meta\assets, --assetIndex, 1.16, --uuid, {MINECRAFT_UUID}, --accessToken, ????????, --userType, msa, --versionType, release, --width, 854, --height, 480, --launchTarget, fmlclient, --fml.forgeVersion, 36.2.39, --fml.mcVersion, 1.16.5, --fml.forgeGroup, net.minecraftforge, --fml.mcpVersion, 20210115.111550] [15jun2024 18:11:44.136] [main/INFO] [cpw.mods.modlauncher.Launcher/MODLAUNCHER]: ModLauncher 8.1.3+8.1.3+main-8.1.x.c94d18ec starting: java version 1.8.0_412 by Azul Systems, Inc. [15jun2024 18:11:44.525] [main/INFO] [net.minecraftforge.fml.loading.FixSSL/CORE]: Added Lets Encrypt root certificates as additional trust [15jun2024 18:11:44.574] [main/INFO] [mixin/]: SpongePowered MIXIN Subsystem Version=0.8.4 Source=file:/C:/Users/{COMPUTER_USERNAME}/AppData/Roaming/com.modrinth.theseus/meta/libraries/org/spongepowered/mixin/0.8.4/mixin-0.8.4.jar Service=ModLauncher Env=CLIENT [15jun2024 18:11:46.205] [main/INFO] [cpw.mods.modlauncher.LaunchServiceHandler/MODLAUNCHER]: Launching target 'fmlclient' with arguments [--version, 1.16.5, --gameDir, C:\Users\{COMPUTER_USERNAME}\AppData\Roaming\com.modrinth.theseus\profiles\xD, --assetsDir, C:\Users\{COMPUTER_USERNAME}\AppData\Roaming\com.modrinth.theseus\meta\assets, --uuid, {MINECRAFT_UUID}, --username, {MINECRAFT_USERNAME}, --assetIndex, 1.16, --accessToken, ????????, --userType, msa, --versionType, release, --width, 854, --height, 480] [15jun2024 18:11:46.676] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException [15jun2024 18:11:46.677] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]:     at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:39) [15jun2024 18:11:46.677] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]:     at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:54) [15jun2024 18:11:46.677] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]:     at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:72) [15jun2024 18:11:46.677] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]:     at cpw.mods.modlauncher.Launcher.run(Launcher.java:82) [15jun2024 18:11:46.678] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]:     at cpw.mods.modlauncher.Launcher.main(Launcher.java:66) [15jun2024 18:11:46.678] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1061]: Caused by: java.lang.reflect.InvocationTargetException [15jun2024 18:11:46.678] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1061]:     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [15jun2024 18:11:46.678] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1061]:     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) [15jun2024 18:11:46.678] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1061]:     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [15jun2024 18:11:46.679] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1061]:     at java.lang.reflect.Method.invoke(Method.java:498) [15jun2024 18:11:46.679] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1061]:     at net.minecraftforge.fml.loading.FMLClientLaunchProvider.lambda$launchService$0(FMLClientLaunchProvider.java:37) [15jun2024 18:11:46.679] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1061]:     at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37) [15jun2024 18:11:46.679] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1061]:     ... 4 more [15jun2024 18:11:46.679] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:644]: Caused by: java.lang.NoSuchMethodError: org.apache.logging.log4j.core.impl.ThrowableProxy.formatExtendedStackTraceTo(Ljava/lang/StringBuilder;Ljava/util/List;Lorg/apache/logging/log4j/core/pattern/TextRenderer;Ljava/lang/String;Ljava/lang/String;)V [15jun2024 18:11:46.680] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:644]:     at cpw.mods.modlauncher.log.TransformingThrowablePatternConverter.generateEnhancedStackTrace(TransformingThrowablePatternConverter.java:87) [15jun2024 18:11:46.680] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:644]:     at net.minecraftforge.fml.CrashReportExtender.generateEnhancedStackTrace(CrashReportExtender.java:65) [15jun2024 18:11:46.680] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:644]:     at net.minecraftforge.fml.CrashReportExtender.generateEnhancedStackTrace(CrashReportExtender.java:55) [15jun2024 18:11:46.680] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:644]:     at net.minecraft.crash.CrashReport.func_71498_d(CrashReport.java:119) [15jun2024 18:11:46.680] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:644]:     at net.minecraft.crash.CrashReport.func_71502_e(CrashReport.java:135) [15jun2024 18:11:46.681] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:644]:     at net.minecraft.crash.CrashReport.func_230188_h_(CrashReport.java:248) [15jun2024 18:11:46.681] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:644]:     at net.minecraft.client.main.Main.main(Main.java:122) [15jun2024 18:11:46.681] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:644]:     ... 10 more    
  • Topics

×
×
  • Create New...

Important Information

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