Jump to content

Recommended Posts

Posted

Hi everyone! It's my first time writing a post here so i hope i'll do it right. Anyway, i please ask you some help with a mob that i'm making. The mob is a crab, i already have the model, the texture and all the java stuff to spawn it, render it ec... but when i spawn it it goes underground, it passes blocks like they're made of air, and i don't understand why becuase i made another mob and everything goes fine, i've just copy the file from the other mob, except for the model, and change it to work with the crab..... Here's the files i use for this mob, please help me to find where is the problem becuase i can't really find it....

 

Main Class

package mod_mobs;

import mod_mobs.entities.EntityCrab;
import mod_mobs.entities.EntityGhost;
import mod_mobs.items.CustomSpawner;
import mod_mobs.models.ModelCrab;
import mod_mobs.models.ModelGhost;
import mod_mobs.proxy.CommonProxy;
import mod_mobs.render.RenderCrab;
import mod_mobs.render.RenderGhost;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityEggInfo;
import net.minecraft.entity.EntityList;
import net.minecraft.entity.EnumCreatureType;
import net.minecraft.item.Item;
import net.minecraft.world.biome.BiomeGenBase;
import cpw.mods.fml.client.registry.RenderingRegistry;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
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;



@Mod(modid = "mod_mobs", name = "Mobs", version = "1.0")
@NetworkMod(clientSideRequired = true, serverSideRequired = false)
public class main {
public static final String modId = "mod_mobs";

@SidedProxy(clientSide = "mod_mobs.proxy.ClientProxy", serverSide = "mod_mobs.proxy.CommonProxy")

//DICHIARAZIONI
//PROXY
public static CommonProxy proxy;

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

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 Item customSpawner;

//CARICAMENTO
@EventHandler
public void Init(FMLInitializationEvent event)
 {

	//PROXY
	proxy.registerRenderThings();
	//GHOST
	EntityRegistry.registerGlobalEntityID(EntityGhost.class, "Ghost", 1);
	EntityRegistry.addSpawn(EntityGhost.class, 10, 2, 4, EnumCreatureType.monster);
	EntityRegistry.addSpawn(EntityGhost.class, 10, 2, 4, EnumCreatureType.monster, mod_plants.main.AppleBiome);
	EntityRegistry.addSpawn(EntityGhost.class, 10, 2, 4, EnumCreatureType.monster, mod_plants.main.arctic);
	EntityRegistry.addSpawn(EntityGhost.class, 10, 2, 4, EnumCreatureType.monster, mod_plants.main.DeadForest);
	EntityRegistry.addSpawn(EntityGhost.class, 10, 2, 4, EnumCreatureType.monster, mod_plants.main.mesa);
	EntityRegistry.addSpawn(EntityGhost.class, 10, 2, 4, EnumCreatureType.monster, mod_plants.main.palms);
	EntityRegistry.addSpawn(EntityGhost.class, 10, 2, 4, EnumCreatureType.monster, mod_plants.main.SnowHills);
	EntityRegistry.addSpawn(EntityGhost.class, 10, 2, 4, EnumCreatureType.monster, mod_plants.main.volcano);


	//CRAB
	EntityRegistry.registerGlobalEntityID(EntityCrab.class, "Crab", 2);
	EntityRegistry.addSpawn(EntityCrab.class, 10, 2, 4, EnumCreatureType.creature, BiomeGenBase.beach);
	EntityRegistry.addSpawn(EntityCrab.class, 10, 2, 4, EnumCreatureType.creature, mod_plants.main.palms);


	EntityRegistry.findGlobalUniqueEntityId();
	customSpawner = new CustomSpawner(1016).setUnlocalizedName("customSpawner").setCreativeTab(mod_tabs.main.tabMisc);
	RenderingRegistry.registerEntityRenderingHandler(EntityGhost.class, new RenderGhost(new ModelGhost(), 0.3f));
	RenderingRegistry.registerEntityRenderingHandler(EntityCrab.class, new RenderCrab(new ModelCrab(), 0.3f));



	mod_mobs.translates.translates.translate_names();

}

}

 

Custom Entity List (for spawn eggs in custom tab)

package mod_mobs.entities;

import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.logging.Level;

