Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Much mob spawning!


MikeDark
 Share

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
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.

 Share



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • It doesn't work even if I remove every mod Please help
    • Hi, so I was making an item that sends info to the server to do some work, and I want the server to send the client back the results? How do I do that? Here is my code:   The snippet that sends the packet to the server SimpleChannelNetwork.CHANNEL.sendToServer(new CreateStructureCompass("fortress"));   The file that manage the traffic package io.github.bossmania.NetherandEndMaps.core.network; import io.github.bossmania.NetherandEndMaps.NetherandEndMaps; import io.github.bossmania.NetherandEndMaps.core.network.message.CreateStructureCompass; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.network.NetworkRegistry; import net.minecraftforge.fml.network.simple.SimpleChannel; public class SimpleChannelNetwork { public static final String NETWORK_VERSION = "0.1.0"; public static final SimpleChannel CHANNEL = NetworkRegistry.newSimpleChannel( new ResourceLocation(NetherandEndMaps.MOD_ID, "network"), () -> NETWORK_VERSION, version -> version.equals(NETWORK_VERSION), version -> version.equals(NETWORK_VERSION)); public static void init() { CHANNEL.registerMessage(0, CreateStructureCompass.class ,CreateStructureCompass::encode, CreateStructureCompass::decode, CreateStructureCompass::handle); } }   the code that handle the packet receive and where I want the server to send back a packet to the client package io.github.bossmania.NetherandEndMaps.core.network.message; import java.util.function.Supplier; import io.github.bossmania.NetherandEndMaps.common.items.TemporaryItem; import net.minecraft.entity.player.ServerPlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.network.PacketBuffer; import net.minecraft.util.math.BlockPos; import net.minecraft.world.gen.feature.structure.Structure; import net.minecraft.world.server.ServerWorld; import net.minecraftforge.fml.network.NetworkEvent; import net.minecraft.item.Item; import net.minecraft.item.ItemGroup; public class CreateStructureCompass { public String structureType; public CreateStructureCompass() { } //create the constructor and store the structureType public CreateStructureCompass(String structureType) { this.structureType = structureType; } //encode the message public static void encode(CreateStructureCompass message, PacketBuffer buffer) { buffer.writeString(message.structureType); } //decode the message public static CreateStructureCompass decode(PacketBuffer buffer) { return new CreateStructureCompass(buffer.readString()); } //execute function when message is sent to server public static void handle(CreateStructureCompass message, Supplier<NetworkEvent.Context> contextSupplier) { NetworkEvent.Context context = contextSupplier.get(); context.enqueueWork(() -> { //get the player and the server ServerPlayerEntity player = context.getSender(); ServerWorld SEWorld = player.getServerWorld(); //get the location of the structure BlockPos structureLocation = SEWorld.func_241117_a_(Structure.FORTRESS, player.getPosition(),100, false); //this is where I want the server to send structureLocation back to the player }); context.setPacketHandled(true); } }  
    • I cannot get an instance of MC Forge to run with either the vanilla launcher or GDLauncher, yet vanilla MC and Fabric MC work fine in both.  I am running the latest versions of everything, and no 1.18-compatible version of Forge will launch even though they all install without fail. Using the vanilla launcher I get exit code 0 and the following logs: Debug log Latest log With GDLauncher I get the following console output:  
    • In 1.15 and before, you could get the item being held/dragged by the cursor using PlayerInventory#getItemStack. This no longer seems to be the case. How do we do this now?
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.