Jump to content

[Solved] [1.7.10] Crash when attempting to insert custom renderer


Recommended Posts

Posted (edited)

What I am trying to do: replace rendering of baby animals with custom renderers and event handling.

 

Main Mod File:

package com.outlook.siribby.babyanimals;

import com.outlook.siribby.babyanimals.model.*;
import com.outlook.siribby.babyanimals.renderer.*;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.TickEvent;
import net.minecraft.client.renderer.entity.RendererLivingEntity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.passive.*;
import net.minecraftforge.client.event.RenderLivingEvent;
import net.minecraftforge.common.MinecraftForge;

import java.util.HashMap;

@Mod(modid = BabyAnimals.MOD_ID, name = "Baby Animals Model Swapper", version = "@VERSION@")
public class BabyAnimals {
    public static final String MOD_ID = "babyanimals";
    public static final HashMap<Class<? extends EntityLivingBase>, RendererLivingEntity> entityRenderMap = new HashMap<Class<? extends EntityLivingBase>, RendererLivingEntity>();
    private static float renderTickTime;
    private static boolean isRendering;

    @Mod.EventHandler
    public void preInit(FMLPreInitializationEvent event) {
        entityRenderMap.put(EntityPig.class, new RenderNewPig(new ModelNewPig(), new ModelNewPig(0.5F), 0.7F));
        entityRenderMap.put(EntitySheep.class, new RenderNewSheep(new ModelNewSheep2(), new ModelNewSheep1(), 0.7F));
        entityRenderMap.put(EntityCow.class, new RenderNewCow(new ModelNewCow(), 0.7F));
        entityRenderMap.put(EntityMooshroom.class, new RenderNewMooshroom(new ModelNewCow(), 0.7F));
        entityRenderMap.put(EntityWolf.class, new RenderNewWolf(new ModelNewWolf(), new ModelNewWolf(), 0.5F));
        entityRenderMap.put(EntityChicken.class, new RenderNewChicken(new ModelNewChicken(), 0.3F));

        FMLCommonHandler.instance().bus().register(this);
        MinecraftForge.EVENT_BUS.register(this);
    }

    @SubscribeEvent
    public void onTick(TickEvent.RenderTickEvent event) {
        if (event.phase == TickEvent.Phase.START) {
            renderTickTime = event.renderTickTime;
        }
    }

    @SubscribeEvent
    public void renderEntity(RenderLivingEvent.Pre event) {
        if (!isRendering) {
            EntityLivingBase entity = event.entity;

            if (entity.isChild()) {
                RendererLivingEntity renderer = entityRenderMap.get(entity.getClass());

                if (renderer != null) {
                    isRendering = true;
                    renderer.doRender(entity, event.x, event.y, event.z, 0.0F, renderTickTime);
                    isRendering = false;
                    event.setCanceled(true);
                }
            }
        }
    }
}
 

Crash Log:

Spoiler

---- Minecraft Crash Report ----
// Daisy, daisy...

Time: 4/11/15 8:21 PM
Description: Rendering entity in world

java.lang.NullPointerException: Rendering entity in world
at net.minecraft.client.renderer.entity.RendererLivingEntity.func_110813_b(RendererLivingEntity.java:525)
at net.minecraft.client.renderer.entity.RenderLiving.func_110813_b(RenderLiving.java:25)
at net.minecraft.client.renderer.entity.RenderLiving.func_110813_b(RenderLiving.java:134)
at net.minecraft.client.renderer.entity.RendererLivingEntity.passSpecialRender(RendererLivingEntity.java:471)
at net.minecraft.client.renderer.entity.RendererLivingEntity.doRender(RendererLivingEntity.java:296)
at net.minecraft.client.renderer.entity.RenderLiving.doRender(RenderLiving.java:36)
at net.minecraft.client.renderer.entity.RenderLiving.doRender(RenderLiving.java:145)
at com.outlook.siribby.babyanimals.BabyAnimals.renderEntity(BabyAnimals.java:56)
at cpw.mods.fml.common.eventhandler.ASMEventHandler_7_BabyAnimals_renderEntity_Pre.invoke(.dynamic)
at cpw.mods.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:54)
at cpw.mods.fml.common.eventhandler.EventBus.post(EventBus.java:138)
at net.minecraft.client.renderer.entity.RendererLivingEntity.doRender(RendererLivingEntity.java:87)
at net.minecraft.client.renderer.entity.RenderLiving.doRender(RenderLiving.java:36)
at net.minecraft.client.renderer.entity.RenderLiving.doRender(RenderLiving.java:156)
at net.minecraft.client.renderer.entity.RenderManager.func_147939_a(RenderManager.java:300)
at net.minecraft.client.renderer.entity.RenderManager.renderEntityStatic(RenderManager.java:278)
at net.minecraft.client.renderer.entity.RenderManager.renderEntitySimple(RenderManager.java:251)
at net.minecraft.client.renderer.RenderGlobal.renderEntities(RenderGlobal.java:527)
at net.minecraft.client.renderer.EntityRenderer.renderWorld(EntityRenderer.java:1300)
at net.minecraft.client.renderer.EntityRenderer.updateCameraAndRender(EntityRenderer.java:1087)
at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1057)
at net.minecraft.client.Minecraft.run(Minecraft.java:951)
at net.minecraft.client.main.Main.main(Main.java:164)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:85)
at GradleStart.main(GradleStart.java:45)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140)


A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------

