Posted September 29, 201312 yr Hello Modder Community! I am currently learning how to create custom mobs and have the following problem: Update: The spawnegg works, only the spawning on rightclick not! What should happen: On rightclicking with a custom item in the player's hand a new custom mob should spawn at the players location. I have 3 console outputs to track the process: 1) Registering rightclick with custom item -> works and prints ("spawning Worm") 2) Creating a custom EntityWorm -> works and prints ("Creating Worm entity") 3) Rendering the Entity -> not called somehow, nothing printed in console, nothing spawning Console output after two rightclicks with ItemWormEgg: Problem: The rightclick is registered, the Entity is created, but the model is not rendered = nothing visual spawns. The RenderWorm.class should print "Rendering Worm" in console after "Creating Worm Entity", but seems to be never called?? The RenderWorm.class is registered in the RenderingHandler during the main load() of Testmod.class: ClientProxy.init( Class reference: 1. ItemWormEgg 2. ModelWorm 3. RenderWorm 4. EntityWorm 5. Mainmod.class (Testmod) ItemWormEgg public class ItemWormSpawnEgg extends Item { [...] //RIGHTCLICK @Override public ItemStack onItemRightClick(ItemStack item, World world, EntityPlayer player) { if(!world.isRemote) { EntityWorm worm = new EntityWorm(world); int x = player.serverPosX; int y = player.serverPosY; int z = player.serverPosZ; worm.posX = x; worm.posY = y; worm.posZ = z; world.spawnEntityInWorld(worm); System.out.println("spawning Worm"); return item; } return item; } } ModelWorm public class ModelWorm extends ModelBase { //fields ModelRenderer Body; ModelRenderer Shape1; ModelRenderer Shape2; public ModelWorm() { textureWidth = 128; textureHeight = 32; Body = new ModelRenderer(this, 0, 0); Body.addBox(0F, 0F, 0F, 7, 6, 6); Body.setRotationPoint(0F, 18F, 0F); Body.setTextureSize(128, 32); Body.mirror = true; setRotation(Body, 0F, 0F, 0F); Shape1 = new ModelRenderer(this, 27, 0); Shape1.addBox(0F, 0F, 0F, 2, 2, 2); Shape1.setRotationPoint(1F, 16F, 1F); Shape1.setTextureSize(128, 32); Shape1.mirror = true; setRotation(Shape1, 0F, 0F, 0F); Shape2 = new ModelRenderer(this, 36, 0); Shape2.addBox(0F, 0F, 0F, 2, 2, 2); Shape2.setRotationPoint(4F, 16F, 1F); Shape2.setTextureSize(128, 32); Shape2.mirror = true; setRotation(Shape2, 0F, 0F, 0F); } public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { super.render(entity, f, f1, f2, f3, f4, f5); setRotationAngles(f, f1, f2, f3, f4, f5, entity); Body.render(f5); Shape1.render(f5); Shape2.render(f5); } private void setRotation(ModelRenderer model, float x, float y, float z) { model.rotateAngleX = x; model.rotateAngleY = y; model.rotateAngleZ = z; } public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity) { super.setRotationAngles(f, f1, f2, f3, f4, f5, entity); } RenderWorm @SideOnly(Side.CLIENT) public class RenderWorm extends RenderLiving { protected ModelWorm model; public RenderWorm(ModelBase modelBase, float par2) { super(modelBase, par2); System.out.println("Rendering worm..."); } @Override protected ResourceLocation getEntityTexture(Entity par1Entity) { return new ResourceLocation("zkymod:textures/npc/Worm.png"); } } EntityWorm public class EntityWorm extends EntityAnimal { public EntityWorm(World par1World) { super(par1World); this.experienceValue = 10; this.tasks.addTask(0, new EntityAISwimming(this)); this.tasks.addTask(7, new EntityAILookIdle(this)); this.tasks.addTask(6, new EntityAIWander(this, 0.25D)); this.getNavigator().setAvoidsWater(true); this.tasks.addTask(7, new EntityAIWatchClosest(this, EntityPlayer.class, 6.0F)); this.tasks.addTask(1, new EntityAIPanic(this, 1.25D)); this.setSize(0.9F, 0.9F); System.out.println("Creating Worm Entity"); } public boolean isAIEnabled() { return true; } protected String getLivingSound() { return "mob.zombie.say"; } /** * Returns the sound this mob makes when it is hurt. */ protected String getHurtSound() { return "mob.zombie.hurt"; } /** * Returns the sound this mob makes on death. */ protected String getDeathSound() { return "mob.zombie.death"; } protected void applyEntityAttributes() { super.applyEntityAttributes(); this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setAttribute(20.0D); } protected int getDropItemId() { return Item.goldNugget.itemID; } @Override public EntityAgeable createChild(EntityAgeable entityageable) { // TODO Auto-generated method stub return null; } @Override public String getEntityName(){ return "Worm"; } Client Proxy public class ClientProxy extends CommonProxy { @Override public void initRenders() { RenderingRegistry.registerEntityRenderingHandler(EntityWorm.class, new RenderWorm(new ModelWorm(), 0.5F)); } } Testmod (MainClass) @Mod(modid = ModInformation.ID, name =ModInformation.NAME, version = ModInformation.VERSION) @NetworkMod(channels = {ModInformation.CHANNEL} , clientSideRequired = true, serverSideRequired = false, packetHandler = PacketHandler.class) public class Testmod { @Instance(ModInformation.ID) public static Testmod instance; @SidedProxy(clientSide = "proxies.ClientProxy", serverSide = "proxies.CommonProxy") public static CommonProxy proxy; @EventHandler public void preInit(FMLPreInitializationEvent event) { proxy.initRenders(); } @EventHandler public void load(FMLInitializationEvent event) { //Register NPCEntities EntityRegistry.registerModEntity(EntityWorm.class, NpcInfo.WORM_NAME, NpcInfo.WORM_ID, mod, 80, 1, true); EntityRegistry.addSpawn(EntityWorm.class, 2, 0, 1, EnumCreatureType.creature); LanguageRegistry.instance().addStringLocalization("entity."+NpcInfo.WORM_NAME+".name" , "en_US", NpcInfo.WORM_NAME); } } You guys are my last hope, why is nothing spawning? Additional Info: The code compiles without any errors, starting the client, joining the world and rightclicking gives you errors, too, but nothing spawns. Forge Version: [1.6.4] latest recommended, Windows 7 64bit + Eclipse
September 29, 201312 yr Hello, I've got a working render class for 1.6.4! I hope this works for you: public class ElectricerRenderer extends Render { ElectricerModel model; public ElectricerRenderer() { shadowSize = 0.3F; model = new ElectricerModel(); } public void RenderElectricer(ElectricerEntity entity, double par2, double par4, double par6, float par8, float par9) { GL11.glPushMatrix(); GL11.glTranslatef((float)par2, (float)par4 + 1.5F, (float)par6); GL11.glRotatef(180 - par8, 0, 1, 0); GL11.glScalef(-1, -1, 1); bindEntityTexture(entity); model.render(entity, 0, 0, -0.1F, 0, 0, 0.0625F); GL11.glPopMatrix(); } @Override public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9) { RenderElectricer((ElectricerEntity)par1Entity, par2, par4, par6, par8, par9); } @Override protected ResourceLocation getEntityTexture(Entity entity) { return new ResourceLocation("brickcraft", "/textures/models/electricer/ElectricerModel.png"); } You might want to adjust glTranslate a little bit, if the entity is stuck in the floor. Tell me if it works! ss7 You sir are a god damn hero.
September 29, 201312 yr Wait, what is that "mod" variable ? EntityRegistry.registerModEntity(EntityWorm.class, NpcInfo.WORM_NAME, NpcInfo.WORM_ID, mod, 80, 1, true); It should be "this". @ss7 He doesn't need that. He is using RenderLiving already.
September 30, 201312 yr Author @GotoLink: mod was a constant, i replaced the codeMobEntity: EntityRegistry.registerModEntity(EntityWorm.class, NpcInfo.WORM_NAME, NpcInfo.WORM_ID, mod, 80, 1, true); with globalEntityID (to get a spawner egg in creative tab) : EntityRegistry.registerGlobalEntityID(EntityWorm.class, "Worm", EntityRegistry.findGlobalUniqueEntityId(), 8207116, 11760454); Now i get a spawner Egg registered and a global Entity id. When using the new custom spawner egg ingame the mob spawns and renders fine. When using my custom item it does not, which means there must be a problem with the rightclicking of the ItemWand item in the ItemWand.class. The thing is: the console prints the rightclick is registered, it prints the EntityWorm is created, but it does not print that the renderWorm.class is used. ItemWand.class //RIGHTCLICK @Override public ItemStack onItemRightClick(ItemStack item, World world, EntityPlayer player) { if(!world.isRemote) { EntityWorm worm = new EntityWorm(world); int x = player.serverPosX; int y = player.serverPosY; int z = player.serverPosZ; worm.posX = x; worm.posY = y; worm.posZ = z; world.spawnEntityInWorld((EntityWorm)worm); System.out.println("spawning Worm"); return item; } return item; }
September 30, 201312 yr Check the position values of your Entity. And i'd like to see where "mod" is declared. It is supposed to be your Testmod instance.
September 30, 201312 yr Author mod is no longer used, read the code above for the updated EntityRegistry
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.