From af38870e90d108cdd9ed150712509e6d1d509354 Mon Sep 17 00:00:00 2001 From: Adubbz Date: Mon, 13 May 2013 08:22:17 +1000 Subject: [PATCH] Added animals to the Promised Lands. Only thing that is left to do is limiting the amount spawned. --- .../biomes/BiomeGenPromisedLandForest.java | 18 +++++++++++++++ .../biomes/BiomeGenPromisedLandPlains.java | 16 +++++++++++++ .../biomes/BiomeGenPromisedLandSwamp.java | 18 +++++++++++++++ .../biomesoplenty/blocks/BlockBOPGrass.java | 5 +++- .../biomesoplenty/helpers/EntitiesHelper.java | 23 +++++++++++++++++++ .../world/WorldProviderPromised.java | 6 +++++ 6 files changed, 85 insertions(+), 1 deletion(-) diff --git a/src/minecraft/biomesoplenty/biomes/BiomeGenPromisedLandForest.java b/src/minecraft/biomesoplenty/biomes/BiomeGenPromisedLandForest.java index 9538036dc..9408d7089 100644 --- a/src/minecraft/biomesoplenty/biomes/BiomeGenPromisedLandForest.java +++ b/src/minecraft/biomesoplenty/biomes/BiomeGenPromisedLandForest.java @@ -3,6 +3,8 @@ package biomesoplenty.biomes; import java.awt.Color; import java.util.Random; +import cpw.mods.fml.common.Loader; + import biomesoplenty.api.Blocks; import biomesoplenty.configuration.BOPBlocks; import biomesoplenty.configuration.BOPConfiguration; @@ -13,8 +15,11 @@ import biomesoplenty.worldgen.WorldGenPromisedTree3; import biomesoplenty.worldgen.WorldGenWaterSpring; import net.minecraft.block.Block; +import net.minecraft.entity.monster.EntityWitch; +import net.minecraft.entity.passive.EntityCow; import net.minecraft.world.World; import net.minecraft.world.biome.BiomeGenBase; +import net.minecraft.world.biome.SpawnListEntry; import net.minecraft.world.gen.feature.WorldGenMinable; import net.minecraft.world.gen.feature.WorldGenerator; @@ -49,6 +54,19 @@ public class BiomeGenPromisedLandForest extends BiomeGenBase this.customBiomeDecorator.generateClouds = true; //this.customBiomeDecorator.generateLakes = false; this.theWorldGenerator = new WorldGenWaterSpring(Block.waterMoving.blockID, 8); + this.spawnableMonsterList.add(new SpawnListEntry(EntityCow.class, 6, 1, 4)); + + if (Loader.isModLoaded("TwilightForest")) + { + try { + this.spawnableMonsterList.add(new SpawnListEntry(Class.forName("twilightforest.entity.passive.EntityTFBighorn"), 2, 1, 3)); + this.spawnableMonsterList.add(new SpawnListEntry(Class.forName("twilightforest.entity.passive.EntityTFDeer"), 4, 1, 3)); + this.spawnableMonsterList.add(new SpawnListEntry(Class.forName("twilightforest.entity.passive.EntityTFBird"), 2, 1, 3)); + } catch (ClassNotFoundException e) { + System.out.println("[BiomesOPlenty] There was an error while integrating Twilight Forest with Biomes O' Plenty!"); + e.printStackTrace(); + } + } } /** diff --git a/src/minecraft/biomesoplenty/biomes/BiomeGenPromisedLandPlains.java b/src/minecraft/biomesoplenty/biomes/BiomeGenPromisedLandPlains.java index 6005ffccb..3a018ce81 100644 --- a/src/minecraft/biomesoplenty/biomes/BiomeGenPromisedLandPlains.java +++ b/src/minecraft/biomesoplenty/biomes/BiomeGenPromisedLandPlains.java @@ -3,6 +3,8 @@ package biomesoplenty.biomes; import java.awt.Color; import java.util.Random; +import cpw.mods.fml.common.Loader; + import biomesoplenty.api.Blocks; import biomesoplenty.configuration.BOPBlocks; import biomesoplenty.configuration.BOPConfiguration; @@ -14,8 +16,10 @@ import biomesoplenty.worldgen.WorldGenPromisedTree3; import biomesoplenty.worldgen.WorldGenWaterSpring; import net.minecraft.block.Block; +import net.minecraft.entity.passive.EntityCow; import net.minecraft.world.World; import net.minecraft.world.biome.BiomeGenBase; +import net.minecraft.world.biome.SpawnListEntry; import net.minecraft.world.gen.feature.WorldGenMinable; import net.minecraft.world.gen.feature.WorldGenerator; @@ -48,6 +52,18 @@ public class BiomeGenPromisedLandPlains extends BiomeGenBase this.customBiomeDecorator.generateClouds = true; //this.customBiomeDecorator.generateLakes = false; this.theWorldGenerator = new WorldGenWaterSpring(Block.waterMoving.blockID, 8); + + if (Loader.isModLoaded("TwilightForest")) + { + try { + this.spawnableMonsterList.add(new SpawnListEntry(Class.forName("twilightforest.entity.passive.EntityTFBird"), 2, 1, 3)); + this.spawnableMonsterList.add(new SpawnListEntry(Class.forName("twilightforest.entity.passive.EntityTFBunny"), 4, 1, 3)); + this.spawnableMonsterList.add(new SpawnListEntry(Class.forName("twilightforest.entity.passive.EntityTFSquirrel"), 4, 1, 2)); + } catch (ClassNotFoundException e) { + System.out.println("[BiomesOPlenty] There was an error while integrating Twilight Forest with Biomes O' Plenty!"); + e.printStackTrace(); + } + } } /** diff --git a/src/minecraft/biomesoplenty/biomes/BiomeGenPromisedLandSwamp.java b/src/minecraft/biomesoplenty/biomes/BiomeGenPromisedLandSwamp.java index 4cc92d674..501dc08f2 100644 --- a/src/minecraft/biomesoplenty/biomes/BiomeGenPromisedLandSwamp.java +++ b/src/minecraft/biomesoplenty/biomes/BiomeGenPromisedLandSwamp.java @@ -3,17 +3,23 @@ package biomesoplenty.biomes; import java.awt.Color; import java.util.Random; +import cpw.mods.fml.common.Loader; + import biomesoplenty.api.Blocks; import biomesoplenty.configuration.BOPBlocks; import biomesoplenty.configuration.BOPConfiguration; +import biomesoplenty.integration.ThaumcraftIntegration; import biomesoplenty.worldgen.WorldGenPromisedShrub; import biomesoplenty.worldgen.WorldGenPromisedTree; import biomesoplenty.worldgen.WorldGenPromisedWillowTree; import biomesoplenty.worldgen.WorldGenWaterSpring; import net.minecraft.block.Block; +import net.minecraft.entity.passive.EntityCow; +import net.minecraft.entity.passive.EntityPig; import net.minecraft.world.World; import net.minecraft.world.biome.BiomeGenBase; +import net.minecraft.world.biome.SpawnListEntry; import net.minecraft.world.gen.feature.WorldGenerator; public class BiomeGenPromisedLandSwamp extends BiomeGenBase @@ -49,6 +55,18 @@ public class BiomeGenPromisedLandSwamp extends BiomeGenBase this.customBiomeDecorator.generateClouds = true; //this.customBiomeDecorator.generateLakes = false; this.theWorldGenerator = new WorldGenWaterSpring(Block.waterMoving.blockID, 8); + this.spawnableMonsterList.add(new SpawnListEntry(EntityPig.class, 4, 1, 4)); + + if (Loader.isModLoaded("TwilightForest")) + { + try { + this.spawnableMonsterList.add(new SpawnListEntry(Class.forName("twilightforest.entity.passive.EntityTFBird"), 2, 1, 3)); + this.spawnableMonsterList.add(new SpawnListEntry(Class.forName("twilightforest.entity.passive.EntityTFRaven"), 1, 1, 2)); + } catch (ClassNotFoundException e) { + System.out.println("[BiomesOPlenty] There was an error while integrating Twilight Forest with Biomes O' Plenty!"); + e.printStackTrace(); + } + } } /** diff --git a/src/minecraft/biomesoplenty/blocks/BlockBOPGrass.java b/src/minecraft/biomesoplenty/blocks/BlockBOPGrass.java index 957d91685..071acd8c2 100644 --- a/src/minecraft/biomesoplenty/blocks/BlockBOPGrass.java +++ b/src/minecraft/biomesoplenty/blocks/BlockBOPGrass.java @@ -6,10 +6,13 @@ import java.util.List; import java.util.Random; import net.minecraft.block.Block; +import net.minecraft.block.BlockStairs; +import net.minecraft.block.BlockStep; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.Entity; +import net.minecraft.entity.EnumCreatureType; import net.minecraft.item.ItemStack; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.Icon; @@ -56,7 +59,7 @@ public class BlockBOPGrass extends Block { return blockIcon[meta][side]; } - + @Override @SuppressWarnings({ "rawtypes", "unchecked" }) public void getSubBlocks(int blockID, CreativeTabs creativeTabs, List list) { diff --git a/src/minecraft/biomesoplenty/helpers/EntitiesHelper.java b/src/minecraft/biomesoplenty/helpers/EntitiesHelper.java index 72c97712e..95eabdf41 100644 --- a/src/minecraft/biomesoplenty/helpers/EntitiesHelper.java +++ b/src/minecraft/biomesoplenty/helpers/EntitiesHelper.java @@ -1,5 +1,6 @@ package biomesoplenty.helpers; +import net.minecraft.block.Block; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityCreature; import net.minecraft.entity.EntityLiving; @@ -7,8 +8,18 @@ import net.minecraft.entity.passive.EntityChicken; import net.minecraft.entity.passive.EntityCow; import net.minecraft.entity.passive.EntityPig; import net.minecraft.entity.passive.EntitySheep; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.Event.Result; +import net.minecraftforge.event.ForgeEventFactory; import net.minecraftforge.event.ForgeSubscribe; +import net.minecraftforge.event.Event.HasResult; import net.minecraftforge.event.entity.EntityJoinWorldEvent; +import net.minecraftforge.event.entity.living.LivingPackSizeEvent; +import net.minecraftforge.event.entity.living.LivingSpawnEvent; +import net.minecraftforge.event.entity.living.LivingSpawnEvent.CheckSpawn; +import biomesoplenty.api.Blocks; import biomesoplenty.api.Items; import biomesoplenty.mobs.ai.EntityAITemptArmour; @@ -34,4 +45,16 @@ public class EntitiesHelper if (entity instanceof EntityCow) ((EntityLiving)entity).tasks.addTask(3, new EntityAITemptArmour((EntityCreature) entity, 0.25F, Items.flowerBand.get().itemID, 3, false)); } + + @ForgeSubscribe + public void canEntitySpawn(LivingSpawnEvent event) + { + + int i = MathHelper.floor_double(event.entity.posX); + int j = MathHelper.floor_double(event.entity.boundingBox.minY); + int k = MathHelper.floor_double(event.entity.posZ); + + if (event.entity.worldObj.getBlockId(i, j - 1, k) == Blocks.holyGrass.get().blockID && event.entity.worldObj.getFullBlockLightValue(i, j, k) > 8) + event.setResult(Result.ALLOW); + } } diff --git a/src/minecraft/biomesoplenty/world/WorldProviderPromised.java b/src/minecraft/biomesoplenty/world/WorldProviderPromised.java index 72d03b3f6..050b361c1 100644 --- a/src/minecraft/biomesoplenty/world/WorldProviderPromised.java +++ b/src/minecraft/biomesoplenty/world/WorldProviderPromised.java @@ -137,6 +137,12 @@ public class WorldProviderPromised extends WorldProvider var6 *= var3 * 0.91F + 0.09F; return this.worldObj.getWorldVec3Pool().getVecFromPool((double)var4, (double)var5, (double)var6); } + + @Override + public void setAllowedSpawnTypes(boolean allowHostile, boolean allowPeaceful) + { + allowPeaceful = true; + } @Override public String getWelcomeMessage()