Jump to content

Recommended Posts

Posted (edited)

Hi! My problem is that MONSTERS are spawning in large amounts. Only in dark places, but amounts are really too big. There's no such problem with creatures. In entity code I have getMaxSpawnedInChunk() set to 2. What can be causing this problem?

Spawn Registry

Spoiler

        this.spawnableMonsterList.add(new Biome.SpawnListEntry(EntityHowler.class, 1, 1, 1));

 

EDIT:
Even when I set weight to some huge number I've got a lot of mobs. For e.g. 

Spoiler

        this.spawnableMonsterList.add(new Biome.SpawnListEntry(EntitySkylight.class, 98, 1, 1));

 

EDIT:
BiomeMysticForest
 

Spoiler

public class BiomeMysticForest extends KetherBiome
{
    protected static WorldGenAbstractTree TREE_FEATURE2 = new WorldGenBasicMysticTree(false);
    protected static WorldGenAbstractTree TREE_FEATURE3 = new WorldGenShinyTree(true);
    protected static WorldGenAbstractTree TREE_FEATURE4 = new WorldGenNewTree();
    protected static WorldGenCustomTree2 CUSTOMTREE2 = new WorldGenCustomTree2();
    //protected static final WorldGenAbstractTree CUSTOMTREE3 = new WorldGenMysticForestTree();
    protected static WorldGenAbstractTree CUSTOMTREE3 = new WorldGenMegaMysticTree(true,10,5,KCore.MysticLog.getDefaultState(),KCore.MysticLeaves.getDefaultState());
    protected static WorldGenMiniTallGrass TALLGRASS1 = new WorldGenMiniTallGrass(KCore.MysticTallGrass);
    protected static WorldGenMiniTallGrass TALLGRASS2 = new WorldGenMiniTallGrass(KCore.MysticMiniGrass);
    protected static WorldGenSingleGen SINGLEGEN = new WorldGenSingleGen();
    protected static WorldGenSingleGen SINGLEGEN2 = new WorldGenSingleGen(3);
    protected static WorldGenAbstractTree CUSTOMTREE4 = new WorldGenSoulTree(true);
    protected static WorldGenMysticMultiGrass GrassGen = new WorldGenMysticMultiGrass(KCore.SteppedSucculent);
    protected static WorldGenAbstractTree GAUSSIANTREE = new WorldGenCrownTree(true);

    public BiomeMysticForest(Biome.BiomeProperties properties)
    {
        super(properties);
        this.spawnableCreatureList.clear();
        this.spawnableCaveCreatureList.clear();
        this.spawnableMonsterList.clear();
        this.spawnableWaterCreatureList.clear();
        this.decorator=createBiomeDecorator();
        this.decorator.treesPerChunk = 3;
        this.decorator.extraTreeChance = 0F;
        this.decorator.flowersPerChunk = 0;
        this.decorator.grassPerChunk = 2;
        this.topBlock=KCore.CorruptedGrass.getDefaultState();
        this.fillerBlock=KCore.CorruptedDirt.getDefaultState();
        this.setRegistryName(KCore.MODID, "Mystic Forest");
        this.spawnableCreatureList.add(new Biome.SpawnListEntry(EntityMysticBird2.class, 12, 1, 2));
        this.spawnableCreatureList.add(new Biome.SpawnListEntry(EntityLivingFlower.class, 8, 1, 1));
        this.spawnableMonsterList.add(new Biome.SpawnListEntry(EntityHowler.class, 5, 1, 1));
        this.spawnableCreatureList.add(new Biome.SpawnListEntry(EntityMysticBird1.class, 12, 1, 2));
        this.spawnableMonsterList.add(new Biome.SpawnListEntry(EntitySkylight.class, 98, 1, 1));
        this.spawnableMonsterList.add(new Biome.SpawnListEntry(EntityFungite.class, 2, 1, 1));

    }

    public void decorate(World worldIn, Random random, BlockPos pos)
    {    
        super.decorate(worldIn, random, pos);
    }
    public WorldGenAbstractTree getRandomTreeFeature(Random rand)
    {
    	if(rand.nextInt(5)==2){
    		if(rand.nextInt(50)==0) {
    			return (WorldGenAbstractTree)TREE_FEATURE3;
    		}else {
        		return (WorldGenAbstractTree)TREE_FEATURE2;
    		}
    	}else if(rand.nextInt(10)==0) {
    		return GAUSSIANTREE;
    	}
    	else if(rand.nextInt(5)==3) {
    		return TREE_FEATURE4;
    	}else if(rand.nextInt(5)==1) {
    		return CUSTOMTREE2;
    	}else if(rand.nextInt(15)==2) {
    		return CUSTOMTREE4;
    	}
    	else{
            return (WorldGenAbstractTree)CUSTOMTREE3;
    	}    	
    }
    
