Jump to content

Rendering issues and curiosity question


wog890

Recommended Posts

So I'm going to start off with my main issue. I'm working on adding a penguin into the game to begin learning basic AI and all that good stuff. I've been following the tutorial by  Wuppy 29, but he has left out the last part about the actual Model file. I attempted to work this out myself (and checked out other tutorials and minecraft source code) but have not been able to figure it out. My entity is rendering, but it comes out as a humanoid (which I assume is the default and looks really weird since my penguin texture doesn't fit a humanoid model) I put some trace lines in my Model code, but it never gets triggered, so I'm assuming the ModelPenguin class isn't being used.

 

If it isn't to much to ask for, I'd appreciate it if someone would check my code below and inform me of what I am missing. Thanks for your help!

 

Main mod file

 

 

 

package wogCreeperSheep.common;

import java.util.Map;

import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityEggInfo;
import net.minecraft.entity.EntityList;
import net.minecraft.entity.EnumCreatureType;
import net.minecraft.world.biome.BiomeGenBase;
import wogCreeperSheep.common.core.WCSCommonProxy;
import wogCreeperSheep.common.entities.EntityPenguin;
import wogCreeperSheep.common.entities.ModelPenguin;
import wogCreeperSheep.common.entities.RenderPenguin;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.Init;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.network.NetworkMod;
import cpw.mods.fml.common.registry.EntityRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;

@NetworkMod(clientSideRequired = true, serverSideRequired = false)
@Mod(modid = "wog890_WogCreeperSheep", name = "Wog Creeper Sheep", version = "0.1.0")
public class WogCreeperSheep {

@Instance("wog890_WogCreeperSheep")
public static WogCreeperSheep instance;

public static final String MAIN_PATH = "/wogTextures/";
public static final String ENTITIES_PATH = MAIN_PATH + "wogEntities/";
public static final String PENGUIN_PATH = ENTITIES_PATH + "PenguinEntity.png";

public static int startEntityId = 400;

@SidedProxy(clientSide = "wogCreeperSheep.common.core.WCSClientProxy", serverSide = "wogCreeperSheep.common.core.WCSCommonProxy")
public static WCSCommonProxy proxy;

@Init
public void load(FMLInitializationEvent event) {
	proxy.registerRenderInformation();

	EntityRegistry.registerModEntity(EntityPenguin.class, "Penguin", 1, this, 80, 3, true);
	EntityRegistry.addSpawn(EntityPenguin.class, 10, 2, 8, EnumCreatureType.creature, BiomeGenBase.frozenOcean,
		BiomeGenBase.frozenRiver, BiomeGenBase.iceMountains, BiomeGenBase.icePlains, BiomeGenBase.taiga,
		BiomeGenBase.taigaHills);

	LanguageRegistry.instance().addStringLocalization("entity.wog890_WogCreeperSheep.Penguin.name", "Penguin");

	registerEntityEgg(EntityPenguin.class, 0x000000, 0xffffff);
}

public void addRenderer(Map map) {
	map.put(EntityPenguin.class, new RenderPenguin(new ModelPenguin(), 0.5f));
}

public static void registerEntityEgg(Class<? extends Entity> entity, int primaryColor, int secondaryColor) {
	int id = getUniqueEntityId();
	EntityList.IDtoClassMapping.put(id, entity);
	EntityList.entityEggs.put(id, new EntityEggInfo(id, primaryColor, secondaryColor));
}

public static int getUniqueEntityId() {
	do {
		startEntityId++;
	}
	while (EntityList.getStringFromID(startEntityId) != null);

	return startEntityId;
}

}

 

 

 

 

EntityPenguin.class

 

 

 

package wogCreeperSheep.common.entities;

import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityAgeable;
import net.minecraft.entity.EnumCreatureAttribute;
import net.minecraft.entity.ai.EntityAIFollowOwner;
import net.minecraft.entity.ai.EntityAISwimming;
import net.minecraft.entity.ai.EntityAIWander;
import net.minecraft.entity.passive.EntityTameable;
import net.minecraft.world.World;
import wogCreeperSheep.common.WogCreeperSheep;

public class EntityPenguin extends EntityTameable {

private float field_70926_e;
private float field_70924_f;

public EntityPenguin(World world) {
	super(world);
	texture = WogCreeperSheep.instance.PENGUIN_PATH;
	moveSpeed = 0.25F;
	tasks.addTask(0, new EntityAISwimming(this));
	tasks.addTask(1, new EntityAIFollowOwner(this, moveSpeed, 10.0F, 2.0F));
	tasks.addTask(2, new EntityAIWander(this, moveSpeed));
}

@Override
public EnumCreatureAttribute getCreatureAttribute() {
	return EnumCreatureAttribute.UNDEFINED;
}

@Override
public void onLivingUpdate() {
	super.onLivingUpdate();
}

@Override
public boolean isAIEnabled() {
	return true;
}

@Override
public EntityAgeable func_90011_a(EntityAgeable entityAgeable) {
	return null;
}

@Override
public int getMaxHealth() {
	return 4;
}

@Override
public String getTexture() {
	return WogCreeperSheep.instance.PENGUIN_PATH;
}

@Override
protected String getLivingSound() {
	return null;
}

@Override
protected String getHurtSound() {
	return null;
}

@Override
protected String getDeathSound() {
	return null;
}

}

 

 

 

 

RenderPenguin.class

 

 

 

package wogCreeperSheep.common.entities;

import net.minecraft.client.renderer.entity.RenderLiving;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;

