Jump to content

Register Entity with 1.3.1 forge


SanAndreaP

Recommended Posts

Hello there :)

 

I wanted to use the new "modder" version of forge and play around with it. Everything seems to work, but I have issues with entities: If I use only the method ModLoader.registerEntityID(...) and spawn the entity ingame, I can hear them, but I can't see them. Also I cannot kill them, except they manage to kill themselves (e.g. lava / falling sand). If they die, sometimes I get this error:

 

java.util.ConcurrentModificationException

at java.util.ArrayList$Itr.checkForComodification(Unknown Source)

at java.util.ArrayList$Itr.next(Unknown Source)

at net.minecraft.src.World.getCollidingBoundingBoxes(World.java:1466)

at net.minecraft.src.Entity.moveEntity(Entity.java:657)

at net.minecraft.src.EntityFX.onUpdate(EntityFX.java:114)

at net.minecraft.src.EffectRenderer.updateEffects(EffectRenderer.java:64)

at net.minecraft.client.Minecraft.runTick(Minecraft.java:1688)

at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:731)

at net.minecraft.client.Minecraft.run(Minecraft.java:661)

at java.lang.Thread.run(Unknown Source)

--- END ERROR REPORT 7cb8184b ----------

 

 

So I searched in the forge code and found this method:

EntityRegistry.registerModEntity(CSM_EntityClayMan.class, "CSM_EntityClayMan", 0, this, 64, 1, true);

If I use this method and spawn the entity in a new world, I got an error which says "Disconnected by Server: Internal Server error" with no detailed information. If I try to open that world again, it crashes with following error:

 

 

2012-08-13 01:42:47 [iNFO] [sTDERR] java.lang.ArrayIndexOutOfBoundsException: 2

2012-08-13 01:42:47 [iNFO] [sTDERR] at cpw.mods.fml.common.network.EntitySpawnPacket.generatePacket(EntitySpawnPacket.java:63)

2012-08-13 01:42:47 [iNFO] [sTDERR] at cpw.mods.fml.common.network.FMLPacket.makePacket(FMLPacket.java:79)

2012-08-13 01:42:47 [iNFO] [sTDERR] at cpw.mods.fml.common.network.FMLNetworkHandler.getEntitySpawningPacket(FMLNetworkHandler.java:321)

2012-08-13 01:42:47 [iNFO] [sTDERR] at net.minecraft.src.EntityTrackerEntry.getPacketForThisEntity(EntityTrackerEntry.java:339)

2012-08-13 01:42:47 [iNFO] [sTDERR] at net.minecraft.src.EntityTrackerEntry.tryStartWachingThis(EntityTrackerEntry.java:252)

2012-08-13 01:42:47 [iNFO] [sTDERR] at net.minecraft.src.EntityTracker.processOutstandingEntries(EntityTracker.java:213)

2012-08-13 01:42:47 [iNFO] [sTDERR] at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:623)

2012-08-13 01:42:47 [iNFO] [sTDERR] at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:547)

2012-08-13 01:42:47 [iNFO] [sTDERR] at net.minecraft.src.IntegratedServer.tick(IntegratedServer.java:102)

2012-08-13 01:42:47 [iNFO] [sTDERR] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:453)

2012-08-13 01:42:47 [iNFO] [sTDERR] at net.minecraft.src.ThreadServerApplication.run(ThreadServerApplication.java:17)

 

 

So apparently I'm doing something wrong, but I can't figure out what.

 

This is how my mod_ class looks like now:

 

package net.minecraft.src;

 

import cpw.mods.fml.common.network.NetworkMod;

import cpw.mods.fml.common.registry.EntityRegistry;

 

import net.minecraftforge.client.MinecraftForgeClient;

import net.minecraftforge.common.MinecraftForge;

 

@NetworkMod

public class mod_ClayMan extends BaseMod {

 

public String getVersion() {

        return "1.2.5 v.7.9";

    }

 

  /* some items here */

 

    public static String modName = "ClaySoldierMod";

    public static final String textureFile = "/claymans/CSMItems.png";

   

  /*some item IDs here */

   

    private static void setIDs() {

    SAP_ConfigManager cfg = new SAP_ConfigManager("Clay Soldiers Mod", "1.1");

   

    cfg.setVar_IN_A(itemNames, itemIDs, cfg.getGroupIdFromName("Item IDs"));

   

    cfg.loadConfig();

   

    itemIDs = cfg.getVar_IN_A(itemNames);

    }

 

    public mod_ClayMan() {

 

    }

 

@Override

public void load() {

 

setIDs();

 

ModLoader.setInGameHook(this, true, true);

MinecraftForgeClient.preloadTexture(textureFile);

 

/* some item initializations */

 

ModLoader.registerEntityID(CSM_EntityClayMan.class, "CSM_ClaySoldier", ModLoader.getUniqueEntityId());

EntityRegistry.registerModEntity(CSM_EntityClayMan.class, "CSM_ClaySoldierMP", 0, this, 64, 1, true);

 

/* some more of that above for other entities */

 

/* some recipes */

}

 

@Override

public boolean onTickInGame(float f, Minecraft game) {

/* moar code */

}

 

 

@Override