    public WorldGenerator getRandomWorldGenForGrass(Random rand)
    {
    	int i=rand.nextInt(13);
    	WorldGenerator worldgen=TALLGRASS1;
    	if(i<10){
	    	if(i==1||i==2||i==3||i==8){
	    		worldgen=SINGLEGEN;
	    	}
	    	if(i==4||i==7){
	    		worldgen=TALLGRASS2;
	    	}
	    	if(i==5||i==6) {
	    		worldgen=SINGLEGEN2;
	    	}
    	}else{
    		if(i==10) {
    			worldgen=GrassGen;
    		}else {
        		worldgen=TALLGRASS1;
    		}
    	}
    	return worldgen;
    }

    @Override
    public void addDefaultFlowers(){
    }
    
    public void genTerrainBlocks(World worldIn, Random rand, ChunkPrimer chunkPrimerIn, int x, int z, double noiseVal)
    {
        this.generateBiomeTerrainMysticForest(worldIn, rand, chunkPrimerIn, x, z, noiseVal);
    }
    
    public final void generateBiomeTerrainMysticForest(World worldIn, Random rand, ChunkPrimer chunkPrimerIn, int x, int z, double noiseVal)
    {
        int i = worldIn.getSeaLevel();
        IBlockState iblockstate = this.topBlock;
        IBlockState iblockstate1 = this.fillerBlock;
        int j = -1;
        int k = (int)(noiseVal / 3.0D + 3.0D + rand.nextDouble() * 0.25D);
        int l = x & 15;
        int i1 = z & 15;
        BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos();

        for (int j1 = 255; j1 >= 0; --j1)
        {
            if (j1 <= rand.nextInt(5))
            {
                chunkPrimerIn.setBlockState(i1, j1, l, BEDROCK);
            }
            else
            {
                IBlockState iblockstate2 = chunkPrimerIn.getBlockState(i1, j1, l);

                if (iblockstate2.getMaterial() == Material.AIR)
                {
                    j = -1;
                }
                else if (iblockstate2.getBlock() == KCore.MythicStone)
                {
                    if (j == -1)
                    {
                        if (k <= 0)
                        {
                            iblockstate = AIR;
                            iblockstate1 = KCore.MythicStone.getDefaultState();
                        }
                        else if (j1 >= i - 4 && j1 <= i + 1)
                        {
                            iblockstate = this.topBlock;
                            iblockstate1 = this.fillerBlock;
                        }

                        if (j1 < i && (iblockstate == null || iblockstate.getMaterial() == Material.AIR))
                        {
                                iblockstate = WATER;
                        }

                        j = k;

                        if (j1 >= i - 1)
                        {
                            chunkPrimerIn.setBlockState(i1, j1, l, iblockstate);
                        }
                        else if (j1 < i - 7 - k)
                        {
                            iblockstate = AIR;
                            iblockstate1 = KCore.MythicStone.getDefaultState();
                            chunkPrimerIn.setBlockState(i1, j1, l, GRAVEL);
                        }
                        else
                        {
                            chunkPrimerIn.setBlockState(i1, j1, l, iblockstate1);
                        }
                    }
                    else if (j > 0)
                    {
                        --j;
                        chunkPrimerIn.setBlockState(i1, j1, l, iblockstate1);
                    }
                }
            }
        }
    }

}

 

Kether Biome
 

Spoiler

public abstract class KetherBiome extends Biome
{
    /** The biome decorator. */
    public BiomeDecorator decorator;

    public KetherBiome(Biome.BiomeProperties properties)
    {
    	super(properties);
        this.decorator = this.createBiomeDecorator();
    }

    public BiomeDecorator createBiomeDecorator()
    {
        return getModdedBiomeDecorator(new BiomeDecoratorMystic());
    }

    @SideOnly(Side.CLIENT)
    public int getSkyColorByTemp(float currentTemperature)
    {
        currentTemperature = currentTemperature / 3.0F;
        currentTemperature = MathHelper.clamp(currentTemperature, -1.0F, 1.0F);
        return MathHelper.hsvToRGB(0.62222224F - currentTemperature * 0.05F, 0.5F + currentTemperature * 0.1F, 1.0F);
    }


    public void decorate(World worldIn, Random rand, BlockPos pos)
    {
        this.decorator.decorate(worldIn, rand, this, pos);
    }

