Posted July 9, 201510 yr Hey, I've got this weird issue where my mob won't spawn outside in the world, and only near the player's entry point to the world. Spawn/Entity code (located in init method) EntityRegistry.registerModEntity(EntityMimic.class, "rpgMimic", ENTITY_MIMIC_ID, BrightRPG.instance, 80, 1, true); EntityRegistry.addSpawn(EntityMimic.class, 85, 3, 7, EnumCreatureType.CREATURE, BiomeGenBase.desert, BiomeGenBase.beach, BiomeGenBase.birchForest, BiomeGenBase.birchForestHills, BiomeGenBase.desertHills, BiomeGenBase.extremeHills, BiomeGenBase.extremeHillsEdge, BiomeGenBase.extremeHillsPlus, BiomeGenBase.forest, BiomeGenBase.forestHills, BiomeGenBase.jungle, BiomeGenBase.jungleEdge, BiomeGenBase.jungleHills, BiomeGenBase.mesa, BiomeGenBase.mesaPlateau, BiomeGenBase.mesaPlateau_F, BiomeGenBase.plains, BiomeGenBase.river, BiomeGenBase.roofedForest, BiomeGenBase.savanna, BiomeGenBase.savannaPlateau); EntityList.addMapping(EntityMimic.class, "rpgMimic", 205, 113213, 3523523);
July 10, 201510 yr A few things: 1. Do NOT use '1' for the update frequency (the number after '80') - vanilla animals / mobs all use '3' 2. 205 is a magic number - use a counter or something of that nature 3. Entity spawning logic is mostly done in the actual Entity class getCanSpawnHere method - show us yours. http://i.imgur.com/NdrFdld.png[/img]
July 10, 201510 yr Author Here it is: @Override public boolean getCanSpawnHere() { return this.worldObj.getDifficulty() != EnumDifficulty.PEACEFUL; } I changed the frequency to 3 and they still would only spawn near the world entrance. Also, why is 205 taken? When I changed it to a final int, I set it at 400, nothing spawned at all.
July 10, 201510 yr Vanilla global entity IDs only go up to 255, which is why it is HIGHLY recommended NOT to use them, and use only the registerModEntity. In 1.8, you don't need to manually add mappings like that anymore to get a spawn egg, you can use instead EntityRegister#registerEgg. The frequency I mentioned is not related to spawn rate, just something I see all the time that is probably not very good to do. Put some println statements in your mob's onInitialSpawn method and see if that is getting called. Also, you probably want to call super.getCanSpawnHere() - the super methods generally have useful checks, depending on what class your mob extends. http://i.imgur.com/NdrFdld.png[/img]
July 10, 201510 yr Author So I changed the registry to this: int id = 600; EntityRegistry.registerModEntity(EntityMimic.class, "rpgMimic", BrightRPG.ENTITY_MIMIC_ID, BrightRPG.instance, 80, 3, true); EntityRegistry.addSpawn(EntityMimic.class, 85, 3, 7, EnumCreatureType.CREATURE, BiomeGenBase.desert, BiomeGenBase.beach, BiomeGenBase.birchForest, BiomeGenBase.birchForestHills, BiomeGenBase.desertHills, BiomeGenBase.extremeHills, BiomeGenBase.extremeHillsEdge, BiomeGenBase.extremeHillsPlus, BiomeGenBase.forest, BiomeGenBase.forestHills, BiomeGenBase.jungle, BiomeGenBase.jungleEdge, BiomeGenBase.jungleHills, BiomeGenBase.mesa, BiomeGenBase.mesaPlateau, BiomeGenBase.mesaPlateau_F, BiomeGenBase.plains, BiomeGenBase.river, BiomeGenBase.roofedForest, BiomeGenBase.savanna, BiomeGenBase.savannaPlateau); EntityList.idToClassMapping.put(id, EntityMimic.class); EntityList.entityEggs.put(id, new EntityEggInfo(id, 113213, 3523523)); id++; I did some more experimenting and it seems that they'll just despawn as soon as I look away. I also can't find the onInitialSpawn method in EntityMob, EntityCreature, EntityLiving or EntityLivingBase.
July 10, 201510 yr Update your MCP mappings, then - it's from EntityLiving: public IEntityLivingData onInitialSpawn(DifficultyInstance difficulty, IEntityLivingData data) To debug why your entity despawns immediately, we'd need to see your entire Entity class code. http://i.imgur.com/NdrFdld.png[/img]
July 10, 201510 yr Author I'll update MCP in a sec, here's the entity code. It's pretty barebones right now: package twain.brightRPG.entity; import java.util.UUID; 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.EntityAIMoveThroughVillage; import net.minecraft.entity.ai.EntityAIMoveTowardsRestriction; 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.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.DifficultyInstance; import net.minecraft.world.EnumDifficulty; import net.minecraft.world.World; import twain.brightRPG.BrightRPG; public class EntityMimic extends EntityMob { private UUID field_175459_bn; public EntityMimic(World par1World) { super(par1World); this.tasks.addTask(0, new EntityAISwimming(this)); this.tasks.addTask(1, new EntityAIAttackOnCollide(this, EntityPlayer.class, 0.6D, false)); this.tasks.addTask(2, new EntityAIAttackOnCollide(this, EntityVillager.class, 0.6D, true)); this.tasks.addTask(3, new EntityAIMoveTowardsRestriction(this, 1.0D)); this.tasks.addTask(4, new EntityAIMoveThroughVillage(this, 0.6D, true)); this.tasks.addTask(5, new EntityAIWander(this, 0.6D)); this.tasks.addTask(6, new EntityAIWatchClosest(this, EntityPlayer.class, 7.0F)); this.tasks.addTask(7, new EntityAILookIdle(this)); this.targetTasks.addTask(0, new EntityAIHurtByTarget(this, true)); this.setSize(0.6F, 1.8F); } @Override protected void applyEntityAttributes() { super.applyEntityAttributes(); this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(20.0D);; this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.6D); this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(3.0D); } @Override protected String getLivingSound() { return null; } @Override protected String getHurtSound() { return "brightRPG:mimicHurt"; } @Override protected String getDeathSound() { return "brightRPG:mimicDeath"; } @Override protected float getSoundVolume() { return 0.4F; } @Override public void setRevengeTarget(EntityLivingBase livingBase) { super.setRevengeTarget(livingBase); if (livingBase != null) { this.field_175459_bn = livingBase.getUniqueID(); } } @Override public boolean getCanSpawnHere() { return this.worldObj.getDifficulty() != EnumDifficulty.PEACEFUL && super.getCanSpawnHere(); } }
July 10, 201510 yr That is certainly pretty bare bones... you don't happen to be on Peaceful, do you? Otherwise, do you have any tick handlers or other events somewhere that kill entities? Do you get any strange output in your console? What version of Forge are you on? http://i.imgur.com/NdrFdld.png[/img]
July 10, 201510 yr Author All no...it's really perplexing. I've tried each difficulty setting and then just running around the world looking, but it's only near the spawn. I'm using forge 11.14.3.1450.
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.