Jump to content

Entity Modding- ClientProxy and Render class errors


Anuwa

Recommended Posts

Hello,

I am sorry if the topic discussion/location is misleading in any way, this is my first post here.

To the point:

I am trying to create an entity using Eclipse and forge (Minecraft version 1.7.2). I have created the Entity class correctly, as well as registered it, because on test launching I successfully created a white box that panics like heck. I wanted to give it a model, so I followed a tutorial on creating the Render class, the Model class, and editing the ClientProxy class. That is where I am stumped, completely. Basically, when I try to do the RenderingRegistry.registerEntityRenderingHandler code, it errors saying its not applicable.

This is the ClientProxy class:

 

package anuwa.modGorebiscus.client;

import net.minecraft.entity.Entity;
import cpw.mods.fml.client.registry.RenderingRegistry;
import anuwa.modGorebiscus.EntityGorebiscus;
import anuwa.modGorebiscus.ModelGorebiscus;
import anuwa.modGorebiscus.RenderGorebiscus;
import anuwa.modGorebiscus.ServerProxy;

public class ClientProxy extends ServerProxy {
        
	@Override
	public void registerRenderThings() {
		RenderingRegistry.registerEntityRenderingHandler(EntityGorebiscus.class, new RenderGorebiscus(new ModelGorebiscus(), 0.0F));
        }
        
}

 

 

I also have an error in the EntityRender class. For some reason, the last part of code says "Cannot cast from Entity to Entity Gorebiscus"

This is the code:

 

package anuwa.modGorebiscus;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.renderer.entity.RenderLiving;
import net.minecraft.entity.Entity;
import anuwa.modGorebiscus.EntityGorebiscus;
import net.minecraft.util.ResourceLocation;

@SideOnly(Side.CLIENT)
public class RenderGorebiscus extends RenderLiving
{
    private static final ResourceLocation mobTextures = new ResourceLocation(Strings.MODID + ":" + "entityGorebiscus");
    private static final String __OBFID = "CL_00000984";

    public RenderGorebiscus(ModelGorebiscus par1ModelGorebiscus, float par2)
    {
        super(par1ModelGorebiscus, par2);
    }

    /**
     * Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture.
     */
    protected ResourceLocation getEntityTexture(EntityGorebiscus par1EntityGorebiscus)
    {
        return mobTextures;
    }

    /**
     * Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture.
     */
    protected ResourceLocation getEntityTexture(Entity par1Entity)
    {
        return this.getEntityTexture((EntityGorebiscus)par1Entity);
    }
}

 

 

And heres the Entity class just in case:

 

package anuwa.modGorebiscus;

import net.minecraft.entity.EntityList;
import net.minecraft.entity.EnumCreatureType;
import net.minecraft.world.biome.BiomeGenBase;
import anuwa.modGorebiscus.modGorebiscus;
import cpw.mods.fml.common.registry.EntityRegistry;

public class EntityGorebiscus {

public static void mainRegistry() {
	registerEntity();
}

public static void registerEntity() {

	createEntity(EntityGorebiscusMob.class, "Gorebiscus", 0xFFFFFF, 0x7A0000);

}

public static void createEntity(Class entityClass, String entityName, int solidColor, int spotColor) {
	int randomId = EntityRegistry.findGlobalUniqueEntityId();
	EntityRegistry.registerGlobalEntityID(entityClass, entityName, randomId);
	EntityRegistry.registerModEntity(entityClass, entityName, randomId, modGorebiscus.modInstance, 64, 1, true);
	EntityRegistry.addSpawn(entityClass, 3, 0, 1, EnumCreatureType.creature, BiomeGenBase.plains);
	createEgg(randomId, solidColor, spotColor);
}

private static void createEgg(int randomId, int solidColor, int spotColor) {
	EntityList.entityEggs.put(Integer.valueOf(randomId), new EntityList.EntityEggInfo(randomId, solidColor, spotColor));
}

}

 

 

And the main mod class:

 

package anuwa.modGorebiscus;

import java.util.Random;

import net.minecraft.block.Block;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityList;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler; // used in 1.6.2
//import cpw.mods.fml.common.Mod.PreInit;    // used in 1.5.2
//import cpw.mods.fml.common.Mod.Init;       // used in 1.5.2
//import cpw.mods.fml.common.Mod.PostInit;   // used in 1.5.2
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.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.registry.EntityRegistry;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;
import anuwa.modGorebiscus.EntityGorebiscus;