    @SideOnly(Side.CLIENT)
    public int getGrassColorAtPos(BlockPos pos)
    {
        double d0 = (double)MathHelper.clamp(this.getTemperature(pos), 0.0F, 1.0F);
        double d1 = (double)MathHelper.clamp(this.getRainfall(), 0.0F, 1.0F);
        return getModdedBiomeGrassColor(ColorizerGrass.getGrassColor(d0, d1));
    }

    @SideOnly(Side.CLIENT)
    public int getFoliageColorAtPos(BlockPos pos)
    {
        double d0 = (double)MathHelper.clamp(this.getTemperature(pos), 0.0F, 1.0F);
        double d1 = (double)MathHelper.clamp(this.getRainfall(), 0.0F, 1.0F);
        return getModdedBiomeFoliageColor(ColorizerFoliage.getFoliageColor(d0, d1));
    }

    public BiomeDecorator getModdedBiomeDecorator(BiomeDecorator original)
    {
        return new net.minecraftforge.event.terraingen.DeferredBiomeDecorator(original);
    }

    public int getModdedBiomeGrassColor(int original)
    {
        net.minecraftforge.event.terraingen.BiomeEvent.GetGrassColor event = new net.minecraftforge.event.terraingen.BiomeEvent.GetGrassColor(this, original);
        net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event);
        return event.getNewColor();
    }

    public int getModdedBiomeFoliageColor(int original)
    {
        net.minecraftforge.event.terraingen.BiomeEvent.GetFoliageColor event = new net.minecraftforge.event.terraingen.BiomeEvent.GetFoliageColor(this, original);
        net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event);
        return event.getNewColor();
    }
}

 


BiomeDecoratorMystic

Spoiler

public class BiomeDecoratorMystic extends BiomeDecorator {

	private static final int TitaniumPerChunk = 5;
	private static final int AdamantiumPerChunk = 2;
	private static final WorldGenMysticOre TitaniumGen = new WorldGenMysticOre(KCore.TitaniumOre.getDefaultState(), 3);
	private static final WorldGenMysticOre AdamantiumGen = new WorldGenMysticOre(KCore.AdamantiumOre.getDefaultState(), 1);

    public static final WorldGenCrystalChamber CrystalChamber = new WorldGenCrystalChamber();
    public static final WorldGenCloudTemple CloudTemple = new WorldGenCloudTemple();
    public static final WorldGenSingleGen EnergyShard = new WorldGenSingleGen(4);
    
	@Override
	public void decorate(World world, Random rand, Biome biome, BlockPos pos) {
		super.decorate(world, rand, biome, pos);
	}

