Jump to content

Recommended Posts

Posted

For some reason my entity doesnt want to spawn (doesnt spawn in world or using its own mob egg). ive looked through the code but cant seem to find whats wrong. Im guessing its something to do with the actual entity cause when i use the mob egg, the hitbox on the ground doesnt go away so its not a texture issue. Any help is appreciated! :)

 

Entity class

 

 

package com.manslaughter777.crystaldimension.entity;

import net.minecraft.block.Block;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.EntityAIAttackOnCollide;
import net.minecraft.entity.ai.EntityAIHurtByTarget;
import net.minecraft.entity.ai.EntityAIMoveThroughVillage;
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.monster.EntityZombie;
import net.minecraft.entity.passive.EntityVillager;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;

public class EntityCrystopian extends EntityMob {

public EntityCrystopian(World world) {
	super(world);
        
	this.tasks.addTask(0, new EntityAISwimming(this));
        this.tasks.addTask(4, new EntityAIAttackOnCollide(this, EntityVillager.class, 1.0D, true));
        this.tasks.addTask(2, new EntityAIAttackOnCollide(this, EntityPlayer.class, 1.0D, false));
        this.tasks.addTask(6, new EntityAIMoveThroughVillage(this, 1.0D, false));
        this.tasks.addTask(7, new EntityAIWander(this, 1.0D));
        this.tasks.addTask(8, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));
        this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, true));
        this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityPlayer.class, 0, true));
        this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityVillager.class, 0, true));
}

protected void addRandomArmor()
    {
        super.addRandomArmor();
        this.setCurrentItemOrArmor(0, new ItemStack(Items.golden_axe));
        this.setCurrentItemOrArmor(1, new ItemStack(Items.chainmail_leggings));
        this.setCurrentItemOrArmor(1, new ItemStack(Items.chainmail_boots));
    }
    
    protected Item getDropItem()
    {
        return Items.apple;
    }
    
    protected void dropRareDrop(int par1) {
    	this.entityDropItem(new ItemStack(Items.gold_ingot, 1, 1), 0.0F);
    }
    
    /*
    protected String getLivingSound()
    {
        return "";
    } */

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

    /**
     * Returns the sound this mob makes on death.
     */
    /*
    protected String getDeathSound()
    {
        return "";
    }
    */

    protected void func_145780_a(int p_145780_1_, int p_145780_2_, int p_145780_3_, Block p_145780_4_)
    {
        this.playSound("mob.zombie.step", 0.15F, 1.0F);
    }

    /*
protected void applyEntityAttributes()
    {
        super.applyEntityAttributes();
        this.getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(40.0D);
        this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.23000000417232513D);
        this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(3.0D);
        this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(20.0D);
    }
    */
    @Override
    protected void applyEntityAttributes()
    {
        
        super.applyEntityAttributes();
        this.getAttributeMap().registerAttribute(SharedMonsterAttributes.attackDamage);
        this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(10.0D);
        this.getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(32.0D);
        this.getEntityAttribute(SharedMonsterAttributes.knockbackResistance).setBaseValue(0.0D);
        this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(10.23000000417232513D);
        this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(60.0D);
        
    }

protected boolean isAIEnabled()
    {
        return true;
    }

}

 

 

 

Model Class

 

 

package com.manslaughter777.crystaldimension.model;

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

public class ModelCrystopian extends ModelBase {

//fields
    ModelRenderer head;
    ModelRenderer body;
    ModelRenderer lleg;
    ModelRenderer rleg;
    ModelRenderer rarm;
    ModelRenderer larm;
  