//import cpw.mods.fml.common.network.NetworkMod; // not used in 1.7

@Mod(modid = Strings.MODID, name = Strings.name, version = Strings.version)
//@NetworkMod(clientSideRequired=true) // not used in 1.7
public class modGorebiscus {

	public static final String modid = "gorebiscus";


        // The instance of your mod that Forge uses.
        @Instance(Strings.MODID)
        public static modGorebiscus modInstance;
        
        // Says where the client and server 'proxy' code is loaded.
        @SidedProxy(clientSide="anuwa.modGorebiscus.client.ClientProxy", serverSide="tutorial.modGorebiscus.ServerProxy")
        public static ServerProxy proxy;
        
        public static Item ItemRuby;
        public static Block OreRuby;
        public static CreativeTabs tabGorebiscus = new CreativeTabsGorebiscus("Gorebiscus");
        
        @EventHandler // used in 1.6.2
        //@PreInit    // used in 1.5.2
        public void preInit(FMLPreInitializationEvent event) {
        		EntityGorebiscus.mainRegistry();
                ItemRuby = new ItemRuby().setUnlocalizedName("ItemRuby").setTextureName(Strings.MODID + ":" + "itemRuby");
                OreRuby = new OreRuby().setBlockName("OreRuby");
                GameRegistry.registerItem(ItemRuby, ItemRuby.getUnlocalizedName().substring(5));
                GameRegistry.registerBlock(OreRuby, OreRuby.getUnlocalizedName().substring(5));
                proxy.registerRenderThings();
        }
        
        @EventHandler // used in 1.6.2
        //@Init       // used in 1.5.2
        public void load(FMLInitializationEvent event) {
            proxy.registerRenderThings();
        }
        
        @EventHandler // used in 1.6.2
        //@PostInit   // used in 1.5.2
        public void postInit(FMLPostInitializationEvent event) {
                // Stub Method
        }
        
}

 

 

If it helps, the Model class:

 

package anuwa.modGorebiscus;

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

public class ModelGorebiscus extends ModelBase
{
  //fields
    ModelRenderer head;
    ModelRenderer body;
    ModelRenderer leg3;
    ModelRenderer leg4;
    ModelRenderer tail1;
    ModelRenderer tail2;
    ModelRenderer tail3;
    ModelRenderer tail4;
    ModelRenderer tail5;
    ModelRenderer haunch1;
    ModelRenderer leg1;
    ModelRenderer haunch2;
    ModelRenderer leg2;
  