	@Override
	protected void genDecorations(Biome biome, World world, Random random) {
        for(int j=0;j<this.treesPerChunk;j++){
			int rx = chunkPos.getX() + random.nextInt(16)+8;
			int rz = chunkPos.getZ() + random.nextInt(16)+8;
        		biome.getRandomTreeFeature(random).generate(world, random, world.getHeight(new BlockPos(rx, 0, rz)));
        }
        for (int i3 = 0; i3 < this.grassPerChunk; ++i3)
        {
			int rx = chunkPos.getX() + random.nextInt(16)+8;
			int rz = chunkPos.getZ() + random.nextInt(16)+8;
			biome.getRandomWorldGenForGrass(random).generate(world, random, world.getHeight(new BlockPos(rx, 0, rz)));
        }
	       for(int j=0;j<this.TitaniumPerChunk;j++){
	    		int X = chunkPos.getX() + random.nextInt(16)+8;
	    		int Z = chunkPos.getZ() + random.nextInt(16)+8;
	        	int j3=random.nextInt(248)+8;
	        	if(j3>0){
	        		int i4=random.nextInt(j3);
	        		BlockPos blockposnew = new BlockPos(X,i4,Z);
	        		TitaniumGen.generate(world, random, blockposnew);
	        	}
	        }
	        for(int j=0;j<this.AdamantiumPerChunk;j++){
	    		int X = chunkPos.getX() + random.nextInt(16)+8;
	    		int Z = chunkPos.getZ() + random.nextInt(16)+8;
	        	int j3=random.nextInt(248)+8;
	        	if(j3<30){
	        		int i4=random.nextInt(j3);
	        		BlockPos blockposnew = new BlockPos(X,i4,Z);
	        		AdamantiumGen.generate(world, random, blockposnew);
	        	}
	        }
	        
	        if(random.nextInt(100)==2) {
	    		int X = chunkPos.getX() + random.nextInt(16)+8;
	    		int Z = chunkPos.getZ() + random.nextInt(16)+8;
	        	int j3=random.nextInt(60)+8;
	        	if(j3<70&&j3>10){
	        		int i4=random.nextInt(j3)+8;
	        		BlockPos blockposnew = new BlockPos(X,i4,Z);
	        		CrystalChamber.generate(world, random, blockposnew);
	        	}
	        }

	        if(random.nextInt(3)==0) {
	    		int X = chunkPos.getX() + random.nextInt(16)+8;
	    		int Z = chunkPos.getZ() + random.nextInt(16)+8;
	        	int j3=85+random.nextInt(25)+random.nextInt(25)+random.nextInt(25)+random.nextInt(25);
	        	if(j3>0){
	        		BlockPos blockposnew = new BlockPos(X,j3,Z);
	        		new WorldGenClouds().generate(world, random, blockposnew);
	        	}
	        }
	        
	        if(random.nextInt(600)==0) {
	    		int X = chunkPos.getX() + random.nextInt(16)+8;
	    		int Z = chunkPos.getZ() + random.nextInt(16)+8;
	        	int j3=90+random.nextInt(45)+random.nextInt(45)+random.nextInt(45)+random.nextInt(45);
	        	if(j3>100&&j3<220){
	        		BlockPos blockposnew = new BlockPos(X,j3,Z);
	        		CloudTemple.generate(world, random, blockposnew);
	        	}
	        }
	        
	        if(random.nextInt(30)==0)
	        {
	    		int X = chunkPos.getX() + random.nextInt(16)+8;
	    		int Z = chunkPos.getZ() + random.nextInt(16)+8;
	    		BlockPos tmp = new BlockPos(X,0,Z);
	    		int TOP = world.getHeight(tmp).getY();
	        		BlockPos blockposnew = new BlockPos(X,TOP,Z);
	            EnergyShard.generate(world, random, blockposnew);
	        }
	}
	
    public WorldGenAbstractTree getRandomTreeFeature(Random rand)
    {
    	return null;
    }
    
    public WorldGenerator getRandomWorldGenForGrass(Random rand)
    {
    	return null;
    }

}

 

 

populateChunk method in my ChunkGenerator
 

Spoiler

   public void populate(int x, int z)
    {
        BlockFalling.fallInstantly = true;

        int i = x * 16;
        int j = z * 16;
        BlockPos blockpos = new BlockPos(i, 0, j);
        Biome biome = this.world.getBiome(blockpos.add(16, 0, 16));
        this.rand.setSeed(this.world.getSeed());
        long k = this.rand.nextLong() / 2L * 2L + 1L;
        long l = this.rand.nextLong() / 2L * 2L + 1L;
        this.rand.setSeed((long)x * k + (long)z * l ^ this.world.getSeed());
        boolean flag = false;
        ChunkPos chunkpos = new ChunkPos(x, z);

        net.minecraftforge.event.ForgeEventFactory.onChunkPopulate(true, this, this.world, this.rand, x, z, flag);


        if (biome != Biomes.DESERT && biome != Biomes.DESERT_HILLS && this.settings.useWaterLakes && !flag && this.rand.nextInt(this.settings.waterLakeChance) == 0)
        if (net.minecraftforge.event.terraingen.TerrainGen.populate(this, this.world, this.rand, x, z, flag, net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType.LAKE))
        {
            int i1 = this.rand.nextInt(16) + 8;
            int j1 = this.rand.nextInt(256);
            int k1 = this.rand.nextInt(16) + 8;
            (new WorldGenMysticLakes(Blocks.WATER)).generate(this.world, this.rand, blockpos.add(i1, j1, k1));
        }

        if (!flag && this.rand.nextInt(this.settings.lavaLakeChance / 10) == 0 && this.settings.useLavaLakes)
        if (net.minecraftforge.event.terraingen.TerrainGen.populate(this, this.world, this.rand, x, z, flag, net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType.LAVA))
        {
            int i2 = this.rand.nextInt(16) + 8;
            int l2 = this.rand.nextInt(this.rand.nextInt(248) + 8);
            int k3 = this.rand.nextInt(16) + 8;

            if (l2 < this.world.getSeaLevel() || this.rand.nextInt(this.settings.lavaLakeChance / 8) == 0)
            {
                (new WorldGenMysticLakes(Blocks.LAVA)).generate(this.world, this.rand, blockpos.add(i2, l2, k3));
            }
        }

        biome.decorate(this.world, this.rand, new BlockPos(i, 0, j));
        if (net.minecraftforge.event.terraingen.TerrainGen.populate(this, this.world, this.rand, x, z, flag, net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType.ANIMALS))
        WorldEntitySpawner.performWorldGenSpawning(this.world, biome, i + 8, j + 8, 16, 16, this.rand);
        blockpos = blockpos.add(8, 0, 8);
        

        net.minecraftforge.event.ForgeEventFactory.onChunkPopulate(false, this, this.world, this.rand, x, z, flag);

        BlockFalling.fallInstantly = true;
    }

 

 