    public void addRenderer(Map map) {

        map.put(CSM_EntityClayMan.class, new CSM_RenderClayMan(new CSM_ModelClayMan(0F, 13F), 0.125F));

/*some more of that above for other entities */

    }

 

@Override

public boolean dispenseEntity(World world, double x, double y, double z, int xVel, int zVel, ItemStack item) {

/*some dispensing stuff */

}

}

 

 

 

BTW: all the entities are basically extending EntityCreature.

 

 

I hope you can help me with that. Thanks in advance.

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

I use both, but it doesn't work either :/

 

It's the same error I get as when I use only EntityRegistry.registerModEntity.

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

Sorry for DP, but I searched in the code again for a solution, rewrote my mod_ file to the new Forge system and stuff. I found out that I have to implement IAnimals now for my entities. I did that and somehow the entity is now registered. But as soon as I load a world with my entities or try to spawn them, I get this two errors together:

 

2012-08-14 11:32:39 [iNFO] [sTDERR] java.lang.NullPointerException
2012-08-14 11:32:39 [iNFO] [sTDERR] 	at net.minecraft.src.Render.loadDownloadableImageTexture(Render.java:39)
2012-08-14 11:32:39 [iNFO] [sTDERR] 	at net.minecraft.src.RenderLiving.renderModel(RenderLiving.java:231)
2012-08-14 11:32:39 [iNFO] [sTDERR] 	at net.minecraft.src.RenderLiving.doRenderLiving(RenderLiving.java:99)
2012-08-14 11:32:39 [iNFO] [sTDERR] 	at net.minecraft.src.CSM_RenderClayMan.doRenderLiving(CSM_RenderClayMan.java:336)
2012-08-14 11:32:39 [iNFO] [sTDERR] 	at net.minecraft.src.RenderLiving.doRender(RenderLiving.java:379)
2012-08-14 11:32:39 [iNFO] [sTDERR] 	at net.minecraft.src.RenderManager.renderEntityWithPosYaw(RenderManager.java:188)
2012-08-14 11:32:39 [iNFO] [sTDERR] 	at net.minecraft.src.RenderManager.renderEntity(RenderManager.java:175)
2012-08-14 11:32:39 [iNFO] [sTDERR] 	at net.minecraft.src.RenderGlobal.renderEntities(RenderGlobal.java:434)
2012-08-14 11:32:39 [iNFO] [sTDERR] 	at net.minecraft.src.EntityRenderer.renderWorld(EntityRenderer.java:1037)
2012-08-14 11:32:39 [iNFO] [sTDERR] 	at net.minecraft.src.EntityRenderer.updateCameraAndRender(EntityRenderer.java:898)
2012-08-14 11:32:39 [iNFO] [sTDERR] 	at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:768)
2012-08-14 11:32:39 [iNFO] [sTDERR] 	at net.minecraft.client.Minecraft.run(Minecraft.java:661)
2012-08-14 11:32:39 [iNFO] [sTDERR] 	at java.lang.Thread.run(Unknown Source)
2012-08-14 11:32:40 [iNFO] [sTDERR] java.lang.NullPointerException
2012-08-14 11:32:40 [iNFO] [sTDERR] 	at net.minecraft.src.Render.doRenderShadowAndFire(Render.java:328)
2012-08-14 11:32:40 [iNFO] [sTDERR] 	at net.minecraft.src.RenderManager.renderEntityWithPosYaw(RenderManager.java:189)
2012-08-14 11:32:40 [iNFO] [sTDERR] 	at net.minecraft.src.RenderManager.renderEntity(RenderManager.java:175)
2012-08-14 11:32:40 [iNFO] [sTDERR] 	at net.minecraft.src.RenderGlobal.renderEntities(RenderGlobal.java:434)
2012-08-14 11:32:40 [iNFO] [sTDERR] 	at net.minecraft.src.EntityRenderer.renderWorld(EntityRenderer.java:1037)
2012-08-14 11:32:40 [iNFO] [sTDERR] 	at net.minecraft.src.EntityRenderer.updateCameraAndRender(EntityRenderer.java:898)
2012-08-14 11:32:40 [iNFO] [sTDERR] 	at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:768)
2012-08-14 11:32:40 [iNFO] [sTDERR] 	at net.minecraft.client.Minecraft.run(Minecraft.java:661)
2012-08-14 11:32:40 [iNFO] [sTDERR] 	at java.lang.Thread.run(Unknown Source)

 

 