public class RenderPenguin extends RenderLiving {

protected ModelPenguin model;

public RenderPenguin(ModelPenguin penguin, float f) {
	super(penguin, f);
	model = ((ModelPenguin)mainModel);
}

public void renderPenguin(EntityPenguin entity, double par2, double par3, double par4, float par5, float par6) {
	super.doRenderLiving(entity, par2, par3, par4, par5, par6);
}

public void doRenderLiving(EntityLiving entity, double par2, double par3, double par4, float par5, float par6) {
	renderPenguin((EntityPenguin)entity, par2, par3, par4, par5, par6);
}

public void doRender(Entity entity, double par2, double par3, double par4, float par5, float par6) {
	renderPenguin((EntityPenguin)entity, par2, par3, par4, par5, par6);
}

}

 

 

 

 

ModelPenguin.class

 

 

 

package wogCreeperSheep.common.entities;

import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;

public class ModelPenguin extends ModelBase {
  //fields
    ModelRenderer RightFoot;
    ModelRenderer LeftFoot;
    ModelRenderer Body;
    ModelRenderer Head;
    ModelRenderer Beak;
    ModelRenderer RightWing;
    ModelRenderer LeftWing;
  
  public ModelPenguin()
  {
    textureWidth = 64;
    textureHeight = 32;
    
      RightFoot = new ModelRenderer(this, 25, 21);
      RightFoot.addBox(0F, 0F, 0F, 2, 1, 2);
      RightFoot.setRotationPoint(-1F, 23F, 0.5F);
      RightFoot.setTextureSize(64, 32);
      RightFoot.mirror = true;
      setRotation(RightFoot, 0F, 0F, 0F);
      LeftFoot = new ModelRenderer(this, 25, 21);
      LeftFoot.addBox(0F, 0F, 0F, 2, 1, 2);
      LeftFoot.setRotationPoint(-1F, 23F, -2.5F);
      LeftFoot.setTextureSize(64, 32);
      LeftFoot.mirror = true;
      setRotation(LeftFoot, 0F, 0F, 0F);
      Body = new ModelRenderer(this, 0, 0);
      Body.addBox(0F, 0F, 0F, 6, 9, 6);
      Body.setRotationPoint(-3F, 14F, -3F);
      Body.setTextureSize(64, 32);
      Body.mirror = true;
      setRotation(Body, 0F, 0F, 0F);
      Head = new ModelRenderer(this, 0, 16);
      Head.addBox(0F, 0F, 0F, 6, 6, 6);
      Head.setRotationPoint(-3F, 8F, -3F);
      Head.setTextureSize(64, 32);
      Head.mirror = true;
      setRotation(Head, 0F, 0F, 0F);
      Beak = new ModelRenderer(this, 25, 0);
      Beak.addBox(0F, 0F, 0F, 3, 2, 2);
      Beak.setRotationPoint(-6F, 11F, -1F);
      Beak.setTextureSize(64, 32);
      Beak.mirror = true;
      setRotation(Beak, 0F, 0F, 0F);
      RightWing = new ModelRenderer(this, 25, 5);
      RightWing.addBox(0F, 0F, 0F, 4, 6, 1);
      RightWing.setRotationPoint(-2F, 14F, 3F);
      RightWing.setTextureSize(64, 32);
      RightWing.mirror = true;
      setRotation(RightWing, 0F, 0F, 0F);
      LeftWing = new ModelRenderer(this, 25, 13);
      LeftWing.addBox(0F, 0F, 0F, 4, 6, 1);
      LeftWing.setRotationPoint(-2F, 14F, -4F);
      LeftWing.setTextureSize(64, 32);
      LeftWing.mirror = true;
      setRotation(LeftWing, 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);
    
    if (isChild) {
    	RightFoot.render(f5);
        LeftFoot.render(f5);
        Body.render(f5);
        Head.render(f5);
        Beak.render(f5);
        RightWing.render(f5);
        LeftWing.render(f5);
    }
    else {
    	RightFoot.render(f5);
        LeftFoot.render(f5);
        Body.render(f5);
        Head.render(f5);
        Beak.render(f5);
        RightWing.render(f5);
        LeftWing.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);
  
  }

}

 

 

 

 

My second question is for a future idea, (if I ever get this penguin working). Simply put, I want to be able to breed sheep and creepers together. I know it sounds weird but it because of a friend. I know that editing the base files of Minecraft is generally frowned upon so is this even possible?

Link to comment
Share on other sites

public void addRenderer(Map map) {

  map.put(EntityPenguin.class, new RenderPenguin(new ModelPenguin(), 0.5f));

  }

totaly wrong, this must be

 

 

RenderingRegistry.registerEntityRenderingHandler(EntityPenguin.class, new RenderPenguin(new ModelPenguin(), 0.5f)); //and must go in the client proxy...

 

 

and for 2 question i know there is way, but i cant look now because my pc its off, and eclipse dont work in tablets.

Link to comment
Share on other sites

public void addRenderer(Map map) {

  map.put(EntityPenguin.class, new RenderPenguin(new ModelPenguin(), 0.5f));

  }

totaly wrong, this must be

Hidden

RenderingRegistry.registerEntityRenderingHandler(EntityPenguin.class, new RenderPenguin(new ModelPenguin(), 0.5f)); //and must go in the client proxy...

and for 2 question i know there is way, but i cant look now because my pc its off, and eclipse dont work in tablets.

 

Ah, thank you sir/mam, I forgot to remove that function from one of the extra tutorials I was trying. I will try that function, but first I'll have to look into making a proxy (I've avoided it for stupid reasons, hahahahaha) Thank you so much for the help. If you can help with the second question I would appreciate it, but it is no rush since I have to get this penguin working first anyways

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.