Posted February 19, 20178 yr So as the title says, I made my own mob, the problem though is that when I get into minecraft it is just a white box. I think it is because the model isn't rendering correctly and I don't know how to fix it. Am I registering the renderer wrong or am I just forgetting something? (Please be specific) Main Class: @Mod(modid = Reference.MODID, name = Reference.NAME, version = Reference.VERSION) public class MastersMobs { @Mod.Instance(Reference.MODID) public static MastersMobs instance; @SidedProxy(serverSide = Reference.SERVER_PROXY_CLASS, clientSide = Reference.CLIENT_PROXY_CLASS) public static CommonProxy proxy; public static final ResourceLocation LOOT_DEER = LootTableList.register(new ResourceLocation("mmm", "loot_tables/entities/deer")); public ModItems items; @Mod.EventHandler public void preinit(FMLPreInitializationEvent event) { } @Mod.EventHandler public void init(FMLInitializationEvent event) { this.items = new ModItems(); this.items.init(); this.items.register(); ResourceLocation resourceLocation = new ResourceLocation("mmm", "deer"); EntityRegistry.registerModEntity(resourceLocation, EntityDeerAtr.class, resourceLocation.toString(), 0, instance, 64, 1, true, 0, 16777215); proxy.registerClient(); } @Mod.EventHandler public void postinit(FMLPostInitializationEvent event) { } } ModelClass: public class EntityDeer extends ModelBase { private ModelRenderer head; private ModelRenderer body; private ModelRenderer nose1; private ModelRenderer nose2; private ModelRenderer FLLeg; private ModelRenderer FRLeg; private ModelRenderer BLLeg; private ModelRenderer BRLeg; private ModelRenderer tail; private ModelRenderer ant1b; private ModelRenderer ant1m; private ModelRenderer ant1t; private ModelRenderer ant2b; private ModelRenderer ant2m; private ModelRenderer ant2t; private ModelRenderer neck; public EntityDeer() { this.textureWidth = 512; this.textureHeight = 512; this.body = new ModelRenderer(this, 1, 1); // DeerBody this.neck = new ModelRenderer(this, 73, 1); // Neck this.head = new ModelRenderer(this, 105, 1); // Head this.nose1 = new ModelRenderer(this, 137, 1); // Nose1 this.nose2 = new ModelRenderer(this, 161, 1); // Nose2 this.ant1b = new ModelRenderer(this, 1, 1); // Ant1B this.ant1m = new ModelRenderer(this, 65, 1); // Ant1M this.ant1t = new ModelRenderer(this, 73, 1); // Ant1T this.ant2b = new ModelRenderer(this, 97, 1); // Ant2B this.ant2m = new ModelRenderer(this, 105, 1); // Ant2M this.ant2t = new ModelRenderer(this, 185, 1); // Ant2T this.FLLeg = new ModelRenderer(this, 193, 1); // LFLeg this.FRLeg = new ModelRenderer(this, 209, 1); // RFLeg this.BLLeg = new ModelRenderer(this, 225, 1); // LBLeg this.BRLeg = new ModelRenderer(this, 241, 1); // RBLeg this.tail = new ModelRenderer(this, 257, 1); // Tail this.body.addBox(0F, 0F, 0F, 24, 10, 11, 0F); // DeerBody this.body.setRotationPoint(0F, -10F, -5F); this.neck.addBox(0F, 0F, 0F, 7, 8, 7, 0F); // Neck this.neck.setRotationPoint(-3F, -13F, -3F); this.neck.rotateAngleZ = 0.40142573F; this.head.addBox(0F, 0F, 0F, 10, 8, 9, 0F); // Head this.head.setRotationPoint(-6F, -20F, -4F); this.head.rotateAngleZ = 0.12217305F; this.nose1.addBox(0F, 0F, 0F, 5, 2, 5, 0F); // Nose1 this.nose1.setRotationPoint(-9.9F, -14F, -2F); this.nose1.rotateAngleZ = 0.12217305F; this.nose2.addBox(0F, 0F, 0F, 5, 2, 5, 0F); // Nose2 this.nose2.setRotationPoint(-10.2F, -15F, -2F); this.nose2.rotateAngleZ = 0.33161256F; this.ant1b.addBox(0F, 0F, 0F, 1, 4, 1, 0F); // Ant1B this.ant1b.setRotationPoint(-2F, -24F, -5.5F); this.ant1b.rotateAngleX = 0.34906585F; this.ant1b.rotateAngleZ = 0.12217305F; this.ant1m.addBox(0F, 0F, 0F, 1, 5, 1, 0F); // Ant1M this.ant1m.setRotationPoint(-2F, -25.6F, -8.95F); this.ant1m.rotateAngleX = 1.09955743F; this.ant1m.rotateAngleZ = 0.08726646F; this.ant1t.addBox(0F, 0F, 0F, 1, 5, 1, 0F); // Ant1T this.ant1t.setRotationPoint(-2F, -28.8F, -2.2F); this.ant1t.rotateAngleX = -0.62831853F; this.ant2b.addBox(0F, 0F, 0F, 1, 4, 1, 0F); // Ant2B this.ant2b.setRotationPoint(-2F, -24F, 5.5F); this.ant2b.rotateAngleX = -0.34906585F; this.ant2b.rotateAngleZ = 0.12217305F; this.ant2m.addBox(0F, 0F, 0F, 1, 5, 1, 0F); // Ant2M this.ant2m.setRotationPoint(-2F, -26.4F, 9.6F); this.ant2m.rotateAngleX = -1.09955743F; this.ant2m.rotateAngleZ = 0.08726646F; this.ant2t.addBox(0F, 0F, 0F, 1, 5, 1, 0F); // Ant2T this.ant2t.setRotationPoint(-2F, -27.9F, 2F); this.ant2t.rotateAngleX = 0.66322512F; this.FLLeg.addBox(0F, 0F, 0F, 3, 10, 3, 0F); // LFLeg this.FLLeg.setRotationPoint(0.5F, 0F, 3F); this.FRLeg.addBox(0F, 0F, 0F, 3, 10, 3, 0F); // RFLeg this.FRLeg.setRotationPoint(0.5F, 0F, -5F); this.BLLeg.addBox(0F, 0F, 0F, 3, 10, 3, 0F); // LBLeg this.BLLeg.setRotationPoint(20.5F, 0F, 3F); this.BRLeg.addBox(0F, 0F, 0F, 3, 10, 3, 0F); // RBLeg this.BRLeg.setRotationPoint(20.5F, 0F, -5F); this.tail.addBox(0F, 0F, 0F, 2, 3, 3, 0F); // Tail this.tail.setRotationPoint(23F, -12F, -1F); this.tail.rotateAngleZ = -0.29670597F; } public void getItemModel(Entity entity, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scale) { if (this.isChild) { float f = 2.0F; GlStateManager.pushMatrix(); GlStateManager.translate(0.0F, 6.0F * scale, 0.0F); this.head.render(scale); GlStateManager.popMatrix(); GlStateManager.pushMatrix(); GlStateManager.scale(1.4F / f, 1.0F / f, 1.2F / f); GlStateManager.translate(0.0F, 24.0F * scale, 0.0F); this.body.render(scale); GlStateManager.popMatrix(); } else { this.head.render(scale); this.body.render(scale); } } public void setRotateAngles(ModelRenderer modelRenderer, float x, float y, float z) { modelRenderer.rotateAngleX = x; modelRenderer.rotateAngleY = y; modelRenderer.rotateAngleZ = z; } public void setRotationAngles(float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scaleFactor, Entity entity) { this.head.rotateAngleX = (headPitch * 0.017453292F); } } Entity Class: public class EntityDeerAtr extends EntityAnimal { public EntityDeerAtr(World worldIn) { super(worldIn); this.setSize(0.9F, 1.4F); } public static void registerFixesDeer(DataFixer fixer) { EntityLiving.registerFixesMob(fixer, EntityDeerAtr.class); } protected void initEntityAI() { this.tasks.addTask(0, new EntityAISwimming(this)); this.tasks.addTask(1, new EntityAIPanic(this, 2.0D)); this.tasks.addTask(2, new EntityAIMate(this, 1.0D)); this.tasks.addTask(3, new EntityAITempt(this, 1.25D, Items.WHEAT, false)); this.tasks.addTask(4, new EntityAIFollowParent(this, 1.25D)); this.tasks.addTask(5, new EntityAIWanderAvoidWater(this, 1.0D)); this.tasks.addTask(6, new EntityAIWatchClosest(this, EntityPlayer.class, 6.0F)); this.tasks.addTask(7, new EntityAILookIdle(this)); } protected void applyEntityAttributes() { super.applyEntityAttributes(); this.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(10.0D); this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.20000000298023224D); } protected SoundEvent getAmbientSound() { return SoundEvents.ENTITY_COW_AMBIENT; } protected SoundEvent getHurtSound() { return SoundEvents.ENTITY_COW_HURT; } protected SoundEvent getDeathSound() { return SoundEvents.ENTITY_COW_DEATH; } protected void playStepSound(BlockPos pos, Block blockIn) { this.playSound(SoundEvents.ENTITY_COW_STEP, 0.15F, 1.0F); } /** * Returns the volume for the sounds this mob makes. */ protected float getSoundVolume() { return 0.4F; } @Nullable protected ResourceLocation getLootTable() { return MastersMobs.LOOT_DEER; } public EntityDeerAtr createChild(EntityAgeable ageable) { return new EntityDeerAtr(this.world); } public float getEyeHeight() { return this.isChild() ? this.height : 1.3F; } } Render Class: @SideOnly(Side.CLIENT) public class RenderDeer extends RenderLiving<EntityDeerAtr>{ private static final ResourceLocation DEER_TEXTURES = new ResourceLocation("mmm/textures/entity/deer/deer.png"); public RenderDeer(RenderManager render) { super(render, new EntityDeer(), 0.7F); } @Nonnull protected ResourceLocation getEntityTexture(@Nonnull EntityDeerAtr entity) { return DEER_TEXTURES; } } ClientProxy: public class ClientProxy extends CommonProxy { public void registerClient() { registerModel(ModItems.rdeerMeat, 0, new ModelResourceLocation(ModItems.rdeerMeat.getRegistryName(), "inventory")); registerModel(ModItems.cdeerMeat, 0 , new ModelResourceLocation(ModItems.cdeerMeat.getRegistryName(), "inventory")); registerModel(ModItems.sdeerMeat, 0, new ModelResourceLocation(ModItems.sdeerMeat.getRegistryName(), "inventory")); registerModel(ModItems.deerHide, 0, new ModelResourceLocation(ModItems.deerHide.getRegistryName(), "inventory")); registerModel(ModItems.tanHide, 0, new ModelResourceLocation(ModItems.tanHide.getRegistryName(), "inventory")); registerModel(ModItems.deerAntlers, 0, new ModelResourceLocation(ModItems.deerAntlers.getRegistryName(), "inventory")); RenderingRegistry.registerEntityRenderingHandler(EntityDeerAtr.class, RenderDeer::new); } public void registerModel(Object obj, int meta, ModelResourceLocation loc) { Item item = null; if((obj instanceof Item)) { item = (Item)obj; } else if ((obj instanceof Block)) { item = Item.getItemFromBlock((Block)obj); } else { throw new IllegalArgumentException(); } Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, meta, loc); } } CommonProxy: public class CommonProxy { public void registerClient() {} }
February 21, 20178 yr Author On 2/19/2017 at 3:04 PM, diesieben07 said: All that registration stuff should happen in preInit. Or, even better in the appropriate events: RegistryEvent.Register for block, item, etc. registries, anything that uses a ForgeRegistry goes here. Use the registry from the event. Use ModelLoader.setCustomModelResourceLocation in ModelRegistryEvent to register your models, not the ItemModelMesher. RenderingRegistry.registerEntityRenderingHandler must be called in preInit. All I got is a clear box now
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.