import cpw.mods.fml.common.FMLLog;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityEggInfo;
import net.minecraft.entity.EntityLeashKnot;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.ai.EntityMinecartMobSpawner;
import net.minecraft.entity.boss.EntityDragon;
import net.minecraft.entity.boss.EntityWither;
import net.minecraft.entity.item.EntityBoat;
import net.minecraft.entity.item.EntityEnderCrystal;
import net.minecraft.entity.item.EntityEnderEye;
import net.minecraft.entity.item.EntityEnderPearl;
import net.minecraft.entity.item.EntityExpBottle;
import net.minecraft.entity.item.EntityFallingSand;
import net.minecraft.entity.item.EntityFireworkRocket;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.item.EntityItemFrame;
import net.minecraft.entity.item.EntityMinecartChest;
import net.minecraft.entity.item.EntityMinecartEmpty;
import net.minecraft.entity.item.EntityMinecartFurnace;
import net.minecraft.entity.item.EntityMinecartHopper;
import net.minecraft.entity.item.EntityMinecartTNT;
import net.minecraft.entity.item.EntityPainting;
import net.minecraft.entity.item.EntityTNTPrimed;
import net.minecraft.entity.item.EntityXPOrb;
import net.minecraft.entity.monster.EntityBlaze;
import net.minecraft.entity.monster.EntityCaveSpider;
import net.minecraft.entity.monster.EntityCreeper;
import net.minecraft.entity.monster.EntityEnderman;
import net.minecraft.entity.monster.EntityGhast;
import net.minecraft.entity.monster.EntityGiantZombie;
import net.minecraft.entity.monster.EntityIronGolem;
import net.minecraft.entity.monster.EntityMagmaCube;
import net.minecraft.entity.monster.EntityMob;
import net.minecraft.entity.monster.EntityPigZombie;
import net.minecraft.entity.monster.EntitySilverfish;
import net.minecraft.entity.monster.EntitySkeleton;
import net.minecraft.entity.monster.EntitySlime;
import net.minecraft.entity.monster.EntitySnowman;
import net.minecraft.entity.monster.EntitySpider;
import net.minecraft.entity.monster.EntityWitch;
import net.minecraft.entity.monster.EntityZombie;
import net.minecraft.entity.passive.EntityBat;
import net.minecraft.entity.passive.EntityChicken;
import net.minecraft.entity.passive.EntityCow;
import net.minecraft.entity.passive.EntityHorse;
import net.minecraft.entity.passive.EntityMooshroom;
import net.minecraft.entity.passive.EntityOcelot;
import net.minecraft.entity.passive.EntityPig;
import net.minecraft.entity.passive.EntitySheep;
import net.minecraft.entity.passive.EntitySquid;
import net.minecraft.entity.passive.EntityVillager;
import net.minecraft.entity.passive.EntityWolf;
import net.minecraft.entity.projectile.EntityArrow;
import net.minecraft.entity.projectile.EntityLargeFireball;
import net.minecraft.entity.projectile.EntityPotion;
import net.minecraft.entity.projectile.EntitySmallFireball;
import net.minecraft.entity.projectile.EntitySnowball;
import net.minecraft.entity.projectile.EntityWitherSkull;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;

public class customEntityList
{
    /** Provides a mapping between entity classes and a string */
    public static Map stringToClassMapping = new HashMap();

    /** Provides a mapping between a string and an entity classes */
    public static Map classToStringMapping = new HashMap();

    /** provides a mapping between an entityID and an Entity Class */
    public static Map IDtoClassMapping = new HashMap();

    /** provides a mapping between an Entity Class and an entity ID */
    private static Map classToIDMapping = new HashMap();

    /** Maps entity names to their numeric identifiers */
    private static Map stringToIDMapping = new HashMap();

    /** This is a HashMap of the Creative Entity Eggs/Spawners. */
    public static HashMap entityEggs = new LinkedHashMap();

    /**
     * adds a mapping between Entity classes and both a string representation and an ID
     */
    public static void addMapping(Class par0Class, String par1Str, int par2)
    {
        stringToClassMapping.put(par1Str, par0Class);
        classToStringMapping.put(par0Class, par1Str);
        IDtoClassMapping.put(Integer.valueOf(par2), par0Class);
        classToIDMapping.put(par0Class, Integer.valueOf(par2));
        stringToIDMapping.put(par1Str, Integer.valueOf(par2));
    }

