Posted November 9, 20159 yr I created a Boar mob and tried to make a Monster Spawner via command that spawns my mob. First I tried with /give @p mob_spawner 1 0 {BlockEntityTag:{EntityId:Skeleton}}. It gave me the basic spawner block which spawns pigs. After that I used /setblock ~ ~ ~ mob_spawner 0 destroy {EntityId:Boar}. It spawned the block with the little spinning boar with it, but spawned nothing. Is the problem in the code or I search somewhere else? Just to be sure here is my Boar.class package net.Aethoscraft.mod.entity.hostile; import java.util.Random; import net.Aethoscraft.mod.Aethoscraft; import net.minecraft.entity.Entity; import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.ai.EntityAIHurtByTarget; import net.minecraft.entity.ai.EntityAINearestAttackableTarget; import net.minecraft.entity.ai.EntityAIWatchClosest; import net.minecraft.entity.boss.IBossDisplayData; import net.minecraft.entity.monster.EntityMob; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.world.World; public class EntityBoar extends EntityMob implements IBossDisplayData { Random r = new Random(); public EntityBoar(World world) { super(world); this.experienceValue = 2; this.tasks.addTask(0, new EntityAIWatchClosest(this, EntityPlayer.class, 5.0F)); this.targetTasks.addTask(0, new EntityAIHurtByTarget(this, true)); this.targetTasks.addTask(1, new EntityAINearestAttackableTarget(this, EntityPlayer.class, 0, true)); this.setCustomNameTag("Boar"); } protected void applyEntityAttributes() { super.applyEntityAttributes(); this.getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(5.0D); this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.3D); this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(1.5D); this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(40.0D); } public boolean attackEntityAsMob(Entity p_70652_1_) { return true; } protected boolean isAIEnabled() { return true; } protected Item getDropItem() { if(r.nextInt(100)>20) return Items.leather; else return Aethoscraft.itemBoarTusk; } }
November 10, 20159 yr Author package net.Aethoscraft.mod.handlers; import java.util.Random; import net.Aethoscraft.mod.Aethoscraft; import net.minecraft.entity.EntityList; import net.minecraft.entity.EntityList.EntityEggInfo; import net.minecraft.entity.EnumCreatureType; 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); EntityRegistry.registerModEntity(entityClass, name, entityID, Aethoscraft.instance, 16, 1, true); EntityList.entityEggs.put(Integer.valueOf(entityID),new EntityList.EntityEggInfo(entityID, mainColor,subColor)); } public static void registerCreatures(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.creature); EntityRegistry.registerModEntity(entityClass, name, entityID, Aethoscraft.instance, 16, 1, true); EntityList.entityEggs.put(Integer.valueOf(entityID),new EntityList.EntityEggInfo(entityID, mainColor,subColor)); } } In the main mod class I simply call the handler class above: EntityHandler.registerMonsters(EntityBoar.class, "Boar");
November 11, 20159 yr Author Can u give me a good tutorial on how to avoid global entity IDs (i know that global IDs can only store 256 entities)?I mean that I wish to use custom IDs and if I'm not mistaken, spawn eggs don't work with custom IDs.
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.