-- Head --
Stacktrace:
at net.minecraft.client.renderer.entity.RendererLivingEntity.func_110813_b(RendererLivingEntity.java:525)
at net.minecraft.client.renderer.entity.RenderLiving.func_110813_b(RenderLiving.java:25)
at net.minecraft.client.renderer.entity.RenderLiving.func_110813_b(RenderLiving.java:134)
at net.minecraft.client.renderer.entity.RendererLivingEntity.passSpecialRender(RendererLivingEntity.java:471)
at net.minecraft.client.renderer.entity.RendererLivingEntity.doRender(RendererLivingEntity.java:296)
at net.minecraft.client.renderer.entity.RenderLiving.doRender(RenderLiving.java:36)
at net.minecraft.client.renderer.entity.RenderLiving.doRender(RenderLiving.java:145)
at com.outlook.siribby.babyanimals.BabyAnimals.renderEntity(BabyAnimals.java:56)
at cpw.mods.fml.common.eventhandler.ASMEventHandler_7_BabyAnimals_renderEntity_Pre.invoke(.dynamic)
at cpw.mods.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:54)
at cpw.mods.fml.common.eventhandler.EventBus.post(EventBus.java:138)
at net.minecraft.client.renderer.entity.RendererLivingEntity.doRender(RendererLivingEntity.java:87)
at net.minecraft.client.renderer.entity.RenderLiving.doRender(RenderLiving.java:36)
at net.minecraft.client.renderer.entity.RenderLiving.doRender(RenderLiving.java:156)

-- Entity being rendered --
Details:
Entity Type: Pig (net.minecraft.entity.passive.EntityPig)
Entity ID: 138
Entity Name: Pig
Entity's Exact location: -324.88, 4.00, -120.32
Entity's Block location: World: (-325,4,-121), Chunk: (at 11,0,7 in -21,-8; contains blocks -336,0,-128 to -321,255,-113), Region: (-1,-1; contains chunks -32,-32 to -1,-1, blocks -512,0,-512 to -1,255,-1)
Entity's Momentum: 0.00, -0.08, 0.00

-- Renderer details --
Details:
Assigned renderer: net.minecraft.client.renderer.entity.RenderPig@85d59a0
Location: -2.95,-1.62,-3.20 - World: (-3,-2,-4), Chunk: (at 13,-1,12 in -1,-1; contains blocks -16,0,-16 to -1,255,-1), Region: (-1,-1; contains chunks -32,-32 to -1,-1, blocks -512,0,-512 to -1,255,-1)
Rotation: -61.875
Delta: 0.8952131
Stacktrace:
at net.minecraft.client.renderer.entity.RenderManager.func_147939_a(RenderManager.java:300)
at net.minecraft.client.renderer.entity.RenderManager.renderEntityStatic(RenderManager.java:278)
at net.minecraft.client.renderer.entity.RenderManager.renderEntitySimple(RenderManager.java:251)
at net.minecraft.client.renderer.RenderGlobal.renderEntities(RenderGlobal.java:527)
at net.minecraft.client.renderer.EntityRenderer.renderWorld(EntityRenderer.java:1300)