    /**
     * Adds a entity mapping with egg info.
     */
    public static void addMapping(Class par0Class, String par1Str, int par2, int par3, int par4)
    {
        addMapping(par0Class, par1Str, par2);
        entityEggs.put(Integer.valueOf(par2), new EntityEggInfo(par2, par3, par4));
    }

    /**
     * Create a new instance of an entity in the world by using the entity name.
     */
    public static Entity createEntityByName(String par0Str, World par1World)
    {
        Entity entity = null;

        try
        {
            Class oclass = (Class)stringToClassMapping.get(par0Str);

            if (oclass != null)
            {
                entity = (Entity)oclass.getConstructor(new Class[] {World.class}).newInstance(new Object[] {par1World});
            }
        }
        catch (Exception exception)
        {
            exception.printStackTrace();
        }

        return entity;
    }

    /**
     * create a new instance of an entity from NBT store
     */
    public static Entity createEntityFromNBT(NBTTagCompound par0NBTTagCompound, World par1World)
    {
        Entity entity = null;

        if ("Minecart".equals(par0NBTTagCompound.getString("id")))
        {
            switch (par0NBTTagCompound.getInteger("Type"))
            {
                case 0:
                    par0NBTTagCompound.setString("id", "MinecartRideable");
                    break;
                case 1:
                    par0NBTTagCompound.setString("id", "MinecartChest");
                    break;
                case 2:
                    par0NBTTagCompound.setString("id", "MinecartFurnace");
            }

            par0NBTTagCompound.removeTag("Type");
        }

        Class oclass = null;
        try
        {
            oclass = (Class)stringToClassMapping.get(par0NBTTagCompound.getString("id"));

            if (oclass != null)
            {
                entity = (Entity)oclass.getConstructor(new Class[] {World.class}).newInstance(new Object[] {par1World});
            }
        }
        catch (Exception exception)
        {
            exception.printStackTrace();
        }

        if (entity != null)
        {
            try
            {
                entity.readFromNBT(par0NBTTagCompound);
            }
            catch (Exception e)
            {
                FMLLog.log(Level.SEVERE, e,
                        "An Entity %s(%s) has thrown an exception during loading, its state cannot be restored. Report this to the mod author",
                        par0NBTTagCompound.getString("id"), oclass.getName());
                entity = null;
            }
        }
        else
        {
            par1World.getWorldLogAgent().logWarning("Skipping Entity with id " + par0NBTTagCompound.getString("id"));
        }

        return entity;
    }

    /**
     * Create a new instance of an entity in the world by using an entity ID.
     */
    public static Entity createEntityByID(int par0, World par1World)
    {
        Entity entity = null;

        try
        {
            Class oclass = getClassFromID(par0);

            if (oclass != null)
            {
                entity = (Entity)oclass.getConstructor(new Class[] {World.class}).newInstance(new Object[] {par1World});
            }
        }
        catch (Exception exception)
        {
            exception.printStackTrace();
        }

        if (entity == null)
        {
            par1World.getWorldLogAgent().logWarning("Skipping Entity with id " + par0);
        }

        return entity;
    }

    /**
     * gets the entityID of a specific entity
     */
    public static int getEntityID(Entity par0Entity)
    {
        Class oclass = par0Entity.getClass();
        return classToIDMapping.containsKey(oclass) ? ((Integer)classToIDMapping.get(oclass)).intValue() : 0;
    }

    /**
     * Return the class assigned to this entity ID.
     */
    public static Class getClassFromID(int par0)
    {
        return (Class)IDtoClassMapping.get(Integer.valueOf(par0));
    }

    /**
     * Gets the string representation of a specific entity.
     */
    public static String getEntityString(Entity par0Entity)
    {
        return (String)classToStringMapping.get(par0Entity.getClass());
    }

    /**
     * Finds the class using IDtoClassMapping and classToStringMapping
     */
    public static String getStringFromID(int par0)
    {
        Class oclass = getClassFromID(par0);
        return oclass != null ? (String)classToStringMapping.get(oclass) : null;
    }