  public ModelCrystopian()
  {
    textureWidth = 64;
    textureHeight = 64;
    
      head = new ModelRenderer(this, 0, 0);
      head.addBox(-3F, -6F, -3F, 9, 10, 10);
      head.setRotationPoint(-1.5F, -10F, -2F);
      head.setTextureSize(64, 32);
      head.mirror = true;
      setRotation(head, 0F, 0F, 0F);
      body = new ModelRenderer(this, 0, 20);
      body.addBox(-5F, 0F, -4F, 10, 15, ;
      body.setRotationPoint(0F, -6F, 0F);
      body.setTextureSize(64, 32);
      body.mirror = true;
      setRotation(body, 0F, 0F, 0F);
      lleg = new ModelRenderer(this, 16, 43);
      lleg.addBox(-2F, 0F, -2F, 4, 15, 4);
      lleg.setRotationPoint(3F, 9F, 0F);
      lleg.setTextureSize(64, 32);
      lleg.mirror = true;
      setRotation(lleg, 0F, 0F, 0F);
      rleg = new ModelRenderer(this, 0, 43);
      rleg.addBox(-2F, 0F, -2F, 4, 15, 4);
      rleg.setRotationPoint(-3F, 9F, 0F);
      rleg.setTextureSize(64, 32);
      rleg.mirror = true;
      setRotation(rleg, 0F, 0F, 0F);
      rarm = new ModelRenderer(this, 38, 24);
      rarm.addBox(0F, -1F, -2F, 5, 20, 4);
      rarm.setRotationPoint(5F, -5F, 0F);
      rarm.setTextureSize(64, 32);
      rarm.mirror = true;
      setRotation(rarm, 0F, 0F, 0F);
      larm = new ModelRenderer(this, 38, 0);
      larm.addBox(-2F, -1F, -2F, 5, 20, 4);
      larm.setRotationPoint(-8F, -5F, 0F);
      larm.setTextureSize(64, 32);
      larm.mirror = true;
      setRotation(larm, 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);
    head.render(f5);
    body.render(f5);
    lleg.render(f5);
    rleg.render(f5);
    rarm.render(f5);
    larm.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);
    
    this.head.rotateAngleY = f3 / (180F / (float)Math.PI);
    this.head.rotateAngleX = f4 / (180F / (float)Math.PI);
    //this.lhornang.rotateAngleY = f3 / (180F / (float)Math.PI);
    //this.lhornang.rotateAngleX = f4 / (180F / (float)Math.PI);
    //this.rhorn.rotateAngleY = f3 / (180F / (float)Math.PI);
    //this.rhorn.rotateAngleX = f4 / (180F / (float)Math.PI);
    this.rarm.rotateAngleX = MathHelper.cos(f * 0.6662F + (float)Math.PI) * 2.0F * f1 * 0.5F;
    this.larm.rotateAngleX = MathHelper.cos(f * 0.6662F) * 2.0F * f1 * 0.5F;
    this.rarm.rotateAngleZ = 0.0F;
    this.larm.rotateAngleZ = 0.0F;
    this.rleg.rotateAngleX = MathHelper.cos(f * 0.6662F) * 1.4F * f1;
    this.lleg.rotateAngleX = MathHelper.cos(f * 0.6662F + (float)Math.PI) * 1.4F * f1;
    this.rleg.rotateAngleY = 0.0F;
    this.lleg.rotateAngleY = 0.0F;
    
  }

}

 

 

 

RenderEntity class

 

 

package com.manslaughter777.crystaldimension.render;

import net.minecraft.client.model.ModelBase;
import net.minecraft.client.renderer.entity.RenderLiving;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.util.ResourceLocation;

import com.manslaughter777.crystaldimension.Main;
import com.manslaughter777.crystaldimension.entity.EntityCrystopian;
import com.manslaughter777.crystaldimension.model.ModelCrystopian;

public class RenderCrystopian extends RenderLiving {

private static final ResourceLocation texture = new ResourceLocation(Main.MODID + ":" + "textures/model/entity/Crystopian.png");

protected ModelCrystopian modelEntity;

public RenderCrystopian(ModelBase par1ModelBase, float par2) {
	super(par1ModelBase, par2);
	modelEntity = ((ModelCrystopian) mainModel);
}

public void renderCrystopian(EntityCrystopian entity, double x, double y, double z, float u, float v) {
	super.doRender(entity, x, y, z, u, v);
}

public void doRenderLiving(EntityLiving entityLiving, double x, double y, double z, float u, float v) {
	renderCrystopian((EntityCrystopian)entityLiving, x, y, z, u, v);
}

public void doRender(Entity entity, double x, double y, double z, float u, float v) {
	renderCrystopian((EntityCrystopian)entity, x, y, z, u, v);
}


@Override
protected ResourceLocation getEntityTexture(Entity var1) {
	return texture;
}



}

 

 

 

ClientProxy

 

 

package com.manslaughter777.crystaldimension.proxy;

import com.manslaughter777.crystaldimension.entity.EntityCrystopian;
import com.manslaughter777.crystaldimension.model.ModelCrystopian;
import com.manslaughter777.crystaldimension.render.RenderCrystopian;

