Jump to content

Much mob spawning!


MikeDark

Recommended Posts

Hello everyone, I'm suffering from a problem on the spawn of my mobs, even putting a low rate, spawn limit per chunk, among others, and many of them are appearing and that ends up being bad, and would like to ask help to solve this problem...

 

The Problem:

 

rEbSHDe.jpg

 

My Bear Entity:

 

package mike.scoutcraft.entity;

import mike.scoutcraft.items.SCItems;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.EntityAIAttackOnCollide;
import net.minecraft.entity.ai.EntityAIHurtByTarget;
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.EntityVillager;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.world.World;

public class EntityUrsoPreto extends EntityMob {

public EntityUrsoPreto(World world) {
	super(world);
	this.experienceValue=5;
	this.setSize(1.8F, 1.25F);
	this.tasks.addTask(0, new EntityAISwimming(this));
        this.tasks.addTask(1, new EntityAIAttackOnCollide(this, EntityPlayer.class, 1.0D, true));
        this.tasks.addTask(1, new EntityAIAttackOnCollide(this, EntityVillager.class, 1.0D, false));
        this.tasks.addTask(3, new EntityAIWander(this, 1.0D));
        this.tasks.addTask(4, new EntityAIWatchClosest(this, EntityPlayer.class, 12.0F));
        this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, true));
        this.targetTasks.addTask(1, new EntityAINearestAttackableTarget(this, EntityPlayer.class, 0, true));
        this.targetTasks.addTask(1, new EntityAINearestAttackableTarget(this, EntityVillager.class, 0, false));
}

@Override
    protected void applyEntityAttributes()
    {
        
        super.applyEntityAttributes();
        this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(5.0D);
        this.getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(16.0D);
        this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.30D);
        this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(30.0D);
        
    }
protected boolean isAIEnabled()
    {
        return true;
    }

@Override
public int getMaxSpawnedInChunk() {
   return 2;
}

@Override
protected boolean isValidLightLevel()
{
	 return true;
}

 @Override
 public boolean getCanSpawnHere()
 {
	 return true;
 }

 protected Item getDropItem(){
	return SCItems.CouroDeUrso;
}

 protected void dropRareDrop(int par1){
		switch (this.rand.nextInt(3)){

		case 0:


		}
	}

 protected String getLivingSound()
 {
  return "scoutcraft:rugidourso";
 }

   
 protected String getHurtSound()
 {
   return "scoutcraft:machucarurso";
 }

  
 protected String getDeathSound()
 {
   return "scoutcraft:matarurso";
 }	
}

 

My entity registration and the spawn registry:

 

package mike.scoutcraft.entity;

import mike.scoutcraft.main.ScoutCraft;
import net.minecraft.entity.EntityList;
import net.minecraft.entity.EnumCreatureType;
import net.minecraft.world.biome.BiomeGenBase;
import cpw.mods.fml.common.registry.EntityRegistry;

