Posted February 8, 201411 yr In my mod, there's a block that when right clicked spawns the Monkeysaur entity: package tlhpoe.fs.block; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.util.IIcon; import net.minecraft.world.World; import tlhpoe.fs.entity.boss.EntityMonkeysaur; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; public class BlockMonkeysaurAltar extends Block { public IIcon iSide, iTop; public BlockMonkeysaurAltar() { super(Material.rock); } @Override @SideOnly(Side.CLIENT) public IIcon getIcon(int side, int p_149691_2_) { if(side == 1) return iTop; return iSide; } @Override @SideOnly(Side.CLIENT) public void registerBlockIcons(IIconRegister p_149651_1_) { this.iSide = Blocks.gold_block.getBlockTextureFromSide(0); this.iTop = p_149651_1_.registerIcon("fs:monkeysaurAltar"); this.blockIcon = this.iTop; } @Override public boolean onBlockActivated(World w, int x, int y, int z, EntityPlayer p_149727_5_, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) { if(!w.isRemote) { EntityMonkeysaur e = new EntityMonkeysaur(w); e.posX = x; e.posY = y; e.posZ = z; w.spawnEntityInWorld(e); w.setBlock(x, y, z, Blocks.air); } return true; } } The problem is, the entity appears and I can't interact with it and it doesn't do anything. A few seconds later it disappears. Here's the entity's code: package tlhpoe.fs.entity.boss; import net.minecraft.command.IEntitySelector; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.SharedMonsterAttributes; 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.boss.IBossDisplayData; import net.minecraft.entity.monster.EntityMob; import net.minecraft.entity.monster.IMob; import net.minecraft.world.World; public class EntityMonkeysaur extends EntityMob implements IBossDisplayData, IMob { private static final IEntitySelector attackEntitySelector = new IEntitySelector() { public boolean isEntityApplicable(Entity par1Entity) { return par1Entity instanceof EntityLivingBase && !(par1Entity instanceof EntityMonkeysaur); } }; public EntityMonkeysaur(World par1World) { super(par1World); this.setSize(0.6F * 4, 1.8F * 4); this.tasks.addTask(0, new EntityAISwimming(this)); this.tasks.addTask(1, new EntityAIAttackOnCollide(this, EntityLivingBase.class, 1.0D, false)); this.tasks.addTask(7, new EntityAIWander(this, 1.0D)); this.tasks.addTask(8, new EntityAIWatchClosest(this, EntityLivingBase.class, 8.0F)); this.tasks.addTask(8, new EntityAILookIdle(this)); this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, true)); this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityLivingBase.class, 0, false, false, attackEntitySelector)); this.experienceValue = 350; } @Override protected void applyEntityAttributes() { super.applyEntityAttributes(); this.getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(64.0D); this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(200.0D); this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(10); this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.23000000417232513D); } @Override public void setInWeb() { } @Override protected void despawnEntity() { this.entityAge = 0; } @Override protected void fall(float par1) { } @Override protected boolean isAIEnabled() { return true; } } Kain
February 8, 201411 yr If I remember, when I created a mob, that I didn't want to despawn I made it: @Override protected void despawnEntity() {}
February 8, 201411 yr Wait wait wait. How do you have this: Blocks.air Shouldn't it be Block.air? Shouldn't you have also gotten an error?
February 8, 201411 yr Can I see where you registered your Entity, or anything that relates to that Entity?
February 8, 201411 yr Author I'm using 1.7.2, Minecraft stores its blocks in the Blocks class. Here's where I do my entity registering: package tlhpoe.fs.helper; import net.minecraft.client.renderer.entity.Render; import net.minecraft.entity.Entity; import tlhpoe.fs.entity.EntityIceCreeper; import tlhpoe.fs.entity.EntityWaterCreeper; import tlhpoe.fs.entity.boss.EntityMonkeysaur; import tlhpoe.fs.entity.render.RenderFSCreeper; import tlhpoe.fs.entity.render.RenderMonkeysaur; import cpw.mods.fml.client.registry.RenderingRegistry; import cpw.mods.fml.common.registry.EntityRegistry; public class EntityHelper { public static void doServer() { doEntity(EntityIceCreeper.class, "iceCreeper", 0xFFFFFF, 0x00FFFF); doEntity(EntityWaterCreeper.class, "waterCreeper", 0x0F8FFF, 0x00B2FF); doEntity(EntityMonkeysaur.class, "monkeysaur", 0x663300, 0x472400); } public static void doClient() { doRender(EntityIceCreeper.class, new RenderFSCreeper("ice")); doRender(EntityWaterCreeper.class, new RenderFSCreeper("water")); doRender(EntityMonkeysaur.class, new RenderMonkeysaur()); } private static void doEntity(Class<? extends Entity> clazz, String name, int bgColor, int spotColor) { int id = EntityRegistry.findGlobalUniqueEntityId(); EntityRegistry.registerGlobalEntityID(clazz, name, id, bgColor, spotColor); } private static void doRender(Class<? extends Entity> clazz, Render render) { RenderingRegistry.registerEntityRenderingHandler(clazz, render); } } I can spawn it just fine with the spawn egg. Kain
February 8, 201411 yr Oh I thought you were using 1.6, my bad. Hmm. Strange, as if its spawning a ghost entity. Try looking at other onBlockActivated methods. In BlockWorkbench, it activates when (world.isRemote), try removing the !
February 8, 201411 yr Author If I remove the !, it spawns the entity client side and it just makes the game confused a little. If I completely remove the if statement, same result. Kain
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.