Jump to content

Mooshroom Mushrooms on back


SilasOtoko

Recommended Posts

Well I found where the code is. Now I am only having issues with my custom mob rendering. It spawns in the world, but it is invisible, and somehow it is overlapping with my custom throwable item, because it shows the image of the item in place of the mob texture.

 

Render

@SideOnly(Side.CLIENT)
public class RenderEnt extends RenderLiving
{
/** Iron Golem's Model. */
    protected ModelEnt ModelEnt;

    public RenderEnt(ModelEnt model, float f)
    {
        super(new ModelEnt(), 0.5F);
        model = (ModelEnt)mainModel;
    }

    public void renderLivingEnt(EntityEnt par1EntityEnt, double par2, double par4, double par6, float par8, float par9)
    {
        super.doRenderLiving(par1EntityEnt, par2, par4, par6, par8, par9);
    }

    protected void renderEntEquippedItems(EntityEnt par1EntityEnt, float par2)
    {
        super.renderEquippedItems(par1EntityEnt, par2);

        if (!par1EntityEnt.isChild())
        {
            this.loadTexture("/terrain.png");
            GL11.glEnable(GL11.GL_CULL_FACE);
            GL11.glPushMatrix();
            GL11.glScalef(1.0F, -1.0F, 1.0F);
            GL11.glTranslatef(0.2F, 0.4F, 0.5F);
            GL11.glRotatef(42.0F, 0.0F, 1.0F, 0.0F);
            this.renderBlocks.renderBlockAsItem(Block.sapling, 0, 1.0F);
            GL11.glTranslatef(0.1F, 0.0F, -0.6F);
            GL11.glRotatef(42.0F, 0.0F, 1.0F, 0.0F);
            this.renderBlocks.renderBlockAsItem(Block.sapling, 0, 1.0F);
            GL11.glPopMatrix();
            GL11.glPushMatrix();
            ((ModelQuadruped)this.mainModel).head.postRender(0.0625F);
            GL11.glScalef(1.0F, -1.0F, 1.0F);
            GL11.glTranslatef(0.0F, 0.75F, -0.2F);
            GL11.glRotatef(12.0F, 0.0F, 1.0F, 0.0F);
            this.renderBlocks.renderBlockAsItem(Block.sapling, 0, 1.0F);
            GL11.glPopMatrix();
            GL11.glDisable(GL11.GL_CULL_FACE);
        }
    }

    protected void renderEquippedItems(EntityLiving par1EntityLiving, float par2)
    {
        this.renderEntEquippedItems((EntityEnt)par1EntityLiving, par2);
    }

    public void doRenderLiving(EntityLiving par1EntityLiving, double par2, double par4, double par6, float par8, float par9)
    {
        this.renderLivingEnt((EntityEnt)par1EntityLiving, par2, par4, par6, par8, par9);
    }

    /**
     * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then
     * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic
     * (Render<T extends Entity) and this method has signature public void doRender(T entity, double d, double d1,
     * double d2, float f, float f1). But JAD is pre 1.5 so doesn't do that.
     */
    public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9)
    {
        this.renderLivingEnt((EntityEnt)par1Entity, par2, par4, par6, par8, par9);
    }
}

 

Entity

public class EntityEnt extends EntityMob {
public EntityEnt(World par1World){
	super(par1World);
        this.texture = "/mob/villager_golem.png";
        this.setSize(1.4F, 2.9F);
        this.getNavigator().setAvoidsWater(true);
        this.tasks.addTask(1, new EntityAIAttackOnCollide(this, 0.25F, true));
        this.tasks.addTask(2, new EntityAIMoveTowardsTarget(this, 0.22F, 32.0F));
        this.tasks.addTask(4, new EntityAIMoveTwardsRestriction(this, 0.16F));
        this.tasks.addTask(5, new EntityAIWander(this, 0.16F));
        this.tasks.addTask(6, new EntityAIWatchClosest(this, EntityPlayer.class, 6.0F));
        this.tasks.addTask(7, new EntityAILookIdle(this));
        this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, false));
}

public String getTexture()
{
	return "/mob/villager_golem.png";
}
@Override
public int getMaxHealth() {
	return 100;
}