-- Affected level --
Details:
Level name: MpServer
All players: 1 total; [EntityClientPlayerMP['MrIbby'/161, l='MpServer', x=-321.94, y=5.62, z=-117.12]]
Chunk stats: MultiplayerChunkCache: 55, 55
Level seed: 0
Level generator: ID 01 - flat, ver 0. Features enabled: false
Level generator options: 
Level spawn location: World: (-419,4,-152), Chunk: (at 13,0,8 in -27,-10; contains blocks -432,0,-160 to -417,255,-145), Region: (-1,-1; contains chunks -32,-32 to -1,-1, blocks -512,0,-512 to -1,255,-1)
Level time: 7790 game time, 7790 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: 51 total; [EntityPig['Pig'/137, l='MpServer', x=-322.50, y=4.00, z=-119.78], EntityChicken['Chicken'/136, l='MpServer', x=-334.53, y=4.00, z=-115.47], EntityPig['Pig'/138, l='MpServer', x=-324.88, y=4.00, z=-120.32], EntityPig['Pig'/143, l='MpServer', x=-317.91, y=4.00, z=-161.31], EntityPig['Pig'/131, l='MpServer', x=-323.09, y=4.00, z=-175.06], EntityPig['Pig'/130, l='MpServer', x=-329.88, y=4.00, z=-175.09], EntitySheep['Sheep'/133, l='MpServer', x=-334.94, y=4.00, z=-134.41], EntityPig['Pig'/132, l='MpServer', x=-326.91, y=4.00, z=-156.22], EntityWolf['Wolf'/135, l='MpServer', x=-320.75, y=4.00, z=-116.97], EntityWolf['Wolf'/134, l='MpServer', x=-324.63, y=4.00, z=-115.44], EntityPig['Pig'/85, l='MpServer', x=-376.56, y=4.00, z=-114.66], EntityWolf['Wolf'/152, l='MpServer', x=-318.56, y=4.00, z=-118.06], EntityPig['Pig'/84, l='MpServer', x=-382.59, y=4.00, z=-136.88], EntityWolf['Wolf'/153, l='MpServer', x=-319.21, y=4.00, z=-117.46], EntityPig['Pig'/87, l='MpServer', x=-374.84, y=4.00, z=-108.59], EntityWolf['Wolf'/154, l='MpServer', x=-319.96, y=4.00, z=-117.46], EntityPig['Pig'/86, l='MpServer', x=-377.56, y=4.00, z=-112.75], EntityPig['Pig'/155, l='MpServer', x=-299.06, y=4.00, z=-154.25], EntitySheep['Sheep'/81, l='MpServer', x=-378.06, y=4.00, z=-135.88], EntityChicken['Chicken'/156, l='MpServer', x=-303.81, y=4.00, z=-150.97], EntityPig['Pig'/80, l='MpServer', x=-374.28, y=4.00, z=-154.84], EntityPig['Pig'/157, l='MpServer', x=-297.91, y=4.00, z=-144.25], EntityPig['Pig'/83, l='MpServer', x=-372.06, y=4.00, z=-133.34], EntitySheep['Sheep'/158, l='MpServer', x=-300.41, y=4.00, z=-141.78], EntityChicken['Chicken'/82, l='MpServer', x=-382.97, y=4.00, z=-138.03], EntityPig['Pig'/159, l='MpServer', x=-303.47, y=4.00, z=-135.03], EntityPig['Pig'/144, l='MpServer', x=-309.16, y=4.00, z=-152.44], EntityChicken['Chicken'/145, l='MpServer', x=-312.56, y=4.00, z=-156.63], EntityPig['Pig'/146, l='MpServer', x=-311.91, y=4.00, z=-151.28], EntitySheep['Sheep'/147, l='MpServer', x=-308.84, y=4.00, z=-135.91], EntityChicken['Chicken'/89, l='MpServer', x=-382.22, y=4.00, z=-88.34], EntityPig['Pig'/148, l='MpServer', x=-319.34, y=4.00, z=-132.16], EntityPig['Pig'/88, l='MpServer', x=-373.44, y=4.00, z=-110.47], EntityChicken['Chicken'/149, l='MpServer', x=-319.97, y=4.00, z=-138.16], EntityPig['Pig'/150, l='MpServer', x=-313.69, y=4.00, z=-143.56], EntityChicken['Chicken'/151, l='MpServer', x=-308.72, y=4.00, z=-124.94], EntityPig['Pig'/102, l='MpServer', x=-357.72, y=4.00, z=-134.56], EntityClientPlayerMP['MrIbby'/161, l='MpServer', x=-321.94, y=5.62, z=-117.12], EntityChicken['Chicken'/103, l='MpServer', x=-352.47, y=4.00, z=-133.47], EntitySheep['Sheep'/100, l='MpServer', x=-359.97, y=4.00, z=-169.03], EntityChicken['Chicken'/101, l='MpServer', x=-359.25, y=4.00, z=-155.25], EntityPig['Pig'/160, l='MpServer', x=-290.50, y=4.00, z=-126.34], EntitySheep['Sheep'/104, l='MpServer', x=-365.31, y=4.00, z=-128.66], EntityPig['Pig'/105, l='MpServer', x=-367.75, y=4.00, z=-108.13], EntityPig['Pig'/119, l='MpServer', x=-346.47, y=4.00, z=-128.22], EntityPig['Pig'/118, l='MpServer', x=-348.28, y=4.00, z=-133.44], EntitySheep['Sheep'/117, l='MpServer', x=-348.50, y=4.00, z=-148.25], EntityChicken['Chicken'/123, l='MpServer', x=-342.97, y=4.00, z=-122.09], EntitySheep['Sheep'/122, l='MpServer', x=-336.63, y=4.00, z=-112.72], EntitySheep['Sheep'/121, l='MpServer', x=-348.97, y=4.00, z=-121.25], EntitySheep['Sheep'/120, l='MpServer', x=-346.59, y=4.00, z=-123.53]]
Retry entities: 0 total; []
Server brand: fml,forge
Server type: Integrated singleplayer server
Stacktrace:
at net.minecraft.client.multiplayer.WorldClient.addWorldInfoToCrashReport(WorldClient.java:415)
at net.minecraft.client.Minecraft.addGraphicsAndWorldToCrashReport(Minecraft.java:2556)
at net.minecraft.client.Minecraft.run(Minecraft.java:972)
at net.minecraft.client.main.Main.main(Main.java:164)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:85)
at GradleStart.main(GradleStart.java:45)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140)

