Kluuucha Posted April 23, 2016 Share Posted April 23, 2016 Hello there. It's my first topic, so sorry for begging for help at the very beginning. I have a problem with entities in my mod. I'm updating mod from 1.7.6 to 1.8 (It's a cooperative mod, so I must use this version, despite it's not too fresh). I need entities to work, 'cause they're the main reason why I'm making this project. I had really bad time removing all the errors, but the worst thing for me was RenderManager. And even after handling all of this, my mobs are crashing the game, when rendering code is included. Here are the files (mod is not called myMod, it's just a replacement) Part of main file (only stuff that's about the mob): package net.mymod.common; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.entity.Render; import net.minecraft.client.renderer.entity.RenderItem; import net.minecraft.entity.EnumCreatureType; import net.minecraft.world.biome.BiomeGenBase; import net.minecraftforge.client.EnumHelperClient; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import net.minecraftforge.fml.client.registry.RenderingRegistry; import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.SidedProxy; import net.minecraftforge.fml.common.Mod.EventHandler; import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.registry.EntityRegistry; import net.minecraftforge.fml.common.registry.GameRegistry; import net.minecraftforge.fml.common.registry.LanguageRegistry; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.client.renderer.texture.TextureManager; import net.minecraft.client.resources.IResourceManager; @net.minecraftforge.fml.common.Mod(modid = mymod.modid, name = "myMod", version = "pre-build 0.1a") public class myMod { public static final String modid = "mymod"; @net.minecraftforge.fml.common.Mod.EventHandler public void init (FMLPreInitializationEvent event) { EntityRegistry.registerModEntity(EntityMyMob.class, "MyMob", 1, this, 64, 1, true, 0xff8100, 0x5d5852); RenderingRegistry.registerEntityRenderingHandler(EntityMyMob.class, new RenderMyMob(Minecraft.getMinecraft().getRenderManager(), new ModelMyMob(), 0.2F)); EntityRegistry.addSpawn(EntityMyMob.class, 10, 4, 8, EnumCreatureType.CREATURE, BiomeGenBase.desert, BiomeGenBase.desertHills, BiomeGenBase.jungle, BiomeGenBase.jungleHills); if(FMLCommonHandler.instance().getSide().isClient()) { } EntityMyMob: package net.mymod.common; import net.minecraft.entity.EntityAgeable; import net.minecraft.entity.EntityCreature; import net.minecraft.entity.ai.EntityAILookIdle; import net.minecraft.entity.ai.EntityAIPanic; import net.minecraft.entity.ai.EntityAISwimming; import net.minecraft.entity.ai.EntityAIWander; import net.minecraft.entity.monster.EntityMob; import net.minecraft.entity.passive.EntityAnimal; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.world.World; public class EntityMyMob extends EntityAnimal{ public EntityMyMob(World par1World) { super(par1World); this.setSize(0.5F, 0.5F); this.getNavigator().setAvoidsWater(true); this.tasks.addTask(0, new EntityAISwimming(this)); this.tasks.addTask(1, new EntityAIWander(this, 0.6D)); this.tasks.addTask(2, new EntityAILookIdle(this)); this.tasks.addTask(3, new EntityAIPanic(this, 0.8D)); } protected boolean canDespawn() { return false; } protected boolean isAIEnabled() { return true; } protected Item getDropItemId() { return Items.string; } @Override public EntityAgeable createChild(EntityAgeable var1) { return null; } } and RenderMyMob: package net.mymod.common; import net.minecraft.client.model.ModelBase; import net.minecraft.client.renderer.entity.Render; import net.minecraft.client.renderer.entity.RenderLiving; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.entity.Entity; import net.minecraft.util.ResourceLocation; public class RenderMyMob extends RenderLiving { private static final ResourceLocation texture = new ResourceLocation("mymod:textures/entity/MyMob.png"); protected ModelMyMob model; public RenderMyMob(RenderManager rm, ModelBase mb, float f) { super(rm, mb, f); model = ((ModelMyMob)mainModel); } public void renderMyMob(EntityMyMob entity, double par2, double par4, double par6, float par8, float par9) { super.doRender(entity, par2, par4, par6, par8, par9); } public void doRenderLiving(EntityMyMob entity, double par2, double par4, double par6, float par8, float par9) { renderMyMob((EntityMyMob)entity, par2, par4, par6, par8, par9); } @Override public void doRender(Entity entity, double d0, double d1, double d2, float f, float f1) { renderMyMob((EntityMyMob)entity, d0, d1, d2, f, f1); } @Override protected ResourceLocation getEntityTexture(Entity entity) { return texture; } } This mob has also custom model, if it's needed I'll post it too. It's highly possible that it doesn't work because it's just messy or something, but I'm struggling with it for long hours and I can't make it work. Thanks in advance, I hope you won't laugh me down I'm returning to modding after loooooong break, I'm just lost in changes. Link to comment Share on other sites More sharing options...
Choonster Posted April 23, 2016 Share Posted April 23, 2016 The RenderManager instance is created between the preInit and init phases, so Minecraft#getRenderManager returns null in preInit. In 1.8, call RenderingRegistry#registerEntityRenderingHandler in init. In 1.8.9 and up, call RenderingRegistry#registerEntityRenderingHandler(Class<T>, IRenderFactory<? super T>) in preInit instead. In future, post the FML log (logs/fml-client-latest.log) or crash report; preferably using a site like Gist or Pastebin. Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future. Link to comment Share on other sites More sharing options...
Kluuucha Posted April 23, 2016 Author Share Posted April 23, 2016 Thanks a lot, It actually worked. I'll remember to add log next time Link to comment Share on other sites More sharing options...
Recommended Posts