/**
     * Returns true if the newer Entity AI code should be run
     */
    public boolean isAIEnabled()
    {
        return true;
    }
    
    /**
     * Decrements the entity's air supply when underwater
     */
    protected int decreaseAirSupply(int par1)
    {
        return par1;
    }
    
    /**
     * Returns the sound this mob makes while it's alive.
     */
    protected String getLivingSound()
    {
        return "none";
    }
    
    /**
     * Returns the sound this mob makes when it is hurt.
     */
    protected String getHurtSound()
    {
        return "mob.irongolem.hit";
    }

    /**
     * Returns the sound this mob makes on death.
     */
    protected String getDeathSound()
    {
        return "mob.irongolem.death";
    }
    
    /**
     * Plays step sound at given x, y, z for the entity
     */
    protected void playStepSound(int par1, int par2, int par3, int par4)
    {
        this.playSound("mob.irongolem.walk", 1.0F, 1.0F);
    }
    
    /**
     * Drop 0-2 items of this living's type. @param par1 - Whether this entity has recently been hit by a player. @param
     * par2 - Level of Looting used to kill this mob.
     */
    protected void dropFewItems(boolean par1, int par2)
    {
        int j = this.rand.nextInt(3);
        int k;

        for (k = 0; k < j; ++k)
        {
            this.dropItem(TutorialMod.EarthRune.itemID, 1);
        }

        k = 3 + this.rand.nextInt(3);

        for (int l = 0; l < k; ++l)
        {
            this.dropItem(TutorialMod.SilverNugget.itemID, 4);
        }
    }

}

 

Main Class Custom Registers

GameRegistry.registerWorldGenerator(new WorldGeneratorJosiah());

	EntityRegistry.registerModEntity(EntityCreeperHeart.class, "CreeperHeart", 1, this, 80, 3, true);
    LanguageRegistry.instance().addStringLocalization("entity.CreeperHeart.name", "CreeperHeart");
    
    RenderingRegistry.registerEntityRenderingHandler(EntityCreeperHeart.class, new RenderCreeperHeart(TutorialMod.CreeperHeart));
    EntityRegistry.registerModEntity(EntityEnt.class, "Ent", 1, this, 40, 1, true);
    EntityRegistry.addSpawn(EntityEnt.class, 10, 1, 7, EnumCreatureType.monster, BiomeGenBase.beach, BiomeGenBase.extremeHills, BiomeGenBase.extremeHillsEdge, BiomeGenBase.forest, BiomeGenBase.forestHills, BiomeGenBase.jungle, BiomeGenBase.jungleHills, BiomeGenBase.mushroomIsland, BiomeGenBase.mushroomIslandShore, BiomeGenBase.ocean, BiomeGenBase.plains, BiomeGenBase.river, BiomeGenBase.swampland);
    LanguageRegistry.instance().addStringLocalization("entity.Josiah.FirstMod_TutorialMod.Tutorial.name", "Ent");
    RenderingRegistry.registerEntityRenderingHandler(EntityEnt.class, new RenderEnt(new ModelEnt(), 0.5F));
    

Link to comment
Share on other sites

Man, i see wrong code everywhere... :'(

 

Let's begin with

public RenderEnt(ModelEnt model, float f)
    {
        super(new ModelEnt(), 0.5F);
        model = (ModelEnt)mainModel;
    }

that is one stupid constructor. Fix needed.

then

((ModelQuadruped)this.mainModel).head.postRender(0.0625F);

i am pretty sure your model isn't a ModelQuadruped, but who knows ?

finally

EntityRegistry.registerModEntity(EntityCreeperHeart.class, "CreeperHeart", 1, this, 80, 3, true);
    LanguageRegistry.instance().addStringLocalization("entity.CreeperHeart.name", "CreeperHeart");
    
    RenderingRegistry.registerEntityRenderingHandler(EntityCreeperHeart.class, new RenderCreeperHeart(TutorialMod.CreeperHeart));
    EntityRegistry.registerModEntity(EntityEnt.class, "Ent", 1, this, 40, 1, true);

both entities have same id, and the rendering should only be registered on client side.

Link to comment
Share on other sites

Try to take it a little easy on me. This is my first minecraft mod and I am just trying out everything to do a trial and error method of figuring out what works. I am a kinesthetic learner so I learn best by doing. I fixed the first problem with the constructor, something which I copied from a tutorial example online, and since my mod is a biped I removed the Quadrupled bit. The last problem with the Entity ID is fixed but I'm not sure what I need to change to render it only on client side?

 

By the way the rendering of the items on top of my model works if anyone was wondering. It's the same way that Mushrooms are on the back of the mooshroom. Only thing is that the details of the placement need to be changed to suit your specific model. I didn't change it on mine because that's a little beyond what I know how to do and the way it turned out on my model suits me just fine.

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.

Announcements



×
×
  • Create New...

Important Information

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