public class SCMobs {

public static void mainRegistry(){
	registerEntity();
}

public static void registerEntity(){

	createEntity(EntityUrsoMarrom.class, "UrsoMarrom", 0xD62727, 0x27A2D6);
	createEntity(EntityUrsoPreto.class, "UrsoPreto", 0xD62727, 0x27A2D6);
	createEntity(EntityFormiga.class, "Formiga", 0xD62727, 0x27A2D6);
	createEntity(EntityCupim.class, "Cupim", 0xD62727, 0x27A2D6);
	createEntity(EntityGuaxinim.class, "Guaxinim", 0xD62727, 0x27A2D6);
	createEntity(EntityGuaxinimLadrao.class, "GuaxinimLadrao", 0xD62727, 0x27A2D6);

}

public static void createEntity(Class entityClass, String entityName, int solidColour, int spotColour){
	int randomId = EntityRegistry.findGlobalUniqueEntityId();

	EntityRegistry.registerGlobalEntityID(entityClass, entityName, randomId);
	EntityRegistry.registerModEntity(entityClass, entityName, randomId, ScoutCraft.Instance, 64, 1, true);
	createEgg(randomId, solidColour, spotColour);
	EntityRegistry.addSpawn(EntityUrsoMarrom.class, 2, 1, 1, EnumCreatureType.monster, BiomeGenBase.beach, BiomeGenBase.birchForest, BiomeGenBase.birchForestHills, BiomeGenBase.coldBeach, BiomeGenBase.coldTaiga, BiomeGenBase.coldTaigaHills, BiomeGenBase.extremeHills, BiomeGenBase.extremeHillsEdge, BiomeGenBase.extremeHillsPlus, BiomeGenBase.forest, BiomeGenBase.forestHills, BiomeGenBase.frozenRiver, BiomeGenBase.iceMountains, BiomeGenBase.icePlains, BiomeGenBase.jungle, BiomeGenBase.jungleEdge, BiomeGenBase.jungleHills, BiomeGenBase.megaTaiga, BiomeGenBase.megaTaigaHills, BiomeGenBase.mesa, BiomeGenBase.mesaPlateau, BiomeGenBase.mesaPlateau_F, BiomeGenBase.mushroomIsland, BiomeGenBase.mushroomIslandShore, BiomeGenBase.plains, BiomeGenBase.river, BiomeGenBase.roofedForest, BiomeGenBase.savanna, BiomeGenBase.savannaPlateau, BiomeGenBase.stoneBeach, BiomeGenBase.swampland, BiomeGenBase.taiga, BiomeGenBase.taigaHills);
	EntityRegistry.addSpawn(EntityUrsoPreto.class, 2, 1, 1, EnumCreatureType.monster, BiomeGenBase.beach, BiomeGenBase.birchForest, BiomeGenBase.birchForestHills, BiomeGenBase.coldBeach, BiomeGenBase.coldTaiga, BiomeGenBase.coldTaigaHills, BiomeGenBase.extremeHills, BiomeGenBase.extremeHillsEdge, BiomeGenBase.extremeHillsPlus, BiomeGenBase.forest, BiomeGenBase.forestHills, BiomeGenBase.frozenRiver, BiomeGenBase.iceMountains, BiomeGenBase.icePlains, BiomeGenBase.jungle, BiomeGenBase.jungleEdge, BiomeGenBase.jungleHills, BiomeGenBase.megaTaiga, BiomeGenBase.megaTaigaHills, BiomeGenBase.mesa, BiomeGenBase.mesaPlateau, BiomeGenBase.mesaPlateau_F, BiomeGenBase.mushroomIsland, BiomeGenBase.mushroomIslandShore, BiomeGenBase.plains, BiomeGenBase.river, BiomeGenBase.roofedForest, BiomeGenBase.savanna, BiomeGenBase.savannaPlateau, BiomeGenBase.stoneBeach, BiomeGenBase.swampland, BiomeGenBase.taiga, BiomeGenBase.taigaHills);
	EntityRegistry.addSpawn(EntityGuaxinim.class, 3, 1, 2, EnumCreatureType.creature, BiomeGenBase.beach, BiomeGenBase.birchForest, BiomeGenBase.birchForestHills, BiomeGenBase.coldBeach, BiomeGenBase.coldTaiga, BiomeGenBase.coldTaigaHills, BiomeGenBase.extremeHills, BiomeGenBase.extremeHillsEdge, BiomeGenBase.extremeHillsPlus, BiomeGenBase.forest, BiomeGenBase.forestHills, BiomeGenBase.frozenRiver, BiomeGenBase.iceMountains, BiomeGenBase.icePlains, BiomeGenBase.jungle, BiomeGenBase.jungleEdge, BiomeGenBase.jungleHills, BiomeGenBase.megaTaiga, BiomeGenBase.megaTaigaHills, BiomeGenBase.mesa, BiomeGenBase.mesaPlateau, BiomeGenBase.mesaPlateau_F, BiomeGenBase.mushroomIsland, BiomeGenBase.mushroomIslandShore, BiomeGenBase.plains, BiomeGenBase.river, BiomeGenBase.roofedForest, BiomeGenBase.savanna, BiomeGenBase.savannaPlateau, BiomeGenBase.stoneBeach, BiomeGenBase.swampland, BiomeGenBase.taiga, BiomeGenBase.taigaHills);
	EntityRegistry.addSpawn(EntityGuaxinimLadrao.class, 1, 1, 1, EnumCreatureType.creature, BiomeGenBase.beach, BiomeGenBase.birchForest, BiomeGenBase.birchForestHills, BiomeGenBase.coldBeach, BiomeGenBase.coldTaiga, BiomeGenBase.coldTaigaHills, BiomeGenBase.extremeHills, BiomeGenBase.extremeHillsEdge, BiomeGenBase.extremeHillsPlus, BiomeGenBase.forest, BiomeGenBase.forestHills, BiomeGenBase.frozenRiver, BiomeGenBase.iceMountains, BiomeGenBase.icePlains, BiomeGenBase.jungle, BiomeGenBase.jungleEdge, BiomeGenBase.jungleHills, BiomeGenBase.megaTaiga, BiomeGenBase.megaTaigaHills, BiomeGenBase.mesa, BiomeGenBase.mesaPlateau, BiomeGenBase.mesaPlateau_F, BiomeGenBase.mushroomIsland, BiomeGenBase.mushroomIslandShore, BiomeGenBase.plains, BiomeGenBase.river, BiomeGenBase.roofedForest, BiomeGenBase.savanna, BiomeGenBase.savannaPlateau, BiomeGenBase.stoneBeach, BiomeGenBase.swampland, BiomeGenBase.taiga, BiomeGenBase.taigaHills);

}

private static void createEgg(int randomId, int solidColour, int spotColour) {
	EntityList.entityEggs.put(Integer.valueOf(randomId), new EntityList.EntityEggInfo(randomId, solidColour, spotColour));
}
}