-- System Details --
Details:
Minecraft Version: 1.7.10
Operating System: Mac OS X (x86_64) version 10.10.2
Java Version: 1.7.0_67, Oracle Corporation
Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
Memory: 770129272 bytes (734 MB) / 1038876672 bytes (990 MB) up to 1038876672 bytes (990 MB)
JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M
AABB Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used
IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0
FML: MCP v9.05 FML v7.10.85.1291 Minecraft Forge 10.13.2.1291 4 mods loaded, 4 mods active
mcp{9.05} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
FML{7.10.85.1291} [Forge Mod Loader] (forgeSrc-1.7.10-10.13.2.1291.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
Forge{10.13.2.1291} [Minecraft Forge] (forgeSrc-1.7.10-10.13.2.1291.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
babyanimals{@VERSION@} [baby Animals Model Swapper] (babyanimals) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
Launched Version: 1.7.10
LWJGL: 2.9.1
OpenGL: NVIDIA GeForce GT 650M OpenGL Engine GL version 2.1 NVIDIA-10.2.1 310.41.15f01, NVIDIA Corporation
GL Caps: Using GL 1.3 multitexturing.
Using framebuffer objects because ARB_framebuffer_object is supported and separate blending is supported.
Anisotropic filtering is supported and maximum anisotropy is 16.
Shaders are available because OpenGL 2.1 is supported.

Is Modded: Definitely; Client brand changed to 'fml,forge'
Type: Client (map_client.txt)
Resource Packs: []
Current Language: English (US)
Profiler Position: N/A (disabled)
Vec3 Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used
Anisotropic Filtering: Off (1)

 

 
SOLUTION:
Two years later, I finally figured out why this didn't work. In 1.7 (and probably previous versions also), the renderManager field needs to be set manually by doing renderer.setRenderManager(RenderManager.instance) in contrast to 1.8 and higher where renderManager is a constructor argument.
 
Adding this code to the main mod class should fix the problem:
@Mod.EventHandler
public void init(FMLInitializationEvent event) {
    for (RendererLivingEntity renderer : entityRenderMap.values()) {
        renderer.setRenderManager(RenderManager.instance);
    }
}

 

Edited by MrIbby
Finally solved the problem
Posted

1st glance - rendering goes to init() not preInit().

Try that.

 

Other than that - make sure your renderers are not breaking class parenting. If above won't work, code would be nice.

1.7.10 is no longer supported by forge, you are on your own.

Posted

Changing the FML event has no effect.

 

Here is the rest of my code:

[spoiler=Models]ModelNewChicken:

package com.outlook.siribby.babyanimals.model;

import net.minecraft.client.model.ModelChicken;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.entity.Entity;

public class ModelNewChicken extends ModelChicken {
    public final ModelRenderer chickHead;
    public final ModelRenderer chickBill;
    public final ModelRenderer chickBody;
    public final ModelRenderer chickRightLeg;
    public final ModelRenderer chickLeftLeg;

    public ModelNewChicken() {
        chickHead = new ModelRenderer(this, 0, 0);
        chickHead.addBox(-1.5F, -1.5F, -1.5F, 3, 3, 3, 0.0F);
        chickHead.setRotationPoint(0.0F, 18F, -2.5F);
        chickBill = new ModelRenderer(this, 12, 3);
        chickBill.addBox(-0.5F, 0.5F, -2.5F, 1, 1, 1, 0.0F);
        chickBill.setRotationPoint(0.0F, 18F, -2.5F);
        chickBody = new ModelRenderer(this, 0, 6);
        chickBody.addBox(-2F, -2.5F, -2F, 4, 5, 4, 0.0F);
        chickBody.setRotationPoint(0.0F, 20F, 0.0F);
        chickRightLeg = new ModelRenderer(this, 12, 0);
        chickRightLeg.addBox(-0.5F, 0.0F, -1F, 1, 2, 1, 0.0F);
        chickRightLeg.setRotationPoint(-1F, 22F, 0.5F);
        chickLeftLeg = new ModelRenderer(this, 12, 0);
        chickLeftLeg.addBox(-0.5F, 0.0F, -1F, 1, 2, 1, 0.0F);
        chickLeftLeg.setRotationPoint(1.0F, 22F, 0.5F);
    }

    @Override
    public void render(Entity entity, float par2, float par3, float par4, float par5, float par6, float par7) {
        if (isChild) {
            setRotationAngles(par2, par3, par4, par5, par6, par7, entity);

            chickHead.render(par7);
            chickBill.render(par7);
            chickBody.render(par7);
            chickRightLeg.render(par7);
            chickLeftLeg.render(par7);
        } else {
            super.render(entity, par2, par3, par4, par5, par6, par7);
        }
    }

    @Override
    public void setRotationAngles(float par1, float par2, float par3, float par4, float par5, float par6, Entity entity) {
        super.setRotationAngles(par1, par2, par3, par4, par5, par6, entity);
        chickHead.rotateAngleX = head.rotateAngleX;
        chickHead.rotateAngleY = head.rotateAngleY;
        chickBill.rotateAngleX = bill.rotateAngleX;
        chickBill.rotateAngleY = bill.rotateAngleY;
        chickBody.rotateAngleX = body.rotateAngleX;
        chickRightLeg.rotateAngleX = rightLeg.rotateAngleX;
        chickLeftLeg.rotateAngleX = leftLeg.rotateAngleX;
    }
}

 

ModelNewCow:

package com.outlook.siribby.babyanimals.model;

import net.minecraft.client.model.ModelCow;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.entity.Entity;

public class ModelNewCow extends ModelCow {
    public final ModelRenderer calfHead;
    public final ModelRenderer calfBody;
    public final ModelRenderer calfLeg1;
    public final ModelRenderer calfLeg2;
    public final ModelRenderer calfLeg3;
    public final ModelRenderer calfLeg4;

    public ModelNewCow() {
        calfHead = new ModelRenderer(this, 0, 0);
        calfHead.addBox(-3F, -3F, -3F, 6, 6, 4, 0.0F);
        calfHead.setRotationPoint(0.0F, 10F, -4F);
        calfHead.setTextureOffset(17, 0).addBox(-3.5F, -4F, -2F, 1, 2, 1, 0.0F);
        calfHead.setTextureOffset(17, 0).addBox(2.5F, -4F, -2F, 1, 2, 1, 0.0F);
        calfBody = new ModelRenderer(this, 15, 5);
        calfBody.addBox(-3F, -4.5F, -2.5F, 6, 9, 5, 0.0F);
        calfBody.setRotationPoint(0.0F, 12.5F, 0.0F);
        calfLeg1 = new ModelRenderer(this, 0, 10);
        calfLeg1.addBox(-1F, 0.0F, -1F, 2, 9, 2, 0.0F);
        calfLeg1.setRotationPoint(-2F, 15F, 4F);
        calfLeg2 = new ModelRenderer(this, 0, 10);
        calfLeg2.addBox(-1F, 0.0F, -1F, 2, 9, 2, 0.0F);
        calfLeg2.setRotationPoint(2.0F, 15F, 4F);
        calfLeg3 = new ModelRenderer(this, 0, 10);
        calfLeg3.addBox(-1F, 0.0F, -1F, 2, 9, 2, 0.0F);
        calfLeg3.setRotationPoint(-2F, 15F, -3F);
        calfLeg4 = new ModelRenderer(this, 0, 10);
        calfLeg4.addBox(-1F, 0.0F, -1F, 2, 9, 2, 0.0F);
        calfLeg4.setRotationPoint(2.0F, 15F, -3F);
    }

    @Override
    public void render(Entity entity, float par2, float par3, float par4, float par5, float par6, float par7) {
        if (isChild) {
            setRotationAngles(par2, par3, par4, par5, par6, par7, entity);

            calfHead.render(par7);
            calfBody.render(par7);
            calfLeg1.render(par7);
            calfLeg2.render(par7);
            calfLeg3.render(par7);
            calfLeg4.render(par7);
        } else {
            super.render(entity, par2, par3, par4, par5, par6, par7);
        }
    }

    @Override
    public void setRotationAngles(float par1, float par2, float par3, float par4, float par5, float par6, Entity entity) {
        super.setRotationAngles(par1, par2, par3, par4, par5, par6, entity);
        calfHead.rotateAngleX = head.rotateAngleX;
        calfHead.rotateAngleY = head.rotateAngleY;
        calfBody.rotateAngleX = body.rotateAngleX;
        calfLeg1.rotateAngleX = leg1.rotateAngleX;
        calfLeg2.rotateAngleX = leg2.rotateAngleX;
        calfLeg3.rotateAngleX = leg3.rotateAngleX;
        calfLeg4.rotateAngleX = leg4.rotateAngleX;
    }
}

 

ModelNewPig:

package com.outlook.siribby.babyanimals.model;

import net.minecraft.client.model.ModelPig;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.entity.Entity;

public class ModelNewPig extends ModelPig {
    public final ModelRenderer pigletHead;
    public final ModelRenderer pigletBody;
    public final ModelRenderer pigletLeg1;
    public final ModelRenderer pigletLeg2;
    public final ModelRenderer pigletLeg3;
    public final ModelRenderer pigletLeg4;

    public ModelNewPig() {
        this(0.0F);
    }

    public ModelNewPig(float par1) {
        super(par1);

        pigletHead = new ModelRenderer(this, 0, 0);
        pigletHead.addBox(-2.5F, -2F, -3F, 5, 4, 4, 0.0F);
        pigletHead.setRotationPoint(0.0F, 17F, -3F);
        pigletBody = new ModelRenderer(this, 14, 4);
        pigletBody.addBox(-3F, -4F, -2F, 6, 8, 4, 0.0F);
        pigletBody.setRotationPoint(0.0F, 19F, 0.0F);
        pigletLeg1 = new ModelRenderer(this, 0, ;
        pigletLeg1.addBox(-1F, 0.0F, -1F, 2, 3, 2, 0.0F);
        pigletLeg1.setRotationPoint(-2F, 21F, 4F);
        pigletLeg2 = new ModelRenderer(this, 0, ;
        pigletLeg2.addBox(-1F, 0.0F, -1F, 2, 3, 2, 0.0F);
        pigletLeg2.setRotationPoint(2.0F, 21F, 4F);
        pigletLeg3 = new ModelRenderer(this, 0, ;
        pigletLeg3.addBox(-1F, 0.0F, -1F, 2, 3, 2, 0.0F);
        pigletLeg3.setRotationPoint(-2F, 21F, -2F);
        pigletLeg4 = new ModelRenderer(this, 0, ;
        pigletLeg4.addBox(-1F, 0.0F, -1F, 2, 3, 2, 0.0F);
        pigletLeg4.setRotationPoint(2.0F, 21F, -2F);
    }

    @Override
    public void render(Entity entity, float par2, float par3, float par4, float par5, float par6, float par7) {
        if (isChild) {
            setRotationAngles(par2, par3, par4, par5, par6, par7, entity);

            pigletHead.render(par7);
            pigletBody.render(par7);
            pigletLeg1.render(par7);
            pigletLeg2.render(par7);
            pigletLeg3.render(par7);
            pigletLeg4.render(par7);
        } else {
            super.render(entity, par2, par3, par4, par5, par6, par7);
        }
    }

    @Override
    public void setRotationAngles(float par1, float par2, float par3, float par4, float par5, float par6, Entity entity) {
        super.setRotationAngles(par1, par2, par3, par4, par5, par6, entity);
        pigletHead.rotateAngleX = head.rotateAngleX;
        pigletHead.rotateAngleY = head.rotateAngleY;
        pigletBody.rotateAngleX = body.rotateAngleX;
        pigletLeg1.rotateAngleX = leg1.rotateAngleX;
        pigletLeg2.rotateAngleX = leg2.rotateAngleX;
        pigletLeg3.rotateAngleX = leg3.rotateAngleX;
        pigletLeg4.rotateAngleX = leg4.rotateAngleX;
    }
}

 

ModelNewSheep1:

package com.outlook.siribby.babyanimals.model;

import net.minecraft.client.model.ModelRenderer;
import net.minecraft.client.model.ModelSheep1;
import net.minecraft.entity.Entity;

public class ModelNewSheep1 extends ModelSheep1 {
    public final ModelRenderer lambHead;
    public final ModelRenderer lambBody;
    public final ModelRenderer lambLeg1;
    public final ModelRenderer lambLeg2;
    public final ModelRenderer lambLeg3;
    public final ModelRenderer lambLeg4;

    public ModelNewSheep1() {
        lambHead = new ModelRenderer(this, 0, 0);
        lambHead.addBox(-3F, -2.5F, -2F, 6, 5, 3, 0.1F);
        lambHead.setRotationPoint(0.0F, 13F, -4F);
        lambBody = new ModelRenderer(this, 15, 4);
        lambBody.addBox(-3F, -4.5F, -2.5F, 6, 9, 5, 0.1F);
        lambBody.setRotationPoint(0.0F, 15.5F, 0.0F);
        lambLeg1 = new ModelRenderer(this, 0, 9);
        lambLeg1.addBox(-1F, 0.0F, -1F, 2, 2, 2, 0.1F);
        lambLeg1.setRotationPoint(-2F, 18F, 4F);
        lambLeg2 = new ModelRenderer(this, 0, 9);
        lambLeg2.addBox(-1F, 0.0F, -1F, 2, 2, 2, 0.1F);
        lambLeg2.setRotationPoint(2.0F, 18F, 4F);
        lambLeg3 = new ModelRenderer(this, 0, 9);
        lambLeg3.addBox(-1F, 0.0F, -1F, 2, 2, 2, 0.1F);
        lambLeg3.setRotationPoint(-2F, 18F, -3F);
        lambLeg4 = new ModelRenderer(this, 0, 9);
        lambLeg4.addBox(-1F, 0.0F, -1F, 2, 2, 2, 0.1F);
        lambLeg4.setRotationPoint(2.0F, 18F, -3F);
    }

    @Override
    public void render(Entity entity, float par2, float par3, float par4, float par5, float par6, float par7) {
        if (isChild) {
            setRotationAngles(par2, par3, par4, par5, par6, par7, entity);

            lambHead.render(par7);
            lambBody.render(par7);
            lambLeg1.render(par7);
            lambLeg2.render(par7);
            lambLeg3.render(par7);
            lambLeg4.render(par7);
        } else {
            super.render(entity, par2, par3, par4, par5, par6, par7);
        }
    }

    @Override
    public void setRotationAngles(float par1, float par2, float par3, float par4, float par5, float par6, Entity entity) {
        super.setRotationAngles(par1, par2, par3, par4, par5, par6, entity);
        lambHead.rotateAngleX = head.rotateAngleX;
        lambHead.rotateAngleY = head.rotateAngleY;
        lambBody.rotateAngleX = body.rotateAngleX;
        lambLeg1.rotateAngleX = leg1.rotateAngleX;
        lambLeg2.rotateAngleX = leg2.rotateAngleX;
        lambLeg3.rotateAngleX = leg3.rotateAngleX;
        lambLeg4.rotateAngleX = leg4.rotateAngleX;
    }
}

 

ModelNewSheep2:

package com.outlook.siribby.babyanimals.model;

import net.minecraft.client.model.ModelRenderer;
import net.minecraft.client.model.ModelSheep2;
import net.minecraft.entity.Entity;

public class ModelNewSheep2 extends ModelSheep2 {
    public final ModelRenderer lambHead;
    public final ModelRenderer lambBody;
    public final ModelRenderer lambLeg1;
    public final ModelRenderer lambLeg2;
    public final ModelRenderer lambLeg3;
    public final ModelRenderer lambLeg4;

    public ModelNewSheep2() {
        lambHead = new ModelRenderer(this, 0, 0);
        lambHead.addBox(-3F, -2.5F, -3F, 6, 5, 4, 0.0F);
        lambHead.setRotationPoint(0.0F, 13F, -4F);
        lambBody = new ModelRenderer(this, 15, 4);
        lambBody.addBox(-3F, -4.5F, -2.5F, 6, 9, 5, 0.0F);
        lambBody.setRotationPoint(0.0F, 15.5F, 0.0F);
        lambLeg1 = new ModelRenderer(this, 0, 9);
        lambLeg1.addBox(-1F, 0.0F, -1F, 2, 6, 2, 0.0F);
        lambLeg1.setRotationPoint(-2F, 18F, 4F);
        lambLeg2 = new ModelRenderer(this, 0, 9);
        lambLeg2.addBox(-1F, 0.0F, -1F, 2, 6, 2, 0.0F);
        lambLeg2.setRotationPoint(2.0F, 18F, 4F);
        lambLeg3 = new ModelRenderer(this, 0, 9);
        lambLeg3.addBox(-1F, 0.0F, -1F, 2, 6, 2, 0.0F);
        lambLeg3.setRotationPoint(-2F, 18F, -3F);
        lambLeg4 = new ModelRenderer(this, 0, 9);
        lambLeg4.addBox(-1F, 0.0F, -1F, 2, 6, 2, 0.0F);
        lambLeg4.setRotationPoint(2.0F, 18F, -3F);
    }

    @Override
    public void render(Entity entity, float par2, float par3, float par4, float par5, float par6, float par7) {
        if (isChild) {
            setRotationAngles(par2, par3, par4, par5, par6, par7, entity);

            lambHead.render(par7);
            lambBody.render(par7);
            lambLeg1.render(par7);
            lambLeg2.render(par7);
            lambLeg3.render(par7);
            lambLeg4.render(par7);
        } else {
            super.render(entity, par2, par3, par4, par5, par6, par7);
        }
    }

    @Override
    public void setRotationAngles(float par1, float par2, float par3, float par4, float par5, float par6, Entity entity) {
        super.setRotationAngles(par1, par2, par3, par4, par5, par6, entity);
        lambHead.rotateAngleX = head.rotateAngleX;
        lambHead.rotateAngleY = head.rotateAngleY;
        lambBody.rotateAngleX = body.rotateAngleX;
        lambLeg1.rotateAngleX = leg1.rotateAngleX;
        lambLeg2.rotateAngleX = leg2.rotateAngleX;
        lambLeg3.rotateAngleX = leg3.rotateAngleX;
        lambLeg4.rotateAngleX = leg4.rotateAngleX;
    }
}

 

ModelNewWolf:

package com.outlook.siribby.babyanimals.model;

import net.minecraft.client.model.ModelRenderer;
import net.minecraft.client.model.ModelWolf;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.passive.EntityWolf;
import net.minecraft.util.MathHelper;

public class ModelNewWolf extends ModelWolf {
    public final ModelRenderer puppyHead;
    public final ModelRenderer puppyBody;
    public final ModelRenderer puppyRuff;
    public final ModelRenderer puppyLeg1;
    public final ModelRenderer puppyLeg2;
    public final ModelRenderer puppyLeg3;
    public final ModelRenderer puppyLeg4;
    public final ModelRenderer puppyTail;

    public ModelNewWolf() {
        puppyHead = new ModelRenderer(this, 0, 0);
        puppyHead.addBox(-2.5F, -2F, -4F, 5, 4, 4, 0.0F);
        puppyHead.setRotationPoint(0.0F, 17F, -4F);
        puppyBody = new ModelRenderer(this, 8, ;
        puppyBody.addBox(-2.5F, -4F, -2F, 5, 8, 4, 0.0F);
        puppyBody.setRotationPoint(0.0F, 17F, 0.0F);
        puppyRuff = new ModelRenderer(this, 26, 0);
        puppyRuff.addBox(-3.5F, -5F, -3F, 7, 4, 6, -0.5F);
        puppyRuff.setRotationPoint(0.0F, 17F, 0.0F);
        puppyLeg1 = new ModelRenderer(this, 0, ;
        puppyLeg1.addBox(-1F, 0.0F, -1F, 2, 5, 2, 0.0F);
        puppyLeg1.setRotationPoint(-1.5F, 19F, 3F);
        puppyLeg2 = new ModelRenderer(this, 0, ;
        puppyLeg2.addBox(-1F, 0.0F, -1F, 2, 5, 2, 0.0F);
        puppyLeg2.setRotationPoint(1.5F, 19F, 3F);
        puppyLeg3 = new ModelRenderer(this, 0, ;
        puppyLeg3.addBox(-1F, 0.0F, -1F, 2, 5, 2, 0.0F);
        puppyLeg3.setRotationPoint(-1.5F, 19F, -3F);
        puppyLeg4 = new ModelRenderer(this, 0, ;
        puppyLeg4.addBox(-1F, 0.0F, -1F, 2, 5, 2, 0.0F);
        puppyLeg4.setRotationPoint(1.5F, 19F, -3F);
        puppyTail = new ModelRenderer(this, 26, 10);
        puppyTail.addBox(-0.5F, 0.0F, -0.5F, 1, 3, 1, 0.0F);
        puppyTail.setRotationPoint(0.0F, 15.5F, 4F);
        puppyHead.setTextureOffset(14, 0).addBox(-2.5F, -4F, -2F, 2, 2, 1, 0.0F);
        puppyHead.setTextureOffset(14, 0).addBox(0.5F, -4F, -2F, 2, 2, 1, 0.0F);
        puppyHead.setTextureOffset(18, 3).addBox(-1.5F, 0.0F, -5F, 3, 2, 1, 0.0F);
    }

    @Override
    public void render(Entity entity, float par2, float par3, float par4, float par5, float par6, float par7) {
        if (isChild) {
            setRotationAngles(par2, par3, par4, par5, par6, par7, entity);

            puppyHead.renderWithRotation(par7);
            puppyBody.render(par7);
            puppyLeg1.render(par7);
            puppyLeg2.render(par7);
            puppyLeg3.render(par7);
            puppyLeg4.render(par7);
            puppyTail.renderWithRotation(par7);
            puppyRuff.render(par7);
        } else {
            super.render(entity, par2, par3, par4, par5, par6, par7);
        }
    }

    @Override
    public void setLivingAnimations(EntityLivingBase entityLivingBase, float par2, float par3, float par4) {
        super.setLivingAnimations(entityLivingBase, par2, par3, par4);

        EntityWolf entityWolf = (EntityWolf) entityLivingBase;
        puppyTail.rotateAngleY = wolfTail.rotateAngleY;

        if (entityWolf.isSitting()) {
            puppyRuff.setRotationPoint(0.0F, 18.5F, -0F);
            puppyRuff.rotateAngleX = wolfMane.rotateAngleX;
            puppyBody.setRotationPoint(0.0F, 20F, 0.0F);
            puppyBody.rotateAngleX = wolfBody.rotateAngleX;
            puppyTail.setRotationPoint(0.0F, 22.0F, 3.0F);
            puppyLeg1.setRotationPoint(-1.5F, 22F, 1.0F);
            puppyLeg1.rotateAngleX = wolfLeg1.rotateAngleX;
            puppyLeg2.setRotationPoint(1.5F, 22F, 1.0F);
            puppyLeg2.rotateAngleX = wolfLeg2.rotateAngleX;
            puppyLeg3.rotateAngleX = wolfLeg3.rotateAngleX;
            puppyLeg3.setRotationPoint(-1.5F, 19F, -3F);
            puppyLeg4.rotateAngleX = wolfLeg4.rotateAngleX;
            puppyLeg4.setRotationPoint(1.51F, 19F, -3F);
        } else {
            puppyBody.setRotationPoint(0.0F, 17F, 0.0F);
            puppyBody.rotateAngleX = wolfBody.rotateAngleX;
            puppyRuff.setRotationPoint(0.0F, 17F, 0.0F);
            puppyRuff.rotateAngleX = wolfMane.rotateAngleX;
            puppyTail.setRotationPoint(0.0F, 15.5F, 4F);
            puppyLeg1.setRotationPoint(-1.5F, 19F, 3F);
            puppyLeg2.setRotationPoint(1.5F, 19F, 3F);
            puppyLeg3.setRotationPoint(-1.5F, 19F, -3F);
            puppyLeg4.setRotationPoint(1.5F, 19F, -3F);
            puppyLeg1.rotateAngleX = wolfLeg1.rotateAngleX;
            puppyLeg2.rotateAngleX = wolfLeg2.rotateAngleX;
            puppyLeg3.rotateAngleX = wolfLeg3.rotateAngleX;
            puppyLeg4.rotateAngleX = wolfLeg4.rotateAngleX;
        }

        puppyHead.rotateAngleZ = wolfHeadMain.rotateAngleZ;
        puppyRuff.rotateAngleZ = wolfMane.rotateAngleZ;
        puppyBody.rotateAngleZ = wolfBody.rotateAngleZ;
        puppyTail.rotateAngleZ = wolfTail.rotateAngleZ;
    }

    @Override
    public void setRotationAngles(float par1, float par2, float par3, float par4, float par5, float par6, Entity entity) {
        super.setRotationAngles(par1, par2, par3, par4, par5, par6, entity);
        puppyHead.rotateAngleX = wolfHeadMain.rotateAngleX;
        puppyHead.rotateAngleY = wolfHeadMain.rotateAngleY;
        puppyTail.rotateAngleX = wolfTail.rotateAngleX;
    }
}

 

[spoiler=Renderers]RenderNewChicken:

package com.outlook.siribby.babyanimals.renderer;

import com.outlook.siribby.babyanimals.BabyAnimals;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.renderer.entity.RenderChicken;
import net.minecraft.entity.passive.EntityChicken;
import net.minecraft.util.ResourceLocation;

public class RenderNewChicken extends RenderChicken {
    public static final ResourceLocation CHICK_TEXTURES = new ResourceLocation(BabyAnimals.MOD_ID, "textures/entity/chicken.png");

    public RenderNewChicken(ModelBase modelBase, float par2) {
        super(modelBase, par2);
    }

    @Override
    protected ResourceLocation getEntityTexture(EntityChicken entityChicken) {
        if (entityChicken.isChild()) {
            return CHICK_TEXTURES;
        }

        return super.getEntityTexture(entityChicken);
    }
}

 

RenderNewCow:

package com.outlook.siribby.babyanimals.renderer;

import com.outlook.siribby.babyanimals.BabyAnimals;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.renderer.entity.RenderCow;
import net.minecraft.entity.passive.EntityCow;
import net.minecraft.util.ResourceLocation;

public class RenderNewCow extends RenderCow {
    public static final ResourceLocation CALF_TEXTURES = new ResourceLocation(BabyAnimals.MOD_ID, "textures/entity/cow/cow.png");

    public RenderNewCow(ModelBase modelBase, float par2) {
        super(modelBase, par2);
    }

    @Override
    protected ResourceLocation getEntityTexture(EntityCow entityCow) {
        if (entityCow.isChild()) {
            return CALF_TEXTURES;
        }

        return super.getEntityTexture(entityCow);
    }
}

 

RenderNewMooshroom:

package com.outlook.siribby.babyanimals.renderer;

import com.outlook.siribby.babyanimals.BabyAnimals;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.renderer.entity.RenderMooshroom;
import net.minecraft.entity.passive.EntityMooshroom;
import net.minecraft.util.ResourceLocation;

public class RenderNewMooshroom extends RenderMooshroom {
    public static final ResourceLocation CALF_TEXTURES = new ResourceLocation(BabyAnimals.MOD_ID, "textures/entity/cow/mooshroom.png");

    public RenderNewMooshroom(ModelBase modelBase, float par2) {
        super(modelBase, par2);
    }

    @Override
    protected ResourceLocation getEntityTexture(EntityMooshroom entityMooshroom) {
        if (entityMooshroom.isChild()) {
            return CALF_TEXTURES;
        }

        return super.getEntityTexture(entityMooshroom);
    }
}

 

RenderNewPig:

package com.outlook.siribby.babyanimals.renderer;

import com.outlook.siribby.babyanimals.BabyAnimals;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.renderer.entity.RenderPig;
import net.minecraft.entity.passive.EntityPig;
import net.minecraft.util.ResourceLocation;

public class RenderNewPig extends RenderPig {
    public static final ResourceLocation PIGLET_TEXTURES = new ResourceLocation(BabyAnimals.MOD_ID, "textures/entity/pig.png");

    public RenderNewPig(ModelBase modelBase1, ModelBase modelBase2, float par3) {
        super(modelBase1, modelBase2, par3);
    }

    @Override
    protected ResourceLocation getEntityTexture(EntityPig entityPig) {
        if (entityPig.isChild()) {
            return PIGLET_TEXTURES;
        }

        return super.getEntityTexture(entityPig);
    }
}

 

Posted

It's a client-side mod, so the renderers are registered in the mod file.

Then post code where it is registered...

Look at his main mod file. He doesn't actually register any renderers, but he cancels the vanilla rendering and renders his own instead.

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Posted

Oops, didn't see that, sorry.

You are calling method that is causing crash on line 16 in BabyAnimals.renderEntity;

Can you post BabyAnimals.class and specially that renderEntity method please, because only null arg that 'can' be on line 525 in RendererLivingEntity.func_110813_b, is entity...

Posted

The main mod file is BabyAnimals.java. I've already checked that the entity isn't null by printing into the console.

 

(I've already posted all of my code in this thread.)

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.

Announcements



×
×
  • Create New...

Important Information

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