    static
    {
        addMapping(EntityItem.class, "Item", 1);
        addMapping(EntityLiving.class, "Mob", 48);
        addMapping(EntityMob.class, "Monster", 49);
        addMapping(EntityGhost.class, "Ghost", 301, 0xd4d1d1, 0xffffff);
        addMapping(EntityCrab.class, "Crab", 302, 0xce4111, 0xd34614);
    }
}

 

Entity Crab

package mod_mobs.entities;

import net.minecraft.entity.EntityAgeable;
import net.minecraft.entity.EnumCreatureAttribute;
import net.minecraft.entity.ai.EntityAIAttackOnCollide;
import net.minecraft.entity.ai.EntityAIHurtByTarget;
import net.minecraft.entity.ai.EntityAILookIdle;
import net.minecraft.entity.ai.EntityAINearestAttackableTarget;
import net.minecraft.entity.ai.EntityAISwimming;
import net.minecraft.entity.ai.EntityAIWander;
import net.minecraft.entity.ai.EntityAIWatchClosest;
import net.minecraft.entity.monster.EntityMob;
import net.minecraft.entity.passive.EntityAnimal;
import net.minecraft.entity.passive.EntityVillager;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.world.World;

public class EntityCrab extends EntityAnimal {

public EntityCrab(World par1World) {
	super(par1World);
	this.experienceValue = 4;
	this.tasks.addTask(0, new EntityAISwimming(this));
}

protected boolean isAIEnabled() {
	return true;
}

public int getMaxHealth() {
	return 10;
}

/*protected String getLivingSound()
    {
        return "mob.zombie.say";
    }

    /**
     * Returns the sound this mob makes when it is hurt.
     */
    /*protected String getHurtSound()
    {
        return "mob.zombie.hurt";
    }

    /**
     * Returns the sound this mob makes on death.
     */
    /*protected String getDeathSound()
    {
        return "mob.zombie.death";
    }
    
   /* protected void playStepSound(int par1, int par2, int par3, int par4) {
    	this.playSound("mob.zombie.step", 0.15F, 1.0F);
    }*/
    
    /*protected int getDropItemId() {
    	return mod_ores.main.Ruby.itemID;
    }
    
    protected void dropRareDrop(int par1) {
    	switch (this.rand.nextInt(3)) {
    	case 0:
    		this.dropItem(mod_ores.main.Sapphire.itemID, 1);
    		break;
    case 1:
	this.dropItem(Item.emerald.itemID, 1);
	break;
case 2:
	this.dropItem(Item.diamond.itemID, 1);
	break;
    }
}*/
    public EnumCreatureAttribute getCreatureAttribute() {
    	return EnumCreatureAttribute.UNDEFINED;
    }
    
   public void onLivingUpdate() {
    	super.onLivingUpdate();
    }

@Override
public EntityAgeable createChild(EntityAgeable entityageable) {
	return null;
}
}

 

Custom spawner (the custom egg to go in the custom tab)

package mod_mobs.items;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

import java.util.Iterator;
import java.util.List;

import mod_mobs.entities.customEntityList;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityEggInfo;
import net.minecraft.entity.EntityList;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.EntityLivingData;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumMovingObjectType;
import net.minecraft.util.Facing;
import net.minecraft.util.Icon;
import net.minecraft.util.MathHelper;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;

public class CustomSpawner extends Item
{
    @SideOnly(Side.CLIENT)
    private Icon theIcon;

    public CustomSpawner(int par1)
    {
        super(par1);
        this.setHasSubtypes(true);
        this.setCreativeTab(mod_tabs.main.tabMisc);
        this.func_111206_d(mod_mobs.main.modId + ":" + "spawn_egg");
    }

    public String getItemDisplayName(ItemStack par1ItemStack)
    {
        String s = ("" + StatCollector.translateToLocal(this.getUnlocalizedName() + ".name")).trim();
        String s1 = customEntityList.getStringFromID(par1ItemStack.getItemDamage());

        if (s1 != null)
        {
            s = s + " " + StatCollector.translateToLocal("entity." + s1 + ".name");
        }

        return s;
    }

    @SideOnly(Side.CLIENT)
    public int getColorFromItemStack(ItemStack par1ItemStack, int par2)
    {
        EntityEggInfo entityegginfo = (EntityEggInfo)customEntityList.entityEggs.get(Integer.valueOf(par1ItemStack.getItemDamage()));
        return entityegginfo != null ? (par2 == 0 ? entityegginfo.primaryColor : entityegginfo.secondaryColor) : 16777215;
    }