Link to comment
Share on other sites

I'm not sure if you attached the picture you meant to attach -- does that picture have a bunch of bears in it?

 

Anyway, I think the problem is that you add the spawns for all your bear types each time you register an individual bear.  For example, you call createEntity() for EntityUrsoMarrom but in the createEntity() code you add spawns for UrsoPreto, etc.

 

I think you should remove the add spawn code to a separate method and only call it once after you've registered all the entities.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Link to comment
Share on other sites

I'm not sure if you attached the picture you meant to attach -- does that picture have a bunch of bears in it?

 

Anyway, I think the problem is that you add the spawns for all your bear types each time you register an individual bear.  For example, you call createEntity() for EntityUrsoMarrom but in the createEntity() code you add spawns for UrsoPreto, etc.

 

I think you should remove the add spawn code to a separate method and only call it once after you've registered all the entities.

 

Well actually the image was not very clear, but I discovered that the problem was in the plains as in mountainous or forest biomes it they appears in smaller quantities... Good but after solving this problem I came across one that I had not realized, the collision box that it is too big for the sides, however is perfect on the front and top, how can I fix?

 

68z6isG.png

Link to comment
Share on other sites

Unfortunately, the collision boxes in Minecraft have x and z dimensions need to be equal. I think this helps the code do path finding but can pose a problem if you've created a complex entity.  I suggest you just make it similar to how a cow or something has collision box -- won't cover whole entity, and won't perfectly size, but will be what Minecraft players already expect.

 

If you really needed to do a fancier collision box, then you basically have to create additional, invisible entities associated with your bear and if those get hit then damage the bear entity.  It is a bit tricky to program, but possible if you need it.

 

Overall, you normally have to compromise -- make the collision box a bit bigger than the entity width and bit smaller than entity length and you'll have most of the entity covered.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Link to comment
Share on other sites

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.