import cpw.mods.fml.client.registry.RenderingRegistry;

public class ClientProxy extends CommonProxy {

public void registerRenderThings() {	

	//Entities
	RenderingRegistry.registerEntityRenderingHandler(EntityCrystopian.class, new RenderCrystopian(new ModelCrystopian(), 0.3F));
}

public void registerTileEntitySpecialRenderer() {

}
}

 

 

 

 

entity handler

 

 

package com.manslaughter777.crystaldimension.handler;

import java.util.Random;

import net.minecraft.entity.EntityList;
import net.minecraft.entity.EnumCreatureType;

import com.manslaughter777.crystaldimension.Main;

import cpw.mods.fml.common.registry.EntityRegistry;

public class EntityHandler {

public static void registerMonsters(Class entityClass, String name) {
	int entityId = EntityRegistry.findGlobalUniqueEntityId();
	long x = name.hashCode();
	Random random = new Random(x);
	int mainColor = random.nextInt() * 16777215;
	int subColor = random.nextInt() * 16777215;

	EntityRegistry.registerGlobalEntityID(entityClass, name, entityId);
	EntityRegistry.addSpawn(entityClass, 50, 2, 4, EnumCreatureType.monster, Main.crystalBiome);
	EntityRegistry.registerModEntity(entityClass, name, entityId, Main.instance, 64, 1, true);
	EntityList.entityEggs.put(Integer.valueOf(entityId), new EntityList.EntityEggInfo(entityId, mainColor, subColor));

}
}

 

 

 

Phew, and finnaly in my main class there is: (postInit)

 

 

/**Entities */
EntityHandler.registerMonsters(EntityCrystopian.class, "Crystopian");

 

 

 

I also get an error when using the mob egg:

 

 

 

java.lang.reflect.InvocationTargetException
at sun.reflect.GeneratedConstructorAccessor29.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at net.minecraft.world.SpawnerAnimals.findChunksForSpawning(SpawnerAnimals.java:164)
at net.minecraft.world.WorldServer.tick(WorldServer.java:169)
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:692)
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:614)
at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118)
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:485)
at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:752)
Caused by: java.lang.IllegalArgumentException: Attribute is already registered!
at net.minecraft.entity.ai.attributes.ServersideAttributeMap.registerAttribute(ServersideAttributeMap.java:41)
at com.manslaughter777.crystaldimension.entity.EntityCrystopian.applyEntityAttributes(EntityCrystopian.java:100)
at net.minecraft.entity.EntityLivingBase.<init>(EntityLivingBase.java:156)
at net.minecraft.entity.EntityLiving.<init>(EntityLiving.java:78)
at net.minecraft.entity.EntityCreature.<init>(EntityCreature.java:36)
at net.minecraft.entity.monster.EntityMob.<init>(EntityMob.java:21)
at com.manslaughter777.crystaldimension.entity.EntityCrystopian.<init>(EntityCrystopian.java:24)
... 10 more

/

 

 

 

 

Posted

Crap! i forgot to post it! , i do have an error:

 

java.lang.reflect.InvocationTargetException

at sun.reflect.GeneratedConstructorAccessor29.newInstance(Unknown Source)

at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)

at java.lang.reflect.Constructor.newInstance(Unknown Source)

at net.minecraft.world.SpawnerAnimals.findChunksForSpawning(SpawnerAnimals.java:164)

at net.minecraft.world.WorldServer.tick(WorldServer.java:169)

at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:692)

at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:614)

at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118)

at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:485)

at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:752)

Caused by: java.lang.IllegalArgumentException: Attribute is already registered!

at net.minecraft.entity.ai.attributes.ServersideAttributeMap.registerAttribute(ServersideAttributeMap.java:41)

at com.manslaughter777.crystaldimension.entity.EntityCrystopian.applyEntityAttributes(EntityCrystopian.java:100)

at net.minecraft.entity.EntityLivingBase.<init>(EntityLivingBase.java:156)

at net.minecraft.entity.EntityLiving.<init>(EntityLiving.java:78)

at net.minecraft.entity.EntityCreature.<init>(EntityCreature.java:36)

at net.minecraft.entity.monster.EntityMob.<init>(EntityMob.java:21)

at com.manslaughter777.crystaldimension.entity.EntityCrystopian.<init>(EntityCrystopian.java:24)

... 10 more

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.