    /**
     * Callback for item usage. If the item does something special on right clicking, he will have one of those. Return
     * True if something happen and false if it don't. This is for ITEMS, not BLOCKS
     */
    public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10)
    {
        if (par3World.isRemote)
        {
            return true;
        }
        else
        {
            int i1 = par3World.getBlockId(par4, par5, par6);
            par4 += Facing.offsetsXForSide[par7];
            par5 += Facing.offsetsYForSide[par7];
            par6 += Facing.offsetsZForSide[par7];
            double d0 = 0.0D;

            if (par7 == 1 && Block.blocksList[i1] != null && Block.blocksList[i1].getRenderType() == 11)
            {
                d0 = 0.5D;
            }

            Entity entity = spawnCreature(par3World, par1ItemStack.getItemDamage(), (double)par4 + 0.5D, (double)par5 + d0, (double)par6 + 0.5D);

            if (entity != null)
            {
                if (entity instanceof EntityLivingBase && par1ItemStack.hasDisplayName())
                {
                    ((EntityLiving)entity).func_94058_c(par1ItemStack.getDisplayName());
                }

                if (!par2EntityPlayer.capabilities.isCreativeMode)
                {
                    --par1ItemStack.stackSize;
                }
            }

            return true;
        }
    }

    /**
     * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
     */
    public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
    {
        if (par2World.isRemote)
        {
            return par1ItemStack;
        }
        else
        {
            MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(par2World, par3EntityPlayer, true);

            if (movingobjectposition == null)
            {
                return par1ItemStack;
            }
            else
            {
                if (movingobjectposition.typeOfHit == EnumMovingObjectType.TILE)
                {
                    int i = movingobjectposition.blockX;
                    int j = movingobjectposition.blockY;
                    int k = movingobjectposition.blockZ;

                    if (!par2World.canMineBlock(par3EntityPlayer, i, j, k))
                    {
                        return par1ItemStack;
                    }

                    if (!par3EntityPlayer.canPlayerEdit(i, j, k, movingobjectposition.sideHit, par1ItemStack))
                    {
                        return par1ItemStack;
                    }

                    if (par2World.getBlockMaterial(i, j, k) == Material.water)
                    {
                        Entity entity = spawnCreature(par2World, par1ItemStack.getItemDamage(), (double)i, (double)j, (double)k);

                        if (entity != null)
                        {
                            if (entity instanceof EntityLivingBase && par1ItemStack.hasDisplayName())
                            {
                                ((EntityLiving)entity).func_94058_c(par1ItemStack.getDisplayName());
                            }

                            if (!par3EntityPlayer.capabilities.isCreativeMode)
                            {
                                --par1ItemStack.stackSize;
                            }
                        }
                    }
                }

                return par1ItemStack;
            }
        }
    }

    /**
     * Spawns the creature specified by the egg's type in the location specified by the last three parameters.
     * Parameters: world, entityID, x, y, z.
     */
    public static Entity spawnCreature(World par0World, int par1, double par2, double par4, double par6)
    {
        if (!customEntityList.entityEggs.containsKey(Integer.valueOf(par1)))
        {
            return null;
        }
        else
        {
            Entity entity = null;

            for (int j = 0; j < 1; ++j)
            {
                entity = customEntityList.createEntityByID(par1, par0World);

                if (entity != null && entity instanceof EntityLivingBase)
                {
                    EntityLiving entityliving = (EntityLiving)entity;
                    entity.setLocationAndAngles(par2, par4, par6, MathHelper.wrapAngleTo180_float(par0World.rand.nextFloat() * 360.0F), 0.0F);
                    entityliving.rotationYawHead = entityliving.rotationYaw;
                    entityliving.renderYawOffset = entityliving.rotationYaw;
                    entityliving.func_110161_a((EntityLivingData)null);
                    par0World.spawnEntityInWorld(entity);
                    entityliving.playLivingSound();
                }
            }

            return entity;
        }
    }

    @SideOnly(Side.CLIENT)
    public boolean requiresMultipleRenderPasses()
    {
        return true;
    }

    @SideOnly(Side.CLIENT)

    /**
     * Gets an icon index based on an item's damage value and the given render pass
     */
    public Icon getIconFromDamageForRenderPass(int par1, int par2)
    {
        return par2 > 0 ? this.theIcon : super.getIconFromDamageForRenderPass(par1, par2);
    }

    @SideOnly(Side.CLIENT)

    /**
     * returns a list of items with the same ID, but different meta (eg: dye returns 16 items)
     */
    public void getSubItems(int par1, CreativeTabs par2CreativeTabs, List par3List)
    {
        Iterator iterator = customEntityList.entityEggs.values().iterator();

        while (iterator.hasNext())
        {
            EntityEggInfo entityegginfo = (EntityEggInfo)iterator.next();
            par3List.add(new ItemStack(par1, 1, entityegginfo.spawnedID));
        }
    }

    @SideOnly(Side.CLIENT)
    public void registerIcons(IconRegister par1IconRegister)
    {
        super.registerIcons(par1IconRegister);
        this.theIcon = par1IconRegister.registerIcon(mod_mobs.main.modId + ":" + "spawn_egg" + "_overlay");
    }
}

 