  public ModelGorebiscus()
  {
    textureWidth = 64;
    textureHeight = 128;
    
      head = new ModelRenderer(this, 0, 0);
      head.addBox(-4F, -4F, -6F, 6, 6, 6);
      head.setRotationPoint(1F, 6F, -7F);
      head.setTextureSize(64, 128);
      head.mirror = true;
      setRotation(head, 0F, 0F, 0F);
      body = new ModelRenderer(this, 0, 12);
      body.addBox(-6F, -10F, -7F, 8, 19, 5);
      body.setRotationPoint(2F, 8F, 3F);
      body.setTextureSize(64, 128);
      body.mirror = true;
      setRotation(body, 1.308997F, 0F, 0F);
      leg3 = new ModelRenderer(this, 26, 18);
      leg3.addBox(-3F, 0F, -3F, 3, 12, 3);
      leg3.setRotationPoint(-0.9F, 12F, -5F);
      leg3.setTextureSize(64, 128);
      leg3.mirror = true;
      setRotation(leg3, 0F, 0F, 0F);
      leg4 = new ModelRenderer(this, 38, 18);
      leg4.addBox(-1F, 0F, -3F, 3, 12, 3);
      leg4.setRotationPoint(1.9F, 12F, -5F);
      leg4.setTextureSize(64, 128);
      leg4.mirror = true;
      setRotation(leg4, 0F, 0F, 0F);
      tail1 = new ModelRenderer(this, 0, 36);
      tail1.addBox(0F, 0F, 0F, 1, 1, ;
      tail1.setRotationPoint(0F, 13F, 10F);
      tail1.setTextureSize(64, 128);
      tail1.mirror = true;
      setRotation(tail1, -0.2617994F, 0F, 0F);
      tail2 = new ModelRenderer(this, 18, 36);
      tail2.addBox(0F, 0F, 0F, 1, 1, ;
      tail2.setRotationPoint(0F, 15F, 17F);
      tail2.setTextureSize(64, 128);
      tail2.mirror = true;
      setRotation(tail2, 0.2617994F, 0F, 0F);
      tail3 = new ModelRenderer(this, 36, 36);
      tail3.addBox(0F, 0F, 0F, 1, 1, ;
      tail3.setRotationPoint(0F, 14F, 24F);
      tail3.setTextureSize(64, 128);
      tail3.mirror = true;
      setRotation(tail3, 2.094395F, 0F, 0F);
      tail4 = new ModelRenderer(this, 54, 36);
      tail4.addBox(0F, 0F, 0F, 1, 1, 2);
      tail4.setRotationPoint(0F, 6F, 19F);
      tail4.setTextureSize(64, 128);
      tail4.mirror = true;
      setRotation(tail4, 0F, 0F, 0F);
      tail5 = new ModelRenderer(this, 60, 36);
      tail5.addBox(0F, 0F, 0F, 1, 2, 1);
      tail5.setRotationPoint(0F, 6F, 18F);
      tail5.setTextureSize(64, 128);
      tail5.mirror = true;
      setRotation(tail5, 0F, 0F, 0F);
      haunch1 = new ModelRenderer(this, 26, 0);
      haunch1.addBox(-3F, 0F, -2F, 3, 6, 3);
      haunch1.setRotationPoint(-0.9F, 15F, 7F);
      haunch1.setTextureSize(64, 128);
      haunch1.mirror = true;
      setRotation(haunch1, -0.5061455F, 0F, 0F);
      leg1 = new ModelRenderer(this, 26, 9);
      leg1.addBox(0F, 0F, 0F, 3, 6, 3);
      leg1.setRotationPoint(-3.8F, 20F, 3F);
      leg1.setTextureSize(64, 128);
      leg1.mirror = true;
      setRotation(leg1, 0.5061455F, 0F, 0F);
      haunch2 = new ModelRenderer(this, 38, 0);
      haunch2.addBox(-1F, 0F, -2F, 3, 6, 3);
      haunch2.setRotationPoint(1.9F, 15F, 7F);
      haunch2.setTextureSize(64, 128);
      haunch2.mirror = true;
      setRotation(haunch2, -0.5061455F, 0F, 0F);
      leg2 = new ModelRenderer(this, 38, 9);
      leg2.addBox(0F, 0F, 0F, 3, 6, 3);
      leg2.setRotationPoint(0.8F, 20F, 3F);
      leg2.setTextureSize(64, 128);
      leg2.mirror = true;
      setRotation(leg2, 0.5061455F, 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);
    head.render(f5);
    body.render(f5);
    leg3.render(f5);
    leg4.render(f5);
    tail1.render(f5);
    tail2.render(f5);
    tail3.render(f5);
    tail4.render(f5);
    tail5.render(f5);
    haunch1.render(f5);
    leg1.render(f5);
    haunch2.render(f5);
    leg2.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)
  {
    super.setRotationAngles(f, f1, f2, f3, f4, f5, null);
  }

}

 

 

The model was made in Techne.

Thank you in advance, and once again, I apologize for anything wrong I did.

"A fight is going on inside me. It is a terrible fight, and it is between two Wolves. One is evil... He is Anger, Envy, Sorrow, Regret, Greed, Arrogance, Self-Pity, Guilt, Resentment, Lies, False Pride, and Superiority -- and Ego. The other is Good... He is Joy, Peace, Love, Hope, Serenity, Humility, Kindness, Benevolence, Empathy, Generosity, Truth, Compassion -- and Faith. The same fight is going on inside you, and inside every other person, too."

"But Papa, which Wolf will win?"

"The One you feed."

Link to comment
Share on other sites

Hm... I seem to be just one step ahead of you. I used different methods and got no errors, but my Penguin only renders as a textureless white rectangular prism. Feel free to check out mine to see how to fix your errors. (It's the post right below!)

Developer of small, unreleased, basic, and incomplete mods since 2014!

Link to comment
Share on other sites

I looked at your post and I don't see how it was fixed.

"A fight is going on inside me. It is a terrible fight, and it is between two Wolves. One is evil... He is Anger, Envy, Sorrow, Regret, Greed, Arrogance, Self-Pity, Guilt, Resentment, Lies, False Pride, and Superiority -- and Ego. The other is Good... He is Joy, Peace, Love, Hope, Serenity, Humility, Kindness, Benevolence, Empathy, Generosity, Truth, Compassion -- and Faith. The same fight is going on inside you, and inside every other person, too."

"But Papa, which Wolf will win?"

"The One you feed."

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.