So I tried to catch these exceptions in the Render file with try { ... } catch (NullPointerException e {} blocks. Then tried to open the world with my entities and I see my entities will be rendered now, but with "vanilla" textures like Creeper and spiders and even some with the /gui/items.png as texture, as seen here:

 

jx6h0.png

 

 

As soon as I try to kill any of them, I get this error:

 

2012-08-14 11:40:35 [iNFO] [sTDERR] java.util.ConcurrentModificationException
2012-08-14 11:40:35 [iNFO] [sTDERR] 	at java.util.ArrayList$Itr.checkForComodification(Unknown Source)
2012-08-14 11:40:35 [iNFO] [sTDERR] 	at java.util.ArrayList$Itr.next(Unknown Source)
2012-08-14 11:40:35 [iNFO] [sTDERR] 	at net.minecraft.src.EntityLiving.onLivingUpdate(EntityLiving.java:1590)
2012-08-14 11:40:35 [iNFO] [sTDERR] 	at net.minecraft.src.CSM_EntityClayMan.onLivingUpdate(CSM_EntityClayMan.java:539)
2012-08-14 11:40:35 [iNFO] [sTDERR] 	at net.minecraft.src.EntityLiving.onUpdate(EntityLiving.java:687)
2012-08-14 11:40:35 [iNFO] [sTDERR] 	at net.minecraft.src.World.updateEntityWithOptionalForce(World.java:2022)
2012-08-14 11:40:35 [iNFO] [sTDERR] 	at net.minecraft.src.WorldServer.updateEntityWithOptionalForce(WorldServer.java:517)
2012-08-14 11:40:35 [iNFO] [sTDERR] 	at net.minecraft.src.World.updateEntity(World.java:1986)
2012-08-14 11:40:35 [iNFO] [sTDERR] 	at net.minecraft.src.World.updateEntities(World.java:1867)
2012-08-14 11:40:35 [iNFO] [sTDERR] 	at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:619)
2012-08-14 11:40:35 [iNFO] [sTDERR] 	at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:547)
2012-08-14 11:40:35 [iNFO] [sTDERR] 	at net.minecraft.src.IntegratedServer.tick(IntegratedServer.java:102)
2012-08-14 11:40:35 [iNFO] [sTDERR] 	at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:453)
2012-08-14 11:40:35 [iNFO] [sTDERR] 	at net.minecraft.src.ThreadServerApplication.run(ThreadServerApplication.java:17)

 

 

So either I forgot something again or this is a forge bug. Here is my changed mod_* file:

https://gist.github.com/4e3d7b2b13bb339601b7

 

Is there a way to solve this? :/

 

 

EDIT: forgot to insert screen

 

EDIT 2: If I outcomment the call super.onLivingUpdate() in my CSM_EntityClayMan class, I get this error, which is similar to that last one above:

 

2012-08-14 11:54:50 [iNFO] [sTDERR] java.util.ConcurrentModificationException
2012-08-14 11:54:50 [iNFO] [sTDERR] 	at java.util.ArrayList$Itr.checkForComodification(Unknown Source)
2012-08-14 11:54:50 [iNFO] [sTDERR] 	at java.util.ArrayList$Itr.next(Unknown Source)
2012-08-14 11:54:50 [iNFO] [sTDERR] 	at net.minecraft.src.Entity.moveEntity(Entity.java:694)
2012-08-14 11:54:50 [iNFO] [sTDERR] 	at net.minecraft.src.EntityLiving.moveEntityWithHeading(EntityLiving.java:1353)
2012-08-14 11:54:50 [iNFO] [sTDERR] 	at net.minecraft.src.EntityLiving.onLivingUpdate(EntityLiving.java:1575)
2012-08-14 11:54:50 [iNFO] [sTDERR] 	at net.minecraft.src.EntityAgeable.onLivingUpdate(EntityAgeable.java:59)
2012-08-14 11:54:50 [iNFO] [sTDERR] 	at net.minecraft.src.EntityAnimal.onLivingUpdate(EntityAnimal.java:40)
2012-08-14 11:54:50 [iNFO] [sTDERR] 	at net.minecraft.src.EntityLiving.onUpdate(EntityLiving.java:687)
2012-08-14 11:54:50 [iNFO] [sTDERR] 	at net.minecraft.src.World.updateEntityWithOptionalForce(World.java:2022)
2012-08-14 11:54:50 [iNFO] [sTDERR] 	at net.minecraft.src.WorldServer.updateEntityWithOptionalForce(WorldServer.java:517)
2012-08-14 11:54:50 [iNFO] [sTDERR] 	at net.minecraft.src.World.updateEntity(World.java:1986)
2012-08-14 11:54:50 [iNFO] [sTDERR] 	at net.minecraft.src.World.updateEntities(World.java:1867)
2012-08-14 11:54:50 [iNFO] [sTDERR] 	at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:619)
2012-08-14 11:54:50 [iNFO] [sTDERR] 	at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:547)
2012-08-14 11:54:50 [iNFO] [sTDERR] 	at net.minecraft.src.IntegratedServer.tick(IntegratedServer.java:102)
2012-08-14 11:54:50 [iNFO] [sTDERR] 	at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:453)
2012-08-14 11:54:50 [iNFO] [sTDERR] 	at net.minecraft.src.ThreadServerApplication.run(ThreadServerApplication.java:17)

 

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.



×
×
  • Create New...

Important Information

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