diff --git a/patches/minecraft/net/minecraft/entity/Entity.java.patch b/patches/minecraft/net/minecraft/entity/Entity.java.patch index fde11d73ba..5f291b0367 100644 --- a/patches/minecraft/net/minecraft/entity/Entity.java.patch +++ b/patches/minecraft/net/minecraft/entity/Entity.java.patch @@ -112,7 +112,7 @@ } public boolean func_96091_a(Explosion par1Explosion, World par2World, int par3, int par4, int par5, int par6, float par7) -@@ -2455,4 +2487,89 @@ +@@ -2455,4 +2487,100 @@ { return this.getEntityName(); } @@ -200,5 +200,16 @@ + public boolean shouldRenderInPass(int pass) + { + return pass == 0; ++ } ++ ++ /** ++ * Returns true if the entity is of the @link{EnumCreatureType} provided ++ * @param type The EnumCreatureType type this entity is evaluating ++ * @param forSpawnCount If this is being invoked to check spawn count caps. ++ * @return If the creature is of the type provided ++ */ ++ public boolean isCreatureType(EnumCreatureType type, boolean forSpawnCount) ++ { ++ return type.getCreatureClass().isAssignableFrom(this.getClass()); + } } diff --git a/patches/minecraft/net/minecraft/world/SpawnerAnimals.java.patch b/patches/minecraft/net/minecraft/world/SpawnerAnimals.java.patch index fb4624bc37..aab5f13a51 100644 --- a/patches/minecraft/net/minecraft/world/SpawnerAnimals.java.patch +++ b/patches/minecraft/net/minecraft/world/SpawnerAnimals.java.patch @@ -19,8 +19,12 @@ public final class SpawnerAnimals { /** The 17x17 area around the player where mobs can spawn */ -@@ -93,6 +99,9 @@ - if ((!enumcreaturetype.getPeacefulCreature() || par2) && (enumcreaturetype.getPeacefulCreature() || par1) && (!enumcreaturetype.getAnimal() || par3) && par0WorldServer.countEntities(enumcreaturetype.getCreatureClass()) <= enumcreaturetype.getMaxNumberOfCreature() * eligibleChunksForSpawning.size() / 256) +@@ -90,9 +96,12 @@ + { + EnumCreatureType enumcreaturetype = aenumcreaturetype[j1]; + +- if ((!enumcreaturetype.getPeacefulCreature() || par2) && (enumcreaturetype.getPeacefulCreature() || par1) && (!enumcreaturetype.getAnimal() || par3) && par0WorldServer.countEntities(enumcreaturetype.getCreatureClass()) <= enumcreaturetype.getMaxNumberOfCreature() * eligibleChunksForSpawning.size() / 256) ++ if ((!enumcreaturetype.getPeacefulCreature() || par2) && (enumcreaturetype.getPeacefulCreature() || par1) && (!enumcreaturetype.getAnimal() || par3) && par0WorldServer.countEntities(enumcreaturetype, true) <= enumcreaturetype.getMaxNumberOfCreature() * eligibleChunksForSpawning.size() / 256) { Iterator iterator = eligibleChunksForSpawning.keySet().iterator(); + ArrayList tmp = new ArrayList(eligibleChunksForSpawning.keySet()); diff --git a/patches/minecraft/net/minecraft/world/World.java.patch b/patches/minecraft/net/minecraft/world/World.java.patch index 9ec54faf65..c603011259 100644 --- a/patches/minecraft/net/minecraft/world/World.java.patch +++ b/patches/minecraft/net/minecraft/world/World.java.patch @@ -1,6 +1,6 @@ --- ../src_base/minecraft/net/minecraft/world/World.java +++ ../src_work/minecraft/net/minecraft/world/World.java -@@ -51,8 +51,30 @@ +@@ -51,8 +51,31 @@ import net.minecraft.world.storage.MapStorage; import net.minecraft.world.storage.WorldInfo; @@ -16,6 +16,7 @@ +import net.minecraftforge.event.entity.EntityJoinWorldEvent; +import net.minecraftforge.event.world.WorldEvent; +import net.minecraftforge.event.entity.PlaySoundAtEntityEvent; ++import net.minecraft.entity.EnumCreatureType; + public abstract class World implements IBlockAccess { @@ -31,7 +32,7 @@ /** * boolean; if true updates scheduled by scheduleBlockUpdate happen immediately */ -@@ -163,6 +185,11 @@ +@@ -163,6 +186,11 @@ */ public BiomeGenBase getBiomeGenForCoords(int par1, int par2) { @@ -43,7 +44,7 @@ if (this.blockExists(par1, 0, par2)) { Chunk chunk = this.getChunkFromBlockCoords(par1, par2); -@@ -191,8 +218,14 @@ +@@ -191,8 +219,14 @@ this.theProfiler = par5Profiler; this.worldInfo = new WorldInfo(par4WorldSettings, par2Str); this.provider = par3WorldProvider; @@ -59,7 +60,7 @@ VillageCollection villagecollection = (VillageCollection)this.mapStorage.loadData(VillageCollection.class, "villages"); if (villagecollection == null) -@@ -206,7 +239,7 @@ +@@ -206,7 +240,7 @@ this.villageCollectionObj.func_82566_a(this); } @@ -68,7 +69,7 @@ this.chunkProvider = this.createChunkProvider(); this.calculateInitialSkylight(); this.calculateInitialWeather(); -@@ -219,7 +252,7 @@ +@@ -219,7 +253,7 @@ this.isRemote = false; this.saveHandler = par1ISaveHandler; this.theProfiler = par5Profiler; @@ -77,7 +78,7 @@ this.field_98181_L = par6ILogAgent; this.worldInfo = par1ISaveHandler.loadWorldInfo(); -@@ -273,12 +306,20 @@ +@@ -273,12 +307,20 @@ this.worldInfo.setServerInitialized(true); } @@ -100,7 +101,7 @@ } else { -@@ -288,6 +329,19 @@ +@@ -288,6 +330,19 @@ this.calculateInitialSkylight(); this.calculateInitialWeather(); @@ -120,7 +121,7 @@ } /** -@@ -371,7 +425,8 @@ +@@ -371,7 +426,8 @@ */ public boolean isAirBlock(int par1, int par2, int par3) { @@ -130,7 +131,7 @@ } /** -@@ -380,7 +435,8 @@ +@@ -380,7 +436,8 @@ public boolean blockHasTileEntity(int par1, int par2, int par3) { int l = this.getBlockId(par1, par2, par3); @@ -140,7 +141,7 @@ } /** -@@ -1132,7 +1188,7 @@ +@@ -1132,7 +1189,7 @@ */ public boolean isDaytime() { @@ -149,7 +150,7 @@ } /** -@@ -1164,7 +1220,7 @@ +@@ -1164,7 +1221,7 @@ int l1 = this.getBlockMetadata(l, i1, j1); Block block = Block.blocksList[k1]; @@ -158,7 +159,7 @@ { MovingObjectPosition movingobjectposition = block.collisionRayTrace(this, l, i1, j1, par1Vec3, par2Vec3); -@@ -1364,6 +1420,12 @@ +@@ -1364,6 +1421,12 @@ */ public void playSoundAtEntity(Entity par1Entity, String par2Str, float par3, float par4) { @@ -171,7 +172,7 @@ if (par1Entity != null && par2Str != null) { for (int i = 0; i < this.worldAccesses.size(); ++i) -@@ -1378,6 +1440,12 @@ +@@ -1378,6 +1441,12 @@ */ public void playSoundToNearExcept(EntityPlayer par1EntityPlayer, String par2Str, float par3, float par4) { @@ -184,7 +185,7 @@ if (par1EntityPlayer != null && par2Str != null) { for (int i = 0; i < this.worldAccesses.size(); ++i) -@@ -1464,6 +1532,11 @@ +@@ -1464,6 +1533,11 @@ EntityPlayer entityplayer = (EntityPlayer)par1Entity; this.playerEntities.add(entityplayer); this.updateAllPlayersSleepingFlag(); @@ -196,7 +197,7 @@ } this.getChunkFromChunkCoords(i, j).addEntity(par1Entity); -@@ -1710,6 +1783,12 @@ +@@ -1710,6 +1784,12 @@ * Calculates the color for the skybox */ public Vec3 getSkyColor(Entity par1Entity, float par2) @@ -209,7 +210,7 @@ { float f1 = this.getCelestialAngle(par2); float f2 = MathHelper.cos(f1 * (float)Math.PI * 2.0F) * 2.0F + 0.5F; -@@ -1802,6 +1881,12 @@ +@@ -1802,6 +1882,12 @@ @SideOnly(Side.CLIENT) public Vec3 getCloudColour(float par1) { @@ -222,7 +223,7 @@ float f1 = this.getCelestialAngle(par1); float f2 = MathHelper.cos(f1 * (float)Math.PI * 2.0F) * 2.0F + 0.5F; -@@ -1880,7 +1965,7 @@ +@@ -1880,7 +1966,7 @@ { int l = chunk.getBlockID(par1, k, par2); @@ -231,7 +232,7 @@ { return k + 1; } -@@ -1895,6 +1980,12 @@ +@@ -1895,6 +1981,12 @@ * How bright are stars in the sky */ public float getStarBrightness(float par1) @@ -244,7 +245,7 @@ { float f1 = this.getCelestialAngle(par1); float f2 = 1.0F - (MathHelper.cos(f1 * (float)Math.PI * 2.0F) * 2.0F + 0.25F); -@@ -2030,16 +2121,8 @@ +@@ -2030,16 +2122,8 @@ if (entity.isDead) { @@ -263,7 +264,7 @@ } this.theProfiler.endSection(); -@@ -2078,7 +2161,7 @@ +@@ -2078,7 +2162,7 @@ if (chunk != null) { @@ -272,7 +273,7 @@ } } } -@@ -2087,6 +2170,10 @@ +@@ -2087,6 +2171,10 @@ if (!this.entityRemoval.isEmpty()) { @@ -283,7 +284,7 @@ this.loadedTileEntityList.removeAll(this.entityRemoval); this.entityRemoval.clear(); } -@@ -2107,18 +2194,18 @@ +@@ -2107,18 +2195,18 @@ { this.loadedTileEntityList.add(tileentity1); } @@ -306,7 +307,7 @@ } } -@@ -2131,13 +2218,13 @@ +@@ -2131,13 +2219,13 @@ public void addTileEntity(Collection par1Collection) { @@ -327,7 +328,7 @@ } } -@@ -2157,9 +2244,17 @@ +@@ -2157,9 +2245,17 @@ { int i = MathHelper.floor_double(par1Entity.posX); int j = MathHelper.floor_double(par1Entity.posZ); @@ -348,7 +349,7 @@ { par1Entity.lastTickPosX = par1Entity.posX; par1Entity.lastTickPosY = par1Entity.posY; -@@ -2392,6 +2487,14 @@ +@@ -2392,6 +2488,14 @@ { return true; } @@ -363,7 +364,7 @@ } } } -@@ -2714,38 +2817,38 @@ +@@ -2714,38 +2818,38 @@ */ public void setBlockTileEntity(int par1, int par2, int par3, TileEntity par4TileEntity) { @@ -422,7 +423,7 @@ } } -@@ -2754,27 +2857,10 @@ +@@ -2754,27 +2858,10 @@ */ public void removeBlockTileEntity(int par1, int par2, int par3) { @@ -454,7 +455,7 @@ } } -@@ -2800,7 +2886,8 @@ +@@ -2800,7 +2887,8 @@ */ public boolean isBlockNormalCube(int par1, int par2, int par3) { @@ -464,7 +465,7 @@ } public boolean func_85174_u(int par1, int par2, int par3) -@@ -2823,8 +2910,7 @@ +@@ -2823,8 +2911,7 @@ */ public boolean doesBlockHaveSolidTopSurface(int par1, int par2, int par3) { @@ -474,7 +475,7 @@ } /** -@@ -2840,7 +2926,7 @@ +@@ -2840,7 +2927,7 @@ if (chunk != null && !chunk.isEmpty()) { Block block = Block.blocksList[this.getBlockId(par1, par2, par3)]; @@ -483,7 +484,7 @@ } else { -@@ -2871,8 +2957,7 @@ +@@ -2871,8 +2958,7 @@ */ public void setAllowedSpawnTypes(boolean par1, boolean par2) { @@ -493,7 +494,7 @@ } /** -@@ -2888,6 +2973,11 @@ +@@ -2888,6 +2974,11 @@ */ private void calculateInitialWeather() { @@ -505,7 +506,7 @@ if (this.worldInfo.isRaining()) { this.rainingStrength = 1.0F; -@@ -2903,6 +2993,11 @@ +@@ -2903,6 +2994,11 @@ * Updates all weather states. */ protected void updateWeather() @@ -517,7 +518,7 @@ { if (!this.provider.hasNoSky) { -@@ -3000,12 +3095,14 @@ +@@ -3000,12 +3096,14 @@ public void toggleRain() { @@ -533,7 +534,7 @@ this.theProfiler.startSection("buildList"); int i; EntityPlayer entityplayer; -@@ -3112,6 +3209,11 @@ +@@ -3112,6 +3210,11 @@ */ public boolean canBlockFreeze(int par1, int par2, int par3, boolean par4) { @@ -545,7 +546,7 @@ BiomeGenBase biomegenbase = this.getBiomeGenForCoords(par1, par3); float f = biomegenbase.getFloatTemperature(); -@@ -3170,6 +3272,11 @@ +@@ -3170,6 +3273,11 @@ */ public boolean canSnowAt(int par1, int par2, int par3) { @@ -557,7 +558,7 @@ BiomeGenBase biomegenbase = this.getBiomeGenForCoords(par1, par3); float f = biomegenbase.getFloatTemperature(); -@@ -3213,10 +3320,12 @@ +@@ -3213,10 +3321,12 @@ else { int l = this.getBlockId(par1, par2, par3); @@ -574,7 +575,7 @@ { j1 = 1; } -@@ -3312,7 +3421,9 @@ +@@ -3312,7 +3422,9 @@ int j4 = i2 + Facing.offsetsXForSide[i4]; int k4 = j2 + Facing.offsetsYForSide[i4]; int l4 = k2 + Facing.offsetsZForSide[i4]; @@ -585,7 +586,7 @@ i3 = this.getSavedLightValue(par1EnumSkyBlock, j4, k4, l4); if (i3 == l2 - i5 && i1 < this.lightUpdateBlockList.length) -@@ -3415,10 +3526,10 @@ +@@ -3415,10 +3527,10 @@ public List func_94576_a(Entity par1Entity, AxisAlignedBB par2AxisAlignedBB, IEntitySelector par3IEntitySelector) { ArrayList arraylist = new ArrayList(); @@ -600,7 +601,7 @@ for (int i1 = i; i1 <= j; ++i1) { -@@ -3444,10 +3555,10 @@ +@@ -3444,10 +3556,10 @@ public List selectEntitiesWithinAABB(Class par1Class, AxisAlignedBB par2AxisAlignedBB, IEntitySelector par3IEntitySelector) { @@ -615,7 +616,7 @@ ArrayList arraylist = new ArrayList(); for (int i1 = i; i1 <= j; ++i1) -@@ -3540,11 +3651,14 @@ +@@ -3540,11 +3652,14 @@ */ public void addLoadedEntities(List par1List) { @@ -633,7 +634,7 @@ } } -@@ -3578,6 +3692,11 @@ +@@ -3578,6 +3693,11 @@ else { if (block != null && (block == Block.waterMoving || block == Block.waterStill || block == Block.lavaMoving || block == Block.lavaStill || block == Block.fire || block.blockMaterial.isReplaceable())) @@ -645,7 +646,7 @@ { block = null; } -@@ -3866,7 +3985,7 @@ +@@ -3866,7 +3986,7 @@ */ public long getSeed() { @@ -654,7 +655,7 @@ } public long getTotalWorldTime() -@@ -3876,7 +3995,7 @@ +@@ -3876,7 +3996,7 @@ public long getWorldTime() { @@ -663,7 +664,7 @@ } /** -@@ -3884,7 +4003,7 @@ +@@ -3884,7 +4004,7 @@ */ public void setWorldTime(long par1) { @@ -672,7 +673,7 @@ } /** -@@ -3892,13 +4011,13 @@ +@@ -3892,13 +4012,13 @@ */ public ChunkCoordinates getSpawnPoint() { @@ -688,7 +689,7 @@ } @SideOnly(Side.CLIENT) -@@ -3922,7 +4041,10 @@ +@@ -3922,7 +4042,10 @@ if (!this.loadedEntityList.contains(par1Entity)) { @@ -700,7 +701,7 @@ } } -@@ -3930,6 +4052,11 @@ +@@ -3930,6 +4053,11 @@ * Called when checking if a certain block can be mined or not. The 'spawn safe zone' check is located here. */ public boolean canMineBlock(EntityPlayer par1EntityPlayer, int par2, int par3, int par4) @@ -712,7 +713,7 @@ { return true; } -@@ -4050,8 +4177,7 @@ +@@ -4050,8 +4178,7 @@ */ public boolean isBlockHighHumidity(int par1, int par2, int par3) { @@ -722,7 +723,7 @@ } /** -@@ -4126,7 +4252,7 @@ +@@ -4126,7 +4253,7 @@ */ public int getHeight() { @@ -731,7 +732,7 @@ } /** -@@ -4134,7 +4260,7 @@ +@@ -4134,7 +4261,7 @@ */ public int getActualHeight() { @@ -740,7 +741,7 @@ } public IUpdatePlayerListBox func_82735_a(EntityMinecart par1EntityMinecart) -@@ -4177,7 +4303,7 @@ +@@ -4177,7 +4304,7 @@ */ public double getHorizon() { @@ -749,7 +750,7 @@ } /** -@@ -4280,4 +4406,98 @@ +@@ -4280,4 +4407,114 @@ { return this.field_98181_L; } @@ -846,5 +847,21 @@ + } + + return getChunkFromChunkCoords(x >> 4, z >> 4).getBlockLightOpacity(x & 15, y, z & 15); ++ } ++ ++ /** ++ * Returns a count of entities that classify themselves as the specified creature type. ++ */ ++ public int countEntities(EnumCreatureType type, boolean forSpawnCount) ++ { ++ int count = 0; ++ for (int x = 0; x < loadedEntityList.size(); x++) ++ { ++ if (((Entity)loadedEntityList.get(x)).isCreatureType(type, forSpawnCount)) ++ { ++ count++; ++ } ++ } ++ return count; + } }