Model Crab

// Date: 12/09/2013 11.08.44
// Template version 1.1
// Java generated by Techne
// Keep in mind that you still need to fill in some blanks
// - ZeuX






package mod_mobs.models;

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

public class ModelCrab extends ModelBase
{
  //fields
    ModelRenderer Body;
    ModelRenderer RightLeg1;
    ModelRenderer RightLeg2;
    ModelRenderer RightLegDown1;
    ModelRenderer RightLegDown2;
    ModelRenderer LeftLeg1;
    ModelRenderer LeftLeg2;
    ModelRenderer LeftLegDown1;
    ModelRenderer LeftLegDown2;
    ModelRenderer Eye1;
    ModelRenderer Eye2;
  
  public ModelCrab()
  {
    textureWidth = 64;
    textureHeight = 32;
    
      Body = new ModelRenderer(this, 0, 24);
      Body.addBox(0F, 0F, 0F, 2, 2, 2);
      Body.setRotationPoint(-1F, 22F, 0F);
      Body.setTextureSize(64, 32);
      Body.mirror = true;
      setRotation(Body, 0F, 0F, 0F);
      RightLeg1 = new ModelRenderer(this, 18, 0);
      RightLeg1.addBox(0F, 0F, 0F, 2, 1, 1);
      RightLeg1.setRotationPoint(0.5F, 22.5F, -0.7F);
      RightLeg1.setTextureSize(64, 32);
      RightLeg1.mirror = true;
      setRotation(RightLeg1, 0F, 0F, -0.2974359F);
      RightLeg2 = new ModelRenderer(this, 18, 0);
      RightLeg2.addBox(0F, 0F, 0F, 2, 1, 1);
      RightLeg2.setRotationPoint(-2.5F, 22F, -0.5F);
      RightLeg2.setTextureSize(64, 32);
      RightLeg2.mirror = true;
      setRotation(RightLeg2, 0F, 0F, 0.3346075F);
      RightLegDown1 = new ModelRenderer(this, 0, 0);
      RightLegDown1.addBox(0F, 0F, 0F, 2, 1, 1);
      RightLegDown1.setRotationPoint(-4F, 23.3F, -0.5F);
      RightLegDown1.setTextureSize(64, 32);
      RightLegDown1.mirror = true;
      setRotation(RightLegDown1, 0F, 0F, -0.8179294F);
      RightLegDown2 = new ModelRenderer(this, 0, 0);
      RightLegDown2.addBox(0F, 0F, 0F, 2, 1, 1);
      RightLegDown2.setRotationPoint(2.5F, 21.8F, -0.5F);
      RightLegDown2.setTextureSize(64, 32);
      RightLegDown2.mirror = true;
      setRotation(RightLegDown2, 0F, 0F, 0.8179294F);
      LeftLeg1 = new ModelRenderer(this, 18, 0);
      LeftLeg1.addBox(0F, 0F, 0F, 2, 1, 1);
      LeftLeg1.setRotationPoint(-2.5F, 22F, 1.5F);
      LeftLeg1.setTextureSize(64, 32);
      LeftLeg1.mirror = true;
      setRotation(LeftLeg1, 0F, 0F, 0.3346075F);
      LeftLeg2 = new ModelRenderer(this, 18, 0);
      LeftLeg2.addBox(0F, 0F, 0F, 2, 1, 1);
      LeftLeg2.setRotationPoint(0.5F, 22.5F, 1.5F);
      LeftLeg2.setTextureSize(64, 32);
      LeftLeg2.mirror = true;
      setRotation(LeftLeg2, 0F, 0F, -0.2974359F);
      LeftLegDown1 = new ModelRenderer(this, 0, 0);
      LeftLegDown1.addBox(0F, 0F, 0F, 2, 1, 1);
      LeftLegDown1.setRotationPoint(-4F, 23.3F, 1.5F);
      LeftLegDown1.setTextureSize(64, 32);
      LeftLegDown1.mirror = true;
      setRotation(LeftLegDown1, 0F, 0F, -0.8179294F);
      LeftLegDown2 = new ModelRenderer(this, 0, 0);
      LeftLegDown2.addBox(0F, 0F, 0F, 2, 1, 1);
      LeftLegDown2.setRotationPoint(2.5F, 21.8F, 1.5F);
      LeftLegDown2.setTextureSize(64, 32);
      LeftLegDown2.mirror = true;
      setRotation(LeftLegDown2, 0F, 0F, 0.8179294F);
      Eye1 = new ModelRenderer(this, 9, 0);
      Eye1.addBox(0F, 0F, 0F, 1, 1, 1);
      Eye1.setRotationPoint(0.5F, 21F, -0.5F);
      Eye1.setTextureSize(64, 32);
      Eye1.mirror = true;
      setRotation(Eye1, 0F, 0F, 0F);
      Eye2 = new ModelRenderer(this, 9, 0);
      Eye2.addBox(0F, 0F, 0F, 1, 1, 1);
      Eye2.setRotationPoint(-1.5F, 21F, -0.5F);
      Eye2.setTextureSize(64, 32);
      Eye2.mirror = true;
      setRotation(Eye2, 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);
    Body.render(f5);
    RightLeg1.render(f5);
    RightLeg2.render(f5);
    RightLegDown1.render(f5);
    RightLegDown2.render(f5);
    LeftLeg1.render(f5);
    LeftLeg2.render(f5);
    LeftLegDown1.render(f5);
    LeftLegDown2.render(f5);
    Eye1.render(f5);
    Eye2.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 par6Entity)
  {
  }

}

 