It appeared that the problem is very weird. There is only problem with EntitySkylight during the day. During the night they almost don't spawn. 

Edited by Krevik
Posted
12 hours ago, jabelar said:

Well, the first parameter is the spawn "weight" meaning it affects the chance of spawning. You have it set very low so I think it will spawn all the time. Normally mobs like zombies have value of 95 there.

Thanks! I thought this works same as with animals, cause animals with spawn rate like 1 spawn very rare

Posted
2 minutes ago, diesieben07 said:

The opposite is the case. The higher the weight the higher the spawn chance compared to other mobs.

But how that fix my problem? Whenever I change the value to low or high, there are lot's of mobs. That applies only to MONSTERS

Posted (edited)
6 hours ago, diesieben07 said:

The opposite is the case. The higher the weight the higher the spawn chance compared to other mobs.

You're right, but the the reason I made my statement about the lower being more common is that entities like pigs have weight of 12 and entity like zombie has weight of 100. However, I see now that each list (creatures, monsters, water creatures) the vanilla weight levels are quite different. 

 

Tuning weight numbers can be a bit tricky because they are relative to the total weight. In other words, every time you add an entity, the chance of all other entities spawning gets a bit smaller. But that shouldn't be an issue in this case.

 

In any case, my point was that he should use numbers similar to the vanilla entities when testing. Since he's looking at monsters, he should have number around 100 to spawn with similar frequency to zombies and skeletons. A number of 1 should be less frequent than a witch which is 5. If you want to see the default values, look at the constructor for the Biome base class.

 

Anyway, we need way more code than that to help you solve this problem. It obviously isn't this line of code causing the trouble. Is this problem related to a custom biome? If so, maybe you're calling the generation code way more times than you think (and therefore generating more of the entity). Or something like that.

Edited by jabelar

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

Posted
3 hours ago, jabelar said:

every time you add an entity, the chance of all other entities spawning gets a bit smaller. But that shouldn't be an issue in this case.

Uh...duh?

When you buy more socks, the odds that you grab a white one out of your sock drawer at random changes.

Vanilla doesn't want to spawn more total mobs as the variety increases (otherwise you reach a hyperbolic example of a billion different mobs and vanilla insures that at least one of each is spawened at any given time, making it impossible to move without running into something) so the actual percentage chance goes down.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted (edited)
2 hours ago, Draco18s said:

Uh...duh?

When you buy more socks, the odds that you grab a white one out of your sock drawer at random changes.

Vanilla doesn't want to spawn more total mobs as the variety increases (otherwise you reach a hyperbolic example of a billion different mobs and vanilla insures that at least one of each is spawened at any given time, making it impossible to move without running into something) so the actual percentage chance goes down.

I know this but was teaching a beginner about what a weighted system means. For testing purposes I was basically telling the OP to copy a number used by vanilla, but I could see him/her then going off and adding a dozen more entities later with the same number, so I wanted to warn him/her about that.

 

Also, although it is true that there is a good reason to limit the total entities, it is also reasonable for a modder to want to add a bit more prolific entities to the game. This is especially true where game balance is concerned. Like if I wanted to add flocks of seagulls, I wouldn't necessarily want food entities like pigs to become more scarce. So it is worth them understanding that they are not really adding to the overall fauna but rather substituting spawns and making existing fauna more rare.

Edited by jabelar

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

Posted
11 hours ago, jabelar said:

I know this but was teaching a beginner about what a weighted system means. For testing purposes I was basically telling the OP to copy a number used by vanilla, but I could see him/her then going off and adding a dozen more entities later with the same number, so I wanted to warn him/her about that.

 

Also, although it is true that there is a good reason to limit the total entities, it is also reasonable for a modder to want to add a bit more prolific entities to the game. This is especially true where game balance is concerned. Like if I wanted to add flocks of seagulls, I wouldn't necessarily want food entities like pigs to become more scarce. So it is worth them understanding that they are not really adding to the overall fauna but rather substituting spawns and making existing fauna more rare.

Not so begginer as you think :P Will post rest of the code soon

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.