[UnSolved] Custom entity "ticking entity" problem

Discussion in 'Plugin Development' started by Jogy34, Dec 29, 2012.

Thread Status:
Not open for further replies.
  1. Offline

    Jogy34

    I am messing around with creating mobs with custom behaviors and right now all I'm trying to do is to create a villager that looks like a creeper. I have my custom mob class set up as basic as I can get it and I have the network id of the mob set to that of a creeper in my onEnable() method but when I try to spawn it my client crashes saying: "Minecraft has stopped running because it encountered a problem; Ticking entity" and the crash report doesn't give any more information. It even says that there were no suspicious class found. I've gotten it to work with other network id's like the enderdragon, wither, skeleton, giant, and snow golem but it wouldn't work for the creeper, spider, zombie, or slime. (I didn't try every id) Anyone know a way to fix this?

    My current code is:
    int my onEnable()
    Code:
    try
    {
        @SuppressWarnings("rawtypes")
        Class[] args = new Class[3];
        args[0] = Class.class;
        args[1] = String.class;
        args[2] = int.class;
     
        Method a = net.minecraft.server.v1_4_6.EntityTypes.class.getDeclaredMethod("a", args);
        a.setAccessible(true);
        a.invoke(a, CreeperVillager.class, "Villager", 50);
    }
    catch (Exception e)
    {
        e.printStackTrace();
        this.setEnabled(false);
    }
    
    My custom villager class:
    Code:
    public class CreeperVillager extends EntityVillager
    {
        public CreeperVillager (World w)
        {
            super(w);
        }
    }
     
  2. Offline

    fireblast709

    Try loading the plugin before the world
     
  3. Offline

    Jogy34

    What do you mean by that?
     
  4. Offline

    fireblast709

    as loading chunks somewhere got async (not sure if that version was already used and you are using that version) it might be that it is causing errors
     
  5. Offline

    Jogy34

    I'm still not quite sure by what you mean by loading the plugin before the world
     
  6. Offline

    fireblast709

    Like in your plugin.yml:
    Code:
    load: STARTUP
     
  7. Offline

    Jogy34

    Now it's throwing an IndexOutOfBoundsException when my server starts up and then when I try to spawn the entity it says there is an "Exception in world tick" instead of "Ticking entity"

    I think the IndexOutOfBoundsException is because I'm trying to load worlds in my onEnable()
     
  8. Offline

    fireblast709

    Might it be that this error is thrown by another piece of code/another plugin? As there is not very logical if this would throw the error
     
  9. Offline

    Jogy34

    I tried taking all of my plugins out and making a separate plugin just for testing this and I still get the same errors.

    EDIT: maybe Jacek could help
     
  10. Offline

    Jacek

    How are you spawning it ? You need to prevent the game spawning the default version of the mob or it creates an invalid state where two entities have the same ID.
     
  11. Offline

    Jogy34

    I'm using a command to spawn one like this:
    Code:
    Player p = (Player)sender;
    Block b = p.getTargetBlock(null, 5);
    net.minecraft.server.v1_4_6.World w = ((CraftWorld)b.getWorld()).getHandle();
    CreeperVillager cv = new CreeperVillager(w);
    cv.setPosition(b.getX() + .5, b.getY() + 1.5, b.getZ() + .5);
    w.addEntity(cv, SpawnReason.CUSTOM);
     
  12. Offline

    Jacek

    Okay well that looks fine. The issue will probably be that a normal villager is spawning somewhere and the server sends the wrong ID to the client. you can spawn a custom mob without replacing every one on the server just fine so try removing the code from the first block you posted (the EntityTypes list modification) and see if it still happens.
     
  13. Offline

    Jogy34

    I'm guessing that I probably misunderstood what you meant but I commented out the entire try/catch block at the top and it gave me an "exception in world tick" error in my client.
     
  14. Offline

    Jacek

    That is exactly what I meant to do :) It could be that you are not calling the .bG() method (I think this is something like initialiseEntity(), it gets called each time an entity is created). Try doing that just before you set it's position.
     
  15. Offline

    Jogy34

    I still get the same errors I got beforehand
     
  16. Offline

    Jacek

    I'm out of ideas then :(
     
  17. Offline

    Jogy34

    ok, thanks for the help anyways.

    anyone think they know how to fix this?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 30, 2016
  18. Offline

    Jacek

    Someone just reported this issue for BloodMoon too, have a look in the crash-report folder, the one they uploaded had a very helpful stack trace :)
     
  19. Offline

    Jogy34

    Unfortunately I doubt it's the same problem. My problem didn't give a stack trace just a useless client crash text document. Also when I change it from EntityVillager to EntityCreeper and try the creeper id it works fine. Same with a zombie
     
  20. Offline

    fireblast709

    Jogy34 it might be good to post that 'useless' text document anyway, as it holds the stacktrace
     
  21. Offline

    Jogy34

    Sorry I was tired and slightly frustrated with something else when I wrote that but it still isn't much help:
    Code:
    ---- Minecraft Crash Report ----
    // Hey, that tickles! Hehehe!
     
    Time: 12/31/12 12:04 PM
    Description: Ticking entity
     
    java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.Byte
    at mj.a(SourceFile:88)
    at qc.o(SourceFile:150)
    at qc.j_(SourceFile:92)
    at yc.a(SourceFile:1319)
    at yc.g(SourceFile:1297)
    at yc.h(SourceFile:1196)
    at net.minecraft.client.Minecraft.l(SourceFile:1326)
    at net.minecraft.client.Minecraft.J(SourceFile:582)
    at net.minecraft.client.Minecraft.run(SourceFile:534)
    at java.lang.Thread.run(Unknown Source)
     
     
    A detailed walkthrough of the error, its code path and all known details is as follows:
    ---------------------------------------------------------------------------------------
     
    -- Head --
    Stacktrace:
    at mj.a(SourceFile:88)
    at qc.o(SourceFile:150)
    at qc.j_(SourceFile:92)
    at yc.a(SourceFile:1319)
    at yc.g(SourceFile:1297)
     
    -- Entity being ticked --
    Details:
    Entity Type: Creeper (qc)
    Entity ID: 234
    Name: Creeper
    Exact location: -82.50, 92.50, -320.50
    Block location: World: (-83,92,-321), Chunk: (at 13,5,15 in -6,-21; contains blocks -96,0,-336 to -81,255,-321), Region: (-1,-1; contains chunks -32,-32 to -1,-1, blocks -512,0,-512 to -1,255,-1)
    Momentum: 0.00, 0.00, 0.00
    Stacktrace:
    at yc.h(SourceFile:1196)
     
    -- Affected level --
    Details:
    Level name: MpServer
    All players: 1 total; [ays['Jogy34'/233, l='MpServer', x=-82.65, y=95.62, z=-321.94]]
    Chunk stats: MultiplayerChunkCache: 441
    Level seed: 0
    Level generator: ID 00 - default, ver 1. Features enabled: false
    Level generator options: 
    Level spawn location: World: (-36,64,-132), Chunk: (at 12,4,12 in -3,-9; contains blocks -48,0,-144 to -33,255,-129), Region: (-1,-1; contains chunks -32,-32 to -1,-1, blocks -512,0,-512 to -1,255,-1)
    Level time: 4192 game time, 16667 day time
    Level dimension: 0
    Level storage version: 0x00000 - Unknown?
    Level weather: Rain time: 0 (now: false), thunder time: 0 (now: false)
    Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: false
    Forced entities: 2 total; [ays['Jogy34'/233, l='MpServer', x=-82.65, y=95.62, z=-321.94], qc['Creeper'/234, l='MpServer', x=-82.50, y=92.50, z=-320.50]]
    Retry entities: 0 total; []
    Stacktrace:
    at ayp.a(SourceFile:281)
    at net.minecraft.client.Minecraft.b(SourceFile:1871)
    at net.minecraft.client.Minecraft.run(SourceFile:543)
    at java.lang.Thread.run(Unknown Source)
     
    -- System Details --
    Details:
    Minecraft Version: 1.4.6
    Operating System: Windows 7 (amd64) version 6.1
    Java Version: 1.7.0_10, Oracle Corporation
    Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
    Memory: 415119912 bytes (395 MB) / 514523136 bytes (490 MB) up to 954466304 bytes (910 MB)
    JVM Flags: 2 total; -Xms512m -Xmx1024m
    AABB Pool Size: 9635 (539560 bytes; 0 MB) allocated, 16 (896 bytes; 0 MB) used
    Suspicious classes: No suspicious classes found.
    IntCache: cache: 0, tcache: 0, allocated: 3, tallocated: 63
    LWJGL: 2.4.2
    OpenGL: Intel(R) HD Graphics 4000 GL version 3.3.0 - Build 8.15.10.2712, Intel
    Is Modded: Probably not. Jar signature remains and client brand is untouched.
    Type: Client (map_client.txt)
    Texture Pack: Default
    Profiler Position: N/A (disabled)
    Vec3 Pool Size: 3910 (218960 bytes; 0 MB) allocated, 25 (1400 bytes; 0 MB) used
    
     
  22. Offline

    fireblast709

    Code:
    java.lang.Integer cannot be cast to java.lang.Byte
    not helpful :confused:? I think this is rather helpful
     
  23. Offline

    Jogy34

    Nope not helpful
    Code:
    at mj.a(SourceFile:88)
    at qc.o(SourceFile:150)
    at qc.j_(SourceFile:92)
    at yc.a(SourceFile:1319)
    at yc.g(SourceFile:1297)
    at yc.h(SourceFile:1196)
    at net.minecraft.client.Minecraft.l(SourceFile:1326)
    at net.minecraft.client.Minecraft.J(SourceFile:582)
    at net.minecraft.client.Minecraft.run(SourceFile:534)
    at java.lang.Thread.run(Unknown Source)
    As there is nothing I can do about that. The only thing I changed was a single number and I made it bigger by 1 and it worked then one more and I got this same error then bigger by 66 and it worked again. Also that is in the client not the server.
     
  24. Offline

    fireblast709

    What is the full code of CreeperVillager?
     
  25. Offline

    Jogy34

    That was the full code. I have the class declaration that extends EntityVillager and then the constructor that calls the super constructor. It works if I replace the id of a creeper with a skeleton, a villager, ender dragon, wither and a few others but not with a zombie a slime or a few others so I'm guess it has something to do with how the different entities are set up
     
  26. Offline

    fireblast709

    Might it be that NBT data is missing, and it fails to catch this on the render. (or something of the sorts)
     
  27. Offline

    Jogy34

    I don't really know if I could do anything about that as when retrieving the NBT data from the entity only the information is passed not the actual compound and when setting the information it only takes the data for the type of entity it is so in this case it would only take in the needed stuff for a villager even if I passed in the information for a creeper or a zombie.

    Anyone have any other suggestions?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 30, 2016
  28. Offline

    Jogy34

    Anyone? I really want to get this fixed.
     
  29. Offline

    fireblast709

    just for the sake of it, try setting all the NBT tags available (like you did in the spawner code a while ago)
     
  30. Offline

    Jogy34

    I tried that before when you suggested that is might be because of NBTTags. I set all of the creeper fields and even tried creating an EntityCreeper then getting the NBTTag data from that and then setting that to the villager but nothing changed. When retrieving or setting the NBTTagCompound of an Entity there isn't any way to get the actual compound. When retrieving you send in your own compound and this is get's filled with that entity's info and then when setting you send in a compound and then the information specific to that entity is pulled out. So or a villager there isn't any way, to my knowledge, to set the specific fields of another entity.
     
Thread Status:
Not open for further replies.

Share This Page