Render Crab

package mod_mobs.render;

import mod_mobs.entities.EntityCrab;
import mod_mobs.models.ModelCrab;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.renderer.entity.Render;
import net.minecraft.client.renderer.entity.RenderLiving;
import net.minecraft.client.resources.ResourceLocation;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;

public class RenderCrab extends RenderLiving {

protected ModelCrab model;
public RenderCrab(ModelBase par1ModelBase, float par2) {
	super(par1ModelBase, par2);
	model = ((ModelCrab)mainModel);
}

public void renderCrab(EntityCrab entity, double par2, double par4, double par6, float par8, float par9) {
	super.doRenderLiving(entity, par2, par4, par6, par8, par9);
}

public void doRenderLiving(EntityLiving par1EntityLiving, double par2, double par4, double par6, float par8, float par9) {
	renderCrab((EntityCrab)par1EntityLiving, par2, par4 ,par6, par8, par9);
}

@Override
public void doRender(Entity entity, double d0, double d1, double d2,
		float f, float f1) {
	renderCrab((EntityCrab)entity, d0, d1, d2, f, f1);
}

@Override
protected ResourceLocation func_110775_a(Entity entity) {
	return new ResourceLocation(mod_mobs.main.modId + ":" + "textures/mobs/Crab.png");
}

}

 

Don't blame me if i always ask for your help. I just want to learn to be better :)

  • 4 weeks later...
Posted

In your EntityCrab class, put "this.setSize(widthOfCrab, heightOfCrab);" into the constructor. You need to give your entity a hitbox otherwise it has no collision with anything...

 

public EntityCrab(World par1World) {

super(par1World);

                this.setSize(1f, .5f);

this.experienceValue = 4;

this.tasks.addTask(0, new EntityAISwimming(this));

}

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.