From da03639bd7530db57ec95e5f375a3789378064ba Mon Sep 17 00:00:00 2001 From: cpw Date: Fri, 13 Nov 2015 02:32:08 -0500 Subject: [PATCH] All the patches done? Some code fixups.. It begins. --- .../network/NetHandlerPlayServer.java.patch | 121 +++++++++++++++ .../network/NetHandlerLoginServer.java.patch | 8 +- .../minecraft/world/SpawnerAnimals.java.patch | 51 +++++++ .../world/gen/ChunkProviderEnd.java.patch | 67 +++++++++ .../gen/ChunkProviderGenerate.java.patch | 110 ++++++++++++++ .../world/gen/ChunkProviderHell.java.patch | 141 ++++++++++++++++++ .../world/gen/MapGenCaves.java.patch | 119 +++++++++++++++ .../gen/feature/WorldGenDungeons.java.patch | 30 ++++ .../world/gen/layer/GenLayer.java.patch | 55 +++++++ .../world/gen/layer/GenLayerBiome.java.patch | 94 ++++++++++++ ...ComponentScatteredFeaturePieces.java.patch | 79 ++++++++++ .../StructureMineshaftPieces.java.patch | 33 ++++ .../StructureStrongholdPieces.java.patch | 75 ++++++++++ .../StructureVillagePieces.java.patch | 84 +++++++++++ .../fml/common/launcher/FMLDeobfTweaker.java | 2 +- .../common/network/PacketLoggingHandler.java | 4 +- .../network/handshake/NetworkDispatcher.java | 6 +- .../network/internal/EntitySpawnHandler.java | 4 +- .../common/network/internal/FMLMessage.java | 3 +- .../fml/common/registry/VillagerRegistry.java | 12 +- 20 files changed, 1081 insertions(+), 17 deletions(-) create mode 100644 patches/minecraft/net/minecraft/network/NetHandlerPlayServer.java.patch create mode 100644 patches/minecraft/net/minecraft/world/SpawnerAnimals.java.patch create mode 100644 patches/minecraft/net/minecraft/world/gen/ChunkProviderEnd.java.patch create mode 100644 patches/minecraft/net/minecraft/world/gen/ChunkProviderGenerate.java.patch create mode 100644 patches/minecraft/net/minecraft/world/gen/ChunkProviderHell.java.patch create mode 100644 patches/minecraft/net/minecraft/world/gen/MapGenCaves.java.patch create mode 100644 patches/minecraft/net/minecraft/world/gen/feature/WorldGenDungeons.java.patch create mode 100644 patches/minecraft/net/minecraft/world/gen/layer/GenLayer.java.patch create mode 100644 patches/minecraft/net/minecraft/world/gen/layer/GenLayerBiome.java.patch create mode 100644 patches/minecraft/net/minecraft/world/gen/structure/ComponentScatteredFeaturePieces.java.patch create mode 100644 patches/minecraft/net/minecraft/world/gen/structure/StructureMineshaftPieces.java.patch create mode 100644 patches/minecraft/net/minecraft/world/gen/structure/StructureStrongholdPieces.java.patch create mode 100644 patches/minecraft/net/minecraft/world/gen/structure/StructureVillagePieces.java.patch diff --git a/patches/minecraft/net/minecraft/network/NetHandlerPlayServer.java.patch b/patches/minecraft/net/minecraft/network/NetHandlerPlayServer.java.patch new file mode 100644 index 0000000000..dbd27862de --- /dev/null +++ b/patches/minecraft/net/minecraft/network/NetHandlerPlayServer.java.patch @@ -0,0 +1,121 @@ +--- ../src-base/minecraft/net/minecraft/network/NetHandlerPlayServer.java ++++ ../src-work/minecraft/net/minecraft/network/NetHandlerPlayServer.java +@@ -254,6 +254,8 @@ + this.playerEntity.ridingEntity.updateRiderPosition(); + } + ++ if (!this.hasMoved) return; //Fixes teleportation kick while riding entities ++ + this.serverController.getConfigurationManager().serverUpdateMountedMovingPlayer(this.playerEntity); + + if (this.playerEntity.ridingEntity != null) +@@ -350,6 +352,8 @@ + this.playerEntity.jump(); + } + ++ if (!this.hasMoved) return; //Fixes "Moved Too Fast" kick when being teleported while moving ++ + this.playerEntity.moveEntity(d11, d12, d13); + this.playerEntity.onGround = packetIn.isOnGround(); + d11 = d8 - this.playerEntity.posX; +@@ -370,6 +374,8 @@ + logger.warn(this.playerEntity.getName() + " moved wrongly!"); + } + ++ if (!this.hasMoved) return; //Fixes "Moved Too Fast" kick when being teleported while moving ++ + this.playerEntity.setPositionAndRotation(d8, d9, d10, f1, f2); + this.playerEntity.addMovementStat(this.playerEntity.posX - d0, this.playerEntity.posY - d1, this.playerEntity.posZ - d2); + +@@ -377,7 +383,7 @@ + { + boolean flag2 = worldserver.getCollidingBoundingBoxes(this.playerEntity, this.playerEntity.getEntityBoundingBox().contract((double)f3, (double)f3, (double)f3)).isEmpty(); + +- if (flag && (flag1 || !flag2) && !this.playerEntity.isPlayerSleeping()) ++ if (flag && (flag1 || !flag2) && !this.playerEntity.isPlayerSleeping() && !this.playerEntity.noClip) + { + this.setPlayerLocation(this.lastPosX, this.lastPosY, this.lastPosZ, f1, f2); + return; +@@ -405,6 +411,8 @@ + this.floatingTickCount = 0; + } + ++ if (!this.hasMoved) return; //Fixes "Moved Too Fast" kick when being teleported while moving ++ + this.playerEntity.onGround = packetIn.isOnGround(); + this.serverController.getConfigurationManager().serverUpdateMountedMovingPlayer(this.playerEntity); + this.playerEntity.handleFalling(this.playerEntity.posY - d7, packetIn.isOnGround()); +@@ -497,7 +505,10 @@ + double d2 = this.playerEntity.posZ - ((double)blockpos.getZ() + 0.5D); + double d3 = d0 * d0 + d1 * d1 + d2 * d2; + +- if (d3 > 36.0D) ++ double dist = playerEntity.theItemInWorldManager.getBlockReachDistance() + 1; ++ dist *= dist; ++ ++ if (d3 > dist) + { + return; + } +@@ -549,6 +560,7 @@ + WorldServer worldserver = this.serverController.worldServerForDimension(this.playerEntity.dimension); + ItemStack itemstack = this.playerEntity.inventory.getCurrentItem(); + boolean flag = false; ++ boolean placeResult = true; + BlockPos blockpos = packetIn.getPosition(); + EnumFacing enumfacing = EnumFacing.getFront(packetIn.getPlacedBlockDirection()); + this.playerEntity.markPlayerActive(); +@@ -560,13 +572,20 @@ + return; + } + ++ net.minecraftforge.event.entity.player.PlayerInteractEvent event = net.minecraftforge.event.ForgeEventFactory.onPlayerInteract(playerEntity, net.minecraftforge.event.entity.player.PlayerInteractEvent.Action.RIGHT_CLICK_AIR, worldserver, new BlockPos(0, 0, 0), null); ++ if (event.useItem != net.minecraftforge.fml.common.eventhandler.Event.Result.DENY) ++ { + this.playerEntity.theItemInWorldManager.tryUseItem(this.playerEntity, worldserver, itemstack); ++ } + } + else if (blockpos.getY() < this.serverController.getBuildLimit() - 1 || enumfacing != EnumFacing.UP && blockpos.getY() < this.serverController.getBuildLimit()) + { +- if (this.hasMoved && this.playerEntity.getDistanceSq((double)blockpos.getX() + 0.5D, (double)blockpos.getY() + 0.5D, (double)blockpos.getZ() + 0.5D) < 64.0D && !this.serverController.isBlockProtected(worldserver, blockpos, this.playerEntity) && worldserver.getWorldBorder().contains(blockpos)) ++ double dist = playerEntity.theItemInWorldManager.getBlockReachDistance() + 3; ++ dist *= dist; ++ if (this.hasMoved && this.playerEntity.getDistanceSq((double)blockpos.getX() + 0.5D, (double)blockpos.getY() + 0.5D, (double)blockpos.getZ() + 0.5D) < dist && !this.serverController.isBlockProtected(worldserver, blockpos, this.playerEntity) && worldserver.getWorldBorder().contains(blockpos)) + { +- this.playerEntity.theItemInWorldManager.activateBlockOrUseItem(this.playerEntity, worldserver, itemstack, blockpos, enumfacing, packetIn.getPlacedBlockOffsetX(), packetIn.getPlacedBlockOffsetY(), packetIn.getPlacedBlockOffsetZ()); ++ // record block place result so we can update client itemstack size if place event was cancelled. ++ placeResult = this.playerEntity.theItemInWorldManager.activateBlockOrUseItem(this.playerEntity, worldserver, itemstack, blockpos, enumfacing, packetIn.getPlacedBlockOffsetX(), packetIn.getPlacedBlockOffsetY(), packetIn.getPlacedBlockOffsetZ()); + } + + flag = true; +@@ -601,7 +620,7 @@ + this.playerEntity.openContainer.detectAndSendChanges(); + this.playerEntity.isChangingQuantityOnly = false; + +- if (!ItemStack.areItemStacksEqual(this.playerEntity.inventory.getCurrentItem(), packetIn.getStack())) ++ if (!ItemStack.areItemStacksEqual(this.playerEntity.inventory.getCurrentItem(), packetIn.getStack()) || !placeResult) // force client itemstack update if place event was cancelled + { + this.sendPacket(new S2FPacketSetSlot(this.playerEntity.openContainer.windowId, slot.slotNumber, this.playerEntity.inventory.getCurrentItem())); + } +@@ -770,8 +789,10 @@ + } + else + { +- IChatComponent ichatcomponent = new ChatComponentTranslation("chat.type.text", new Object[] {this.playerEntity.getDisplayName(), s}); +- this.serverController.getConfigurationManager().sendChatMsgImpl(ichatcomponent, false); ++ ChatComponentTranslation chatcomponenttranslation1 = new ChatComponentTranslation("chat.type.text", this.playerEntity.getDisplayName(), net.minecraftforge.common.ForgeHooks.newChatWithLinks(s)); ++ IChatComponent chat = net.minecraftforge.common.ForgeHooks.onServerChatEvent(this, s, chatcomponenttranslation1); ++ if (chat == null) return; ++ this.serverController.getConfigurationManager().sendChatMsgImpl(chat, false); + } + + this.chatSpamThresholdCount += 20; +@@ -916,7 +937,7 @@ + return; + } + +- this.playerEntity = this.serverController.getConfigurationManager().recreatePlayerEntity(this.playerEntity, 0, false); ++ this.playerEntity = this.serverController.getConfigurationManager().recreatePlayerEntity(this.playerEntity, playerEntity.dimension, false); + } + + break; diff --git a/patches/minecraft/net/minecraft/server/network/NetHandlerLoginServer.java.patch b/patches/minecraft/net/minecraft/server/network/NetHandlerLoginServer.java.patch index 0cd7c7fb2f..207663b904 100644 --- a/patches/minecraft/net/minecraft/server/network/NetHandlerLoginServer.java.patch +++ b/patches/minecraft/net/minecraft/server/network/NetHandlerLoginServer.java.patch @@ -1,6 +1,12 @@ --- ../src-base/minecraft/net/minecraft/server/network/NetHandlerLoginServer.java +++ ../src-work/minecraft/net/minecraft/server/network/NetHandlerLoginServer.java -@@ -71,7 +71,7 @@ +@@ -66,12 +66,12 @@ + if (entityplayermp == null) + { + this.currentLoginState = NetHandlerLoginServer.LoginState.READY_TO_ACCEPT; +- this.server.getConfigurationManager().initializeConnectionToPlayer(this.networkManager, this.field_181025_l); ++ net.minecraftforge.fml.common.network.internal.FMLNetworkHandler.fmlServerHandshake(this.server.getConfigurationManager(), this.networkManager, this.field_181025_l); + this.field_181025_l = null; } } diff --git a/patches/minecraft/net/minecraft/world/SpawnerAnimals.java.patch b/patches/minecraft/net/minecraft/world/SpawnerAnimals.java.patch new file mode 100644 index 0000000000..01632c7d20 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/SpawnerAnimals.java.patch @@ -0,0 +1,51 @@ +--- ../src-base/minecraft/net/minecraft/world/SpawnerAnimals.java ++++ ../src-work/minecraft/net/minecraft/world/SpawnerAnimals.java +@@ -69,14 +69,15 @@ + { + if ((!enumcreaturetype.getPeacefulCreature() || p_77192_3_) && (enumcreaturetype.getPeacefulCreature() || p_77192_2_) && (!enumcreaturetype.getAnimal() || p_77192_4_)) + { +- int j4 = p_77192_1_.countEntities(enumcreaturetype.getCreatureClass()); ++ int j4 = p_77192_1_.countEntities(enumcreaturetype, true); + int k4 = enumcreaturetype.getMaxNumberOfCreature() * i / MOB_COUNT_DIV; + + if (j4 <= k4) + { ++ java.util.ArrayList shuffled = com.google.common.collect.Lists.newArrayList(this.eligibleChunksForSpawning); ++ java.util.Collections.shuffle(shuffled); + label374: +- +- for (ChunkCoordIntPair chunkcoordintpair1 : this.eligibleChunksForSpawning) ++ for (ChunkCoordIntPair chunkcoordintpair1 : shuffled) + { + BlockPos blockpos = getRandomChunkPosition(p_77192_1_, chunkcoordintpair1.chunkXPos, chunkcoordintpair1.chunkZPos); + int k1 = blockpos.getX(); +@@ -134,8 +135,10 @@ + + entityliving.setLocationAndAngles((double)f, (double)i3, (double)f1, p_77192_1_.rand.nextFloat() * 360.0F, 0.0F); + +- if (entityliving.getCanSpawnHere() && entityliving.handleLavaMovement()) ++ net.minecraftforge.fml.common.eventhandler.Event.Result canSpawn = net.minecraftforge.event.ForgeEventFactory.canEntitySpawn(entityliving, p_77192_1_, f, l2, f1); ++ if (canSpawn == net.minecraftforge.fml.common.eventhandler.Event.Result.ALLOW || (canSpawn == net.minecraftforge.fml.common.eventhandler.Event.Result.DEFAULT && (entityliving.getCanSpawnHere() && entityliving.handleLavaMovement()))) + { ++ if (!net.minecraftforge.event.ForgeEventFactory.doSpecialSpawn(entityliving, p_77192_1_, f1, l2, f1)) + ientitylivingdata = entityliving.func_180482_a(p_77192_1_.getDifficultyForLocation(new BlockPos(entityliving)), ientitylivingdata); + + if (entityliving.handleLavaMovement()) +@@ -144,7 +147,7 @@ + p_77192_1_.spawnEntityInWorld(entityliving); + } + +- if (j2 >= entityliving.getMaxSpawnedInChunk()) ++ if (i2 >= net.minecraftforge.event.ForgeEventFactory.getMaxSpawnPackSize(entityliving)) + { + continue label374; + } +@@ -193,7 +196,7 @@ + { + BlockPos blockpos = pos.down(); + +- if (!World.doesBlockHaveSolidTopSurface(worldIn, blockpos)) ++ if (!worldIn.getBlockState(blockpos).getBlock().canCreatureSpawn(worldIn, blockpos, p_180267_0_)) + { + return false; + } diff --git a/patches/minecraft/net/minecraft/world/gen/ChunkProviderEnd.java.patch b/patches/minecraft/net/minecraft/world/gen/ChunkProviderEnd.java.patch new file mode 100644 index 0000000000..45b2a8d71a --- /dev/null +++ b/patches/minecraft/net/minecraft/world/gen/ChunkProviderEnd.java.patch @@ -0,0 +1,67 @@ +--- ../src-base/minecraft/net/minecraft/world/gen/ChunkProviderEnd.java ++++ ../src-work/minecraft/net/minecraft/world/gen/ChunkProviderEnd.java +@@ -32,6 +32,9 @@ + double[] noiseData3; + double[] noiseData4; + double[] noiseData5; ++ // temporary variables used during event handling ++ private int chunkX = 0; ++ private int chunkZ = 0; + + public ChunkProviderEnd(World worldIn, long p_i2007_2_) + { +@@ -42,6 +45,14 @@ + this.noiseGen3 = new NoiseGeneratorOctaves(this.endRNG, 8); + this.noiseGen4 = new NoiseGeneratorOctaves(this.endRNG, 10); + this.noiseGen5 = new NoiseGeneratorOctaves(this.endRNG, 16); ++ ++ NoiseGenerator[] noiseGens = {noiseGen1, noiseGen2, noiseGen3, noiseGen4, noiseGen5}; ++ noiseGens = net.minecraftforge.event.terraingen.TerrainGen.getModdedNoiseGenerators(worldIn, this.endRNG, noiseGens); ++ this.noiseGen1 = (NoiseGeneratorOctaves)noiseGens[0]; ++ this.noiseGen2 = (NoiseGeneratorOctaves)noiseGens[1]; ++ this.noiseGen3 = (NoiseGeneratorOctaves)noiseGens[2]; ++ this.noiseGen4 = (NoiseGeneratorOctaves)noiseGens[3]; ++ this.noiseGen5 = (NoiseGeneratorOctaves)noiseGens[4]; + } + + public void func_180520_a(int p_180520_1_, int p_180520_2_, ChunkPrimer p_180520_3_) +@@ -114,6 +125,9 @@ + + public void func_180519_a(ChunkPrimer p_180519_1_) + { ++ net.minecraftforge.event.terraingen.ChunkProviderEvent.ReplaceBiomeBlocks event = new net.minecraftforge.event.terraingen.ChunkProviderEvent.ReplaceBiomeBlocks(this, chunkX, chunkZ, p_180519_1_, this.endWorld); ++ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event); ++ if (event.getResult() == net.minecraftforge.fml.common.eventhandler.Event.Result.DENY) return; + for (int i = 0; i < 16; ++i) + { + for (int j = 0; j < 16; ++j) +@@ -165,6 +179,7 @@ + + public Chunk provideChunk(int x, int z) + { ++ chunkX = x; chunkZ = z; + this.endRNG.setSeed((long)x * 341873128712L + (long)z * 132897987541L); + ChunkPrimer chunkprimer = new ChunkPrimer(); + this.biomesForGeneration = this.endWorld.getWorldChunkManager().loadBlockGeneratorData(this.biomesForGeneration, x * 16, z * 16, 16, 16); +@@ -184,6 +199,10 @@ + + private double[] initializeNoiseField(double[] p_73187_1_, int p_73187_2_, int p_73187_3_, int p_73187_4_, int p_73187_5_, int p_73187_6_, int p_73187_7_) + { ++ net.minecraftforge.event.terraingen.ChunkProviderEvent.InitNoiseField event = new net.minecraftforge.event.terraingen.ChunkProviderEvent.InitNoiseField(this, p_73187_1_, p_73187_2_, p_73187_3_, p_73187_4_, p_73187_5_, p_73187_6_, p_73187_7_); ++ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event); ++ if (event.getResult() == net.minecraftforge.fml.common.eventhandler.Event.Result.DENY) return event.noisefield; ++ + if (p_73187_1_ == null) + { + p_73187_1_ = new double[p_73187_5_ * p_73187_6_ * p_73187_7_]; +@@ -273,8 +292,10 @@ + public void populate(IChunkProvider p_73153_1_, int p_73153_2_, int p_73153_3_) + { + BlockFalling.fallInstantly = true; ++ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.terraingen.PopulateChunkEvent.Pre(p_73153_1_, endWorld, endWorld.rand, p_73153_2_, p_73153_3_, false)); + BlockPos blockpos = new BlockPos(p_73153_2_ * 16, 0, p_73153_3_ * 16); + this.endWorld.getBiomeGenForCoords(blockpos.add(16, 0, 16)).decorate(this.endWorld, this.endWorld.rand, blockpos); ++ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.terraingen.PopulateChunkEvent.Post(p_73153_1_, endWorld, endWorld.rand, p_73153_2_, p_73153_3_, false)); + BlockFalling.fallInstantly = false; + } + diff --git a/patches/minecraft/net/minecraft/world/gen/ChunkProviderGenerate.java.patch b/patches/minecraft/net/minecraft/world/gen/ChunkProviderGenerate.java.patch new file mode 100644 index 0000000000..12ffaf7776 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/gen/ChunkProviderGenerate.java.patch @@ -0,0 +1,110 @@ +--- ../src-base/minecraft/net/minecraft/world/gen/ChunkProviderGenerate.java ++++ ../src-work/minecraft/net/minecraft/world/gen/ChunkProviderGenerate.java +@@ -58,6 +58,15 @@ + + public ChunkProviderGenerate(World worldIn, long p_i45636_2_, boolean p_i45636_4_, String p_i45636_5_) + { ++ { ++ caveGenerator = net.minecraftforge.event.terraingen.TerrainGen.getModdedMapGen(caveGenerator, net.minecraftforge.event.terraingen.InitMapGenEvent.EventType.CAVE); ++ strongholdGenerator = (MapGenStronghold)net.minecraftforge.event.terraingen.TerrainGen.getModdedMapGen(strongholdGenerator, net.minecraftforge.event.terraingen.InitMapGenEvent.EventType.STRONGHOLD); ++ villageGenerator = (MapGenVillage)net.minecraftforge.event.terraingen.TerrainGen.getModdedMapGen(villageGenerator, net.minecraftforge.event.terraingen.InitMapGenEvent.EventType.VILLAGE); ++ mineshaftGenerator = (MapGenMineshaft)net.minecraftforge.event.terraingen.TerrainGen.getModdedMapGen(mineshaftGenerator, net.minecraftforge.event.terraingen.InitMapGenEvent.EventType.MINESHAFT); ++ scatteredFeatureGenerator = (MapGenScatteredFeature)net.minecraftforge.event.terraingen.TerrainGen.getModdedMapGen(scatteredFeatureGenerator, net.minecraftforge.event.terraingen.InitMapGenEvent.EventType.SCATTERED_FEATURE); ++ ravineGenerator = net.minecraftforge.event.terraingen.TerrainGen.getModdedMapGen(ravineGenerator, net.minecraftforge.event.terraingen.InitMapGenEvent.EventType.RAVINE); ++ oceanMonumentGenerator = (StructureOceanMonument)net.minecraftforge.event.terraingen.TerrainGen.getModdedMapGen(oceanMonumentGenerator, net.minecraftforge.event.terraingen.InitMapGenEvent.EventType.OCEAN_MONUMENT); ++ } + this.worldObj = worldIn; + this.mapFeaturesEnabled = p_i45636_4_; + this.field_177475_o = worldIn.getWorldInfo().getTerrainType(); +@@ -87,6 +96,16 @@ + this.field_177476_s = this.settings.useLavaOceans ? Blocks.lava : Blocks.water; + worldIn.func_181544_b(this.settings.seaLevel); + } ++ ++ NoiseGenerator[] noiseGens = {field_147431_j, field_147432_k, field_147429_l, field_147430_m, noiseGen5, noiseGen6, mobSpawnerNoise}; ++ noiseGens = net.minecraftforge.event.terraingen.TerrainGen.getModdedNoiseGenerators(worldIn, this.rand, noiseGens); ++ this.field_147431_j = (NoiseGeneratorOctaves)noiseGens[0]; ++ this.field_147432_k = (NoiseGeneratorOctaves)noiseGens[1]; ++ this.field_147429_l = (NoiseGeneratorOctaves)noiseGens[2]; ++ this.field_147430_m = (NoiseGeneratorPerlin)noiseGens[3]; ++ this.noiseGen5 = (NoiseGeneratorOctaves)noiseGens[4]; ++ this.noiseGen6 = (NoiseGeneratorOctaves)noiseGens[5]; ++ this.mobSpawnerNoise = (NoiseGeneratorOctaves)noiseGens[6]; + } + + public void setBlocksInChunk(int p_180518_1_, int p_180518_2_, ChunkPrimer p_180518_3_) +@@ -160,6 +179,10 @@ + + public void func_180517_a(int p_180517_1_, int p_180517_2_, ChunkPrimer p_180517_3_, BiomeGenBase[] p_180517_4_) + { ++ net.minecraftforge.event.terraingen.ChunkProviderEvent.ReplaceBiomeBlocks event = new net.minecraftforge.event.terraingen.ChunkProviderEvent.ReplaceBiomeBlocks(this, p_180517_1_, p_180517_2_, p_180517_3_, this.worldObj); ++ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event); ++ if (event.getResult() == net.minecraftforge.fml.common.eventhandler.Event.Result.DENY) return; ++ + double d0 = 0.03125D; + this.stoneNoise = this.field_147430_m.func_151599_a(this.stoneNoise, (double)(p_180517_1_ * 16), (double)(p_180517_2_ * 16), 16, 16, d0 * 2.0D, d0 * 2.0D, 1.0D); + +@@ -366,6 +389,8 @@ + boolean flag = false; + ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(p_73153_2_, p_73153_3_); + ++ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.terraingen.PopulateChunkEvent.Pre(p_73153_1_, worldObj, rand, p_73153_2_, p_73153_3_, flag)); ++ + if (this.settings.useMineShafts && this.mapFeaturesEnabled) + { + this.mineshaftGenerator.func_175794_a(this.worldObj, this.rand, chunkcoordintpair); +@@ -391,7 +416,8 @@ + this.oceanMonumentGenerator.func_175794_a(this.worldObj, this.rand, chunkcoordintpair); + } + +- if (biomegenbase != BiomeGenBase.desert && biomegenbase != BiomeGenBase.desertHills && this.settings.useWaterLakes && !flag && this.rand.nextInt(this.settings.waterLakeChance) == 0) ++ if (biomegenbase != BiomeGenBase.desert && biomegenbase != BiomeGenBase.desertHills && this.settings.useWaterLakes && !flag && this.rand.nextInt(this.settings.waterLakeChance) == 0 ++ && net.minecraftforge.event.terraingen.TerrainGen.populate(p_73153_1_, worldObj, rand, p_73153_2_, p_73153_3_, flag, net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType.LAKE)) + { + int i1 = this.rand.nextInt(16) + 8; + int j1 = this.rand.nextInt(256); +@@ -399,7 +425,8 @@ + (new WorldGenLakes(Blocks.water)).generate(this.worldObj, this.rand, blockpos.add(i1, j1, k1)); + } + +- if (!flag && this.rand.nextInt(this.settings.lavaLakeChance / 10) == 0 && this.settings.useLavaLakes) ++ if (!flag && this.rand.nextInt(this.settings.lavaLakeChance / 10) == 0 && this.settings.useLavaLakes ++ && net.minecraftforge.event.terraingen.TerrainGen.populate(p_73153_1_, worldObj, rand, p_73153_2_, p_73153_3_, 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); +@@ -413,7 +440,8 @@ + + if (this.settings.useDungeons) + { +- for (int j2 = 0; j2 < this.settings.dungeonChance; ++j2) ++ boolean doGen = net.minecraftforge.event.terraingen.TerrainGen.populate(p_73153_1_, worldObj, rand, p_73153_2_, p_73153_3_, flag, net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType.DUNGEON); ++ for (int j2 = 0; doGen && j2 < this.settings.dungeonChance; ++j2) + { + int i3 = this.rand.nextInt(16) + 8; + int l3 = this.rand.nextInt(256); +@@ -423,10 +451,14 @@ + } + + biomegenbase.decorate(this.worldObj, this.rand, new BlockPos(i, 0, j)); ++ if (net.minecraftforge.event.terraingen.TerrainGen.populate(p_73153_1_, worldObj, rand, p_73153_2_, p_73153_3_, flag, net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType.ANIMALS)) ++ { + SpawnerAnimals.performWorldGenSpawning(this.worldObj, biomegenbase, i + 8, j + 8, 16, 16, this.rand); ++ } + blockpos = blockpos.add(8, 0, 8); + +- for (int k2 = 0; k2 < 16; ++k2) ++ boolean doGen = net.minecraftforge.event.terraingen.TerrainGen.populate(p_73153_1_, worldObj, rand, p_73153_2_, p_73153_3_, flag, net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType.ICE); ++ for (int k2 = 0; doGen && k2 < 16; ++k2) + { + for (int j3 = 0; j3 < 16; ++j3) + { +@@ -445,6 +477,8 @@ + } + } + ++ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.terraingen.PopulateChunkEvent.Post(p_73153_1_, worldObj, rand, p_73153_2_, p_73153_3_, flag)); ++ + BlockFalling.fallInstantly = false; + } + diff --git a/patches/minecraft/net/minecraft/world/gen/ChunkProviderHell.java.patch b/patches/minecraft/net/minecraft/world/gen/ChunkProviderHell.java.patch new file mode 100644 index 0000000000..a1e6412b48 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/gen/ChunkProviderHell.java.patch @@ -0,0 +1,141 @@ +--- ../src-base/minecraft/net/minecraft/world/gen/ChunkProviderHell.java ++++ ../src-work/minecraft/net/minecraft/world/gen/ChunkProviderHell.java +@@ -49,8 +49,8 @@ + private final WorldGenHellLava field_177472_y = new WorldGenHellLava(Blocks.flowing_lava, false); + private final GeneratorBushFeature field_177471_z = new GeneratorBushFeature(Blocks.brown_mushroom); + private final GeneratorBushFeature field_177465_A = new GeneratorBushFeature(Blocks.red_mushroom); +- private final MapGenNetherBridge genNetherBridge = new MapGenNetherBridge(); +- private final MapGenBase netherCaveGenerator = new MapGenCavesHell(); ++ private final MapGenNetherBridge genNetherBridge; ++ private final MapGenBase netherCaveGenerator; + double[] noiseData1; + double[] noiseData2; + double[] noiseData3; +@@ -59,16 +59,29 @@ + + public ChunkProviderHell(World worldIn, boolean p_i45637_2_, long p_i45637_3_) + { ++ this.genNetherBridge = (MapGenNetherBridge) net.minecraftforge.event.terraingen.TerrainGen.getModdedMapGen(new MapGenNetherBridge(), net.minecraftforge.event.terraingen.InitMapGenEvent.EventType.NETHER_BRIDGE); ++ this.netherCaveGenerator = net.minecraftforge.event.terraingen.TerrainGen.getModdedMapGen(new MapGenCavesHell(), net.minecraftforge.event.terraingen.InitMapGenEvent.EventType.NETHER_CAVE); + this.worldObj = worldIn; + this.field_177466_i = p_i45637_2_; + this.hellRNG = new Random(p_i45637_3_); +- this.netherNoiseGen1 = new NoiseGeneratorOctaves(this.hellRNG, 16); +- this.netherNoiseGen2 = new NoiseGeneratorOctaves(this.hellRNG, 16); +- this.netherNoiseGen3 = new NoiseGeneratorOctaves(this.hellRNG, 8); +- this.slowsandGravelNoiseGen = new NoiseGeneratorOctaves(this.hellRNG, 4); +- this.netherrackExculsivityNoiseGen = new NoiseGeneratorOctaves(this.hellRNG, 4); +- this.netherNoiseGen6 = new NoiseGeneratorOctaves(this.hellRNG, 10); +- this.netherNoiseGen7 = new NoiseGeneratorOctaves(this.hellRNG, 16); ++ NoiseGeneratorOctaves netherNoiseGen1 = new NoiseGeneratorOctaves(this.hellRNG, 16); ++ NoiseGeneratorOctaves netherNoiseGen2 = new NoiseGeneratorOctaves(this.hellRNG, 16); ++ NoiseGeneratorOctaves netherNoiseGen3 = new NoiseGeneratorOctaves(this.hellRNG, 8); ++ NoiseGeneratorOctaves slowsandGravelNoiseGen = new NoiseGeneratorOctaves(this.hellRNG, 4); ++ NoiseGeneratorOctaves netherrackExculsivityNoiseGen = new NoiseGeneratorOctaves(this.hellRNG, 4); ++ NoiseGeneratorOctaves netherNoiseGen6 = new NoiseGeneratorOctaves(this.hellRNG, 10); ++ NoiseGeneratorOctaves netherNoiseGen7 = new NoiseGeneratorOctaves(this.hellRNG, 16); ++ NoiseGenerator[] noiseGens = new NoiseGenerator[] { ++ netherNoiseGen1, netherNoiseGen2, netherNoiseGen3, slowsandGravelNoiseGen, netherrackExculsivityNoiseGen, netherNoiseGen6, netherNoiseGen7 ++ }; ++ noiseGens = net.minecraftforge.event.terraingen.TerrainGen.getModdedNoiseGenerators(worldIn, this.hellRNG, noiseGens); ++ this.netherNoiseGen1 = (NoiseGeneratorOctaves)noiseGens[0]; ++ this.netherNoiseGen2 = (NoiseGeneratorOctaves)noiseGens[1]; ++ this.netherNoiseGen3 = (NoiseGeneratorOctaves)noiseGens[2]; ++ this.slowsandGravelNoiseGen = (NoiseGeneratorOctaves)noiseGens[3]; ++ this.netherrackExculsivityNoiseGen = (NoiseGeneratorOctaves)noiseGens[4]; ++ this.netherNoiseGen6 = (NoiseGeneratorOctaves)noiseGens[5]; ++ this.netherNoiseGen7 = (NoiseGeneratorOctaves)noiseGens[6]; + worldIn.func_181544_b(63); + } + +@@ -148,6 +161,10 @@ + + public void func_180516_b(int p_180516_1_, int p_180516_2_, ChunkPrimer p_180516_3_) + { ++ net.minecraftforge.event.terraingen.ChunkProviderEvent.ReplaceBiomeBlocks event = new net.minecraftforge.event.terraingen.ChunkProviderEvent.ReplaceBiomeBlocks(this, p_180516_1_, p_180516_2_, p_180516_3_, this.worldObj); ++ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event); ++ if (event.getResult() == net.minecraftforge.fml.common.eventhandler.Event.Result.DENY) return; ++ + int i = this.worldObj.func_181545_F() + 1; + double d0 = 0.03125D; + this.slowsandNoise = this.slowsandGravelNoiseGen.generateNoiseOctaves(this.slowsandNoise, p_180516_1_ * 16, p_180516_2_ * 16, 0, 16, 16, 1, d0, d0, 1.0D); +@@ -265,6 +282,10 @@ + + private double[] initializeNoiseField(double[] p_73164_1_, int p_73164_2_, int p_73164_3_, int p_73164_4_, int p_73164_5_, int p_73164_6_, int p_73164_7_) + { ++ net.minecraftforge.event.terraingen.ChunkProviderEvent.InitNoiseField event = new net.minecraftforge.event.terraingen.ChunkProviderEvent.InitNoiseField(this, p_73164_1_, p_73164_2_, p_73164_3_, p_73164_4_, p_73164_5_, p_73164_6_, p_73164_7_); ++ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event); ++ if (event.getResult() == net.minecraftforge.fml.common.eventhandler.Event.Result.DENY) return event.noisefield; ++ + if (p_73164_1_ == null) + { + p_73164_1_ = new double[p_73164_5_ * p_73164_6_ * p_73164_7_]; +@@ -356,50 +377,60 @@ + public void populate(IChunkProvider p_73153_1_, int p_73153_2_, int p_73153_3_) + { + BlockFalling.fallInstantly = true; ++ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.terraingen.PopulateChunkEvent.Pre(p_73153_1_, worldObj, hellRNG, p_73153_2_, p_73153_3_, false)); + BlockPos blockpos = new BlockPos(p_73153_2_ * 16, 0, p_73153_3_ * 16); + ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(p_73153_2_, p_73153_3_); + this.genNetherBridge.func_175794_a(this.worldObj, this.hellRNG, chunkcoordintpair); + +- for (int i = 0; i < 8; ++i) ++ boolean doGen = net.minecraftforge.event.terraingen.TerrainGen.populate(p_73153_1_, worldObj, hellRNG, p_73153_2_, p_73153_3_, false, net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType.NETHER_LAVA); ++ for (int i = 0; doGen && i < 8; ++i) + { + this.field_177472_y.generate(this.worldObj, this.hellRNG, blockpos.add(this.hellRNG.nextInt(16) + 8, this.hellRNG.nextInt(120) + 4, this.hellRNG.nextInt(16) + 8)); + } + +- for (int j = 0; j < this.hellRNG.nextInt(this.hellRNG.nextInt(10) + 1) + 1; ++j) ++ doGen = net.minecraftforge.event.terraingen.TerrainGen.populate(p_73153_1_, worldObj, hellRNG, p_73153_2_, p_73153_3_, false, net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType.FIRE); ++ for (int j = 0; doGen && j < this.hellRNG.nextInt(this.hellRNG.nextInt(10) + 1) + 1; ++j) + { + this.field_177470_t.generate(this.worldObj, this.hellRNG, blockpos.add(this.hellRNG.nextInt(16) + 8, this.hellRNG.nextInt(120) + 4, this.hellRNG.nextInt(16) + 8)); + } + +- for (int k = 0; k < this.hellRNG.nextInt(this.hellRNG.nextInt(10) + 1); ++k) ++ doGen = net.minecraftforge.event.terraingen.TerrainGen.populate(p_73153_1_, worldObj, hellRNG, p_73153_2_, p_73153_3_, false, net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType.GLOWSTONE); ++ for (int k = 0; doGen && k < this.hellRNG.nextInt(this.hellRNG.nextInt(10) + 1); ++k) + { + this.field_177469_u.generate(this.worldObj, this.hellRNG, blockpos.add(this.hellRNG.nextInt(16) + 8, this.hellRNG.nextInt(120) + 4, this.hellRNG.nextInt(16) + 8)); + } + +- for (int l = 0; l < 10; ++l) ++ for (int l = 0; doGen && l < 10; ++l) + { + this.field_177468_v.generate(this.worldObj, this.hellRNG, blockpos.add(this.hellRNG.nextInt(16) + 8, this.hellRNG.nextInt(128), this.hellRNG.nextInt(16) + 8)); + } + +- if (this.hellRNG.nextBoolean()) ++ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.terraingen.DecorateBiomeEvent.Pre(worldObj, hellRNG, blockpos)); ++ ++ doGen = net.minecraftforge.event.terraingen.TerrainGen.decorate(worldObj, hellRNG, blockpos, net.minecraftforge.event.terraingen.DecorateBiomeEvent.Decorate.EventType.SHROOM); ++ if (doGen && this.hellRNG.nextBoolean()) + { + this.field_177471_z.generate(this.worldObj, this.hellRNG, blockpos.add(this.hellRNG.nextInt(16) + 8, this.hellRNG.nextInt(128), this.hellRNG.nextInt(16) + 8)); + } + +- if (this.hellRNG.nextBoolean()) ++ if (doGen && this.hellRNG.nextBoolean()) + { + this.field_177465_A.generate(this.worldObj, this.hellRNG, blockpos.add(this.hellRNG.nextInt(16) + 8, this.hellRNG.nextInt(128), this.hellRNG.nextInt(16) + 8)); + } + +- for (int i1 = 0; i1 < 16; ++i1) ++ doGen = net.minecraftforge.event.terraingen.TerrainGen.generateOre(worldObj, hellRNG, field_177467_w, blockpos, net.minecraftforge.event.terraingen.OreGenEvent.GenerateMinable.EventType.QUARTZ); ++ for (int i1 = 0; doGen && i1 < 16; ++i1) + { + this.field_177467_w.generate(this.worldObj, this.hellRNG, blockpos.add(this.hellRNG.nextInt(16), this.hellRNG.nextInt(108) + 10, this.hellRNG.nextInt(16))); + } + +- for (int j1 = 0; j1 < 16; ++j1) ++ doGen = net.minecraftforge.event.terraingen.TerrainGen.populate(p_73153_1_, worldObj, hellRNG, p_73153_2_, p_73153_3_, false, net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType.NETHER_LAVA2); ++ for (int j1 = 0; doGen && j1 < 16; ++j1) + { + this.field_177473_x.generate(this.worldObj, this.hellRNG, blockpos.add(this.hellRNG.nextInt(16), this.hellRNG.nextInt(108) + 10, this.hellRNG.nextInt(16))); + } + ++ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.terraingen.PopulateChunkEvent.Post(p_73153_1_, worldObj, hellRNG, p_73153_2_, p_73153_3_, false)); + BlockFalling.fallInstantly = false; + } + diff --git a/patches/minecraft/net/minecraft/world/gen/MapGenCaves.java.patch b/patches/minecraft/net/minecraft/world/gen/MapGenCaves.java.patch new file mode 100644 index 0000000000..8d6cd118cb --- /dev/null +++ b/patches/minecraft/net/minecraft/world/gen/MapGenCaves.java.patch @@ -0,0 +1,119 @@ +--- ../src-base/minecraft/net/minecraft/world/gen/MapGenCaves.java ++++ ../src-work/minecraft/net/minecraft/world/gen/MapGenCaves.java +@@ -138,7 +138,7 @@ + { + IBlockState iblockstate = p_180702_5_.getBlockState(j1, l1, k1); + +- if (iblockstate.getBlock() == Blocks.flowing_water || iblockstate.getBlock() == Blocks.water) ++ if (isOceanBlock(p_180702_5_, j1, l1, k1, p_180702_3_, p_180702_4_)) + { + flag3 = true; + } +@@ -176,33 +176,12 @@ + IBlockState iblockstate1 = p_180702_5_.getBlockState(j3, j2, i2); + IBlockState iblockstate2 = (IBlockState)Objects.firstNonNull(p_180702_5_.getBlockState(j3, j2 + 1, i2), Blocks.air.getDefaultState()); + +- if (iblockstate1.getBlock() == Blocks.grass || iblockstate1.getBlock() == Blocks.mycelium) ++ if (isTopBlock(p_180702_5_, j3, j2, i2, p_180702_3_, p_180702_4_)) + { + flag1 = true; + } + +- if (this.func_175793_a(iblockstate1, iblockstate2)) +- { +- if (j2 - 1 < 10) +- { +- p_180702_5_.setBlockState(j3, j2, i2, Blocks.lava.getDefaultState()); +- } +- else +- { +- p_180702_5_.setBlockState(j3, j2, i2, Blocks.air.getDefaultState()); +- +- if (iblockstate2.getBlock() == Blocks.sand) +- { +- p_180702_5_.setBlockState(j3, j2 + 1, i2, iblockstate2.getValue(BlockSand.VARIANT) == BlockSand.EnumType.RED_SAND ? Blocks.red_sandstone.getDefaultState() : Blocks.sandstone.getDefaultState()); +- } +- +- if (flag1 && p_180702_5_.getBlockState(j3, j2 - 1, i2).getBlock() == Blocks.dirt) +- { +- blockpos$mutableblockpos.func_181079_c(j3 + p_180702_3_ * 16, 0, i2 + p_180702_4_ * 16); +- p_180702_5_.setBlockState(j3, j2 - 1, i2, this.worldObj.getBiomeGenForCoords(blockpos$mutableblockpos).topBlock.getBlock().getDefaultState()); +- } +- } +- } ++ digBlock(p_180702_5_, j3, j2, i2, p_180702_3_, p_180702_4_, flag1, iblockstate1, iblockstate2); + } + } + } +@@ -261,4 +240,71 @@ + } + } + } ++ ++ protected boolean isOceanBlock(ChunkPrimer data, int x, int y, int z, int chunkX, int chunkZ) ++ { ++ net.minecraft.block.Block block = data.getBlockState(x, y, z).getBlock(); ++ return block== Blocks.flowing_water || block == Blocks.water; ++ } ++ ++ //Exception biomes to make sure we generate like vanilla ++ private boolean isExceptionBiome(net.minecraft.world.biome.BiomeGenBase biome) ++ { ++ if (biome == net.minecraft.world.biome.BiomeGenBase.beach) return true; ++ if (biome == net.minecraft.world.biome.BiomeGenBase.desert) return true; ++ return false; ++ } ++ ++ //Determine if the block at the specified location is the top block for the biome, we take into account ++ //Vanilla bugs to make sure that we generate the map the same way vanilla does. ++ private boolean isTopBlock(ChunkPrimer data, int x, int y, int z, int chunkX, int chunkZ) ++ { ++ net.minecraft.world.biome.BiomeGenBase biome = worldObj.getBiomeGenForCoords(new BlockPos(x + chunkX * 16, 0, z + chunkZ * 16)); ++ IBlockState state = data.getBlockState(x, y, z); ++ return (isExceptionBiome(biome) ? state.getBlock() == Blocks.grass : state.getBlock() == biome.topBlock); ++ } ++ ++ /** ++ * Digs out the current block, default implementation removes stone, filler, and top block ++ * Sets the block to lava if y is less then 10, and air other wise. ++ * If setting to air, it also checks to see if we've broken the surface and if so ++ * tries to make the floor the biome's top block ++ * ++ * @param data Block data array ++ * @param index Pre-calculated index into block data ++ * @param x local X position ++ * @param y local Y position ++ * @param z local Z position ++ * @param chunkX Chunk X position ++ * @param chunkZ Chunk Y position ++ * @param foundTop True if we've encountered the biome's top block. Ideally if we've broken the surface. ++ */ ++ protected void digBlock(ChunkPrimer data, int x, int y, int z, int chunkX, int chunkZ, boolean foundTop, IBlockState state, IBlockState up) ++ { ++ net.minecraft.world.biome.BiomeGenBase biome = worldObj.getBiomeGenForCoords(new BlockPos(x + chunkX * 16, 0, z + chunkZ * 16)); ++ IBlockState top = biome.topBlock; ++ IBlockState filler = biome.fillerBlock; ++ ++ if (this.func_175793_a(state, up) || state.getBlock() == top.getBlock() || state.getBlock() == filler.getBlock()) ++ { ++ if (y < 10) ++ { ++ data.setBlockState(x, y, z, Blocks.lava.getDefaultState()); ++ } ++ else ++ { ++ data.setBlockState(x, y, z, Blocks.air.getDefaultState()); ++ ++ if (up.getBlock() == Blocks.sand) ++ { ++ data.setBlockState(x, y + 1, z, up.getValue(BlockSand.VARIANT) == BlockSand.EnumType.RED_SAND ? Blocks.red_sandstone.getDefaultState() : Blocks.sandstone.getDefaultState()); ++ } ++ ++ if (foundTop && data.getBlockState(x, y - 1, z).getBlock() == filler.getBlock()) ++ { ++ data.setBlockState(x, y - 1, z, top.getBlock().getDefaultState()); ++ } ++ } ++ } ++ } + } diff --git a/patches/minecraft/net/minecraft/world/gen/feature/WorldGenDungeons.java.patch b/patches/minecraft/net/minecraft/world/gen/feature/WorldGenDungeons.java.patch new file mode 100644 index 0000000000..fe5d8f922b --- /dev/null +++ b/patches/minecraft/net/minecraft/world/gen/feature/WorldGenDungeons.java.patch @@ -0,0 +1,30 @@ +--- ../src-base/minecraft/net/minecraft/world/gen/feature/WorldGenDungeons.java ++++ ../src-work/minecraft/net/minecraft/world/gen/feature/WorldGenDungeons.java +@@ -123,12 +123,11 @@ + if (j3 == 1) + { + worldIn.setBlockState(blockpos2, Blocks.chest.correctFacing(worldIn, blockpos2, Blocks.chest.getDefaultState()), 2); +- List list = WeightedRandomChestContent.func_177629_a(CHESTCONTENT, new WeightedRandomChestContent[] {Items.enchanted_book.getRandom(p_180709_2_)}); + TileEntity tileentity1 = worldIn.getTileEntity(blockpos2); + + if (tileentity1 instanceof TileEntityChest) + { +- WeightedRandomChestContent.generateChestContents(p_180709_2_, list, (TileEntityChest)tileentity1, 8); ++ WeightedRandomChestContent.generateChestContents(p_180709_2_, net.minecraftforge.common.ChestGenHooks.getItems(net.minecraftforge.common.ChestGenHooks.DUNGEON_CHEST, p_180709_2_), (TileEntityChest)tileentity1, 8); + } + + break; +@@ -159,6 +158,12 @@ + + private String pickMobSpawner(Random p_76543_1_) + { +- return SPAWNERTYPES[p_76543_1_.nextInt(SPAWNERTYPES.length)]; ++ return net.minecraftforge.common.DungeonHooks.getRandomDungeonMob(p_76543_1_); + } ++ ++ static ++ { ++ net.minecraftforge.common.ChestGenHooks.init(net.minecraftforge.common.ChestGenHooks.DUNGEON_CHEST, CHESTCONTENT, 8, 8); ++ net.minecraftforge.common.ChestGenHooks.addItem(net.minecraftforge.common.ChestGenHooks.DUNGEON_CHEST, new WeightedRandomChestContent(new net.minecraft.item.ItemStack(Items.enchanted_book, 1, 0), 1, 1, 1)); ++ } + } diff --git a/patches/minecraft/net/minecraft/world/gen/layer/GenLayer.java.patch b/patches/minecraft/net/minecraft/world/gen/layer/GenLayer.java.patch new file mode 100644 index 0000000000..e3a76dd0b9 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/gen/layer/GenLayer.java.patch @@ -0,0 +1,55 @@ +--- ../src-base/minecraft/net/minecraft/world/gen/layer/GenLayer.java ++++ ../src-work/minecraft/net/minecraft/world/gen/layer/GenLayer.java +@@ -52,12 +52,12 @@ + i = 6; + } + ++ i = getModdedBiomeSize(p_180781_2_, j); ++ + GenLayer lvt_8_1_ = GenLayerZoom.magnify(1000L, genlayer4, 0); + GenLayerRiverInit genlayerriverinit = new GenLayerRiverInit(100L, lvt_8_1_); +- GenLayerBiome lvt_9_1_ = new GenLayerBiome(200L, genlayer4, p_180781_2_, p_180781_3_); +- GenLayer genlayer6 = GenLayerZoom.magnify(1000L, lvt_9_1_, 2); +- GenLayerBiomeEdge genlayerbiomeedge = new GenLayerBiomeEdge(1000L, genlayer6); + GenLayer lvt_10_1_ = GenLayerZoom.magnify(1000L, genlayerriverinit, 2); ++ GenLayer genlayerbiomeedge = p_180781_2_.getBiomeLayer(p_180781_0_, genlayer4, p_180781_3_); + GenLayer genlayerhills = new GenLayerHills(1000L, genlayerbiomeedge, lvt_10_1_); + GenLayer genlayer5 = GenLayerZoom.magnify(1000L, genlayerriverinit, 2); + genlayer5 = GenLayerZoom.magnify(1000L, genlayer5, j); +@@ -191,7 +191,7 @@ + + protected static boolean isBiomeOceanic(int p_151618_0_) + { +- return p_151618_0_ == BiomeGenBase.ocean.biomeID || p_151618_0_ == BiomeGenBase.deepOcean.biomeID || p_151618_0_ == BiomeGenBase.frozenOcean.biomeID; ++ return net.minecraftforge.common.BiomeManager.oceanBiomes.contains(BiomeGenBase.getBiome(p_151618_0_)); + } + + protected int selectRandom(int... p_151619_1_) +@@ -203,4 +203,27 @@ + { + return p_151617_2_ == p_151617_3_ && p_151617_3_ == p_151617_4_ ? p_151617_2_ : (p_151617_1_ == p_151617_2_ && p_151617_1_ == p_151617_3_ ? p_151617_1_ : (p_151617_1_ == p_151617_2_ && p_151617_1_ == p_151617_4_ ? p_151617_1_ : (p_151617_1_ == p_151617_3_ && p_151617_1_ == p_151617_4_ ? p_151617_1_ : (p_151617_1_ == p_151617_2_ && p_151617_3_ != p_151617_4_ ? p_151617_1_ : (p_151617_1_ == p_151617_3_ && p_151617_2_ != p_151617_4_ ? p_151617_1_ : (p_151617_1_ == p_151617_4_ && p_151617_2_ != p_151617_3_ ? p_151617_1_ : (p_151617_2_ == p_151617_3_ && p_151617_1_ != p_151617_4_ ? p_151617_2_ : (p_151617_2_ == p_151617_4_ && p_151617_1_ != p_151617_3_ ? p_151617_2_ : (p_151617_3_ == p_151617_4_ && p_151617_1_ != p_151617_2_ ? p_151617_3_ : this.selectRandom(new int[] {p_151617_1_, p_151617_2_, p_151617_3_, p_151617_4_})))))))))); + } ++ ++ /* ======================================== FORGE START =====================================*/ ++ protected long nextLong(long par1) ++ { ++ long j = (this.chunkSeed >> 24) % par1; ++ ++ if (j < 0) ++ { ++ j += par1; ++ } ++ ++ this.chunkSeed *= this.chunkSeed * 6364136223846793005L + 1442695040888963407L; ++ this.chunkSeed += this.worldGenSeed; ++ return j; ++ } ++ ++ public static int getModdedBiomeSize(WorldType worldType, int original) ++ { ++ net.minecraftforge.event.terraingen.WorldTypeEvent.BiomeSize event = new net.minecraftforge.event.terraingen.WorldTypeEvent.BiomeSize(worldType, original); ++ net.minecraftforge.common.MinecraftForge.TERRAIN_GEN_BUS.post(event); ++ return event.newSize; ++ } ++ /* ========================================= FORGE END ======================================*/ + } diff --git a/patches/minecraft/net/minecraft/world/gen/layer/GenLayerBiome.java.patch b/patches/minecraft/net/minecraft/world/gen/layer/GenLayerBiome.java.patch new file mode 100644 index 0000000000..28a968bdde --- /dev/null +++ b/patches/minecraft/net/minecraft/world/gen/layer/GenLayerBiome.java.patch @@ -0,0 +1,94 @@ +--- ../src-base/minecraft/net/minecraft/world/gen/layer/GenLayerBiome.java ++++ ../src-work/minecraft/net/minecraft/world/gen/layer/GenLayerBiome.java +@@ -6,10 +6,9 @@ + + public class GenLayerBiome extends GenLayer + { +- private BiomeGenBase[] field_151623_c = new BiomeGenBase[] {BiomeGenBase.desert, BiomeGenBase.desert, BiomeGenBase.desert, BiomeGenBase.savanna, BiomeGenBase.savanna, BiomeGenBase.plains}; +- private BiomeGenBase[] field_151621_d = new BiomeGenBase[] {BiomeGenBase.forest, BiomeGenBase.roofedForest, BiomeGenBase.extremeHills, BiomeGenBase.plains, BiomeGenBase.birchForest, BiomeGenBase.swampland}; +- private BiomeGenBase[] field_151622_e = new BiomeGenBase[] {BiomeGenBase.forest, BiomeGenBase.extremeHills, BiomeGenBase.taiga, BiomeGenBase.plains}; +- private BiomeGenBase[] field_151620_f = new BiomeGenBase[] {BiomeGenBase.icePlains, BiomeGenBase.icePlains, BiomeGenBase.icePlains, BiomeGenBase.coldTaiga}; ++ @SuppressWarnings("unchecked") ++ private java.util.List[] biomes = new java.util.ArrayList[net.minecraftforge.common.BiomeManager.BiomeType.values().length]; ++ + private final ChunkProviderSettings field_175973_g; + + public GenLayerBiome(long p_i45560_1_, GenLayer p_i45560_3_, WorldType p_i45560_4_, String p_i45560_5_) +@@ -17,9 +16,30 @@ + super(p_i45560_1_); + this.parent = p_i45560_3_; + ++ for (net.minecraftforge.common.BiomeManager.BiomeType type : net.minecraftforge.common.BiomeManager.BiomeType.values()) ++ { ++ com.google.common.collect.ImmutableList biomesToAdd = net.minecraftforge.common.BiomeManager.getBiomes(type); ++ int idx = type.ordinal(); ++ ++ if (biomes[idx] == null) biomes[idx] = new java.util.ArrayList(); ++ if (biomesToAdd != null) biomes[idx].addAll(biomesToAdd); ++ } ++ ++ int desertIdx = net.minecraftforge.common.BiomeManager.BiomeType.DESERT.ordinal(); ++ ++ biomes[desertIdx].add(new net.minecraftforge.common.BiomeManager.BiomeEntry(BiomeGenBase.desert, 30)); ++ biomes[desertIdx].add(new net.minecraftforge.common.BiomeManager.BiomeEntry(BiomeGenBase.savanna, 20)); ++ biomes[desertIdx].add(new net.minecraftforge.common.BiomeManager.BiomeEntry(BiomeGenBase.plains, 10)); ++ + if (p_i45560_4_ == WorldType.DEFAULT_1_1) + { +- this.field_151623_c = new BiomeGenBase[] {BiomeGenBase.desert, BiomeGenBase.forest, BiomeGenBase.extremeHills, BiomeGenBase.swampland, BiomeGenBase.plains, BiomeGenBase.taiga}; ++ biomes[desertIdx].clear(); ++ biomes[desertIdx].add(new net.minecraftforge.common.BiomeManager.BiomeEntry(BiomeGenBase.desert, 10)); ++ biomes[desertIdx].add(new net.minecraftforge.common.BiomeManager.BiomeEntry(BiomeGenBase.forest, 10)); ++ biomes[desertIdx].add(new net.minecraftforge.common.BiomeManager.BiomeEntry(BiomeGenBase.extremeHills, 10)); ++ biomes[desertIdx].add(new net.minecraftforge.common.BiomeManager.BiomeEntry(BiomeGenBase.swampland, 10)); ++ biomes[desertIdx].add(new net.minecraftforge.common.BiomeManager.BiomeEntry(BiomeGenBase.plains, 10)); ++ biomes[desertIdx].add(new net.minecraftforge.common.BiomeManager.BiomeEntry(BiomeGenBase.taiga, 10)); + this.field_175973_g = null; + } + else if (p_i45560_4_ == WorldType.CUSTOMIZED) +@@ -73,7 +93,7 @@ + } + else + { +- aint1[j + i * areaWidth] = this.field_151623_c[this.nextInt(this.field_151623_c.length)].biomeID; ++ aint1[j + i * areaWidth] = getWeightedBiomeEntry(net.minecraftforge.common.BiomeManager.BiomeType.DESERT).biome.biomeID; + } + } + else if (k == 2) +@@ -84,7 +104,7 @@ + } + else + { +- aint1[j + i * areaWidth] = this.field_151621_d[this.nextInt(this.field_151621_d.length)].biomeID; ++ aint1[j + i * areaWidth] = getWeightedBiomeEntry(net.minecraftforge.common.BiomeManager.BiomeType.WARM).biome.biomeID; + } + } + else if (k == 3) +@@ -95,12 +115,12 @@ + } + else + { +- aint1[j + i * areaWidth] = this.field_151622_e[this.nextInt(this.field_151622_e.length)].biomeID; ++ aint1[j + i * areaWidth] = getWeightedBiomeEntry(net.minecraftforge.common.BiomeManager.BiomeType.COOL).biome.biomeID; + } + } + else if (k == 4) + { +- aint1[j + i * areaWidth] = this.field_151620_f[this.nextInt(this.field_151620_f.length)].biomeID; ++ aint1[j + i * areaWidth] = getWeightedBiomeEntry(net.minecraftforge.common.BiomeManager.BiomeType.ICY).biome.biomeID; + } + else + { +@@ -111,4 +131,12 @@ + + return aint1; + } ++ ++ protected net.minecraftforge.common.BiomeManager.BiomeEntry getWeightedBiomeEntry(net.minecraftforge.common.BiomeManager.BiomeType type) ++ { ++ java.util.List biomeList = biomes[type.ordinal()]; ++ int totalWeight = net.minecraft.util.WeightedRandom.getTotalWeight(biomeList); ++ int weight = net.minecraftforge.common.BiomeManager.isTypeListModded(type)?nextInt(totalWeight):nextInt(totalWeight / 10) * 10; ++ return (net.minecraftforge.common.BiomeManager.BiomeEntry)net.minecraft.util.WeightedRandom.getRandomItem(biomeList, weight); ++ } + } diff --git a/patches/minecraft/net/minecraft/world/gen/structure/ComponentScatteredFeaturePieces.java.patch b/patches/minecraft/net/minecraft/world/gen/structure/ComponentScatteredFeaturePieces.java.patch new file mode 100644 index 0000000000..8d5ce18f23 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/gen/structure/ComponentScatteredFeaturePieces.java.patch @@ -0,0 +1,79 @@ +--- ../src-base/minecraft/net/minecraft/world/gen/structure/ComponentScatteredFeaturePieces.java ++++ ../src-work/minecraft/net/minecraft/world/gen/structure/ComponentScatteredFeaturePieces.java +@@ -40,6 +40,12 @@ + { + } + ++ static ++ { ++ net.minecraftforge.common.ChestGenHooks.init(net.minecraftforge.common.ChestGenHooks.PYRAMID_DESERT_CHEST, itemsToGenerateInTemple, 2, 7); ++ net.minecraftforge.common.ChestGenHooks.addItem(net.minecraftforge.common.ChestGenHooks.PYRAMID_DESERT_CHEST, new WeightedRandomChestContent(new net.minecraft.item.ItemStack(Items.enchanted_book, 1, 0), 1, 1, 1)); ++ } ++ + public DesertPyramid(Random p_i2062_1_, int p_i2062_2_, int p_i2062_3_) + { + super(p_i2062_1_, p_i2062_2_, 64, p_i2062_3_, 21, 15, 21); +@@ -258,7 +264,7 @@ + { + int l1 = enumfacing.getFrontOffsetX() * 2; + int i2 = enumfacing.getFrontOffsetZ() * 2; +- this.field_74940_h[enumfacing.getHorizontalIndex()] = this.func_180778_a(worldIn, p_74875_3_, p_74875_2_, 10 + l1, -11, 10 + i2, WeightedRandomChestContent.func_177629_a(itemsToGenerateInTemple, new WeightedRandomChestContent[] {Items.enchanted_book.getRandom(p_74875_2_)}), 2 + p_74875_2_.nextInt(5)); ++ this.field_74940_h[enumfacing.getHorizontalIndex()] = this.func_180778_a(worldIn, p_74875_3_, p_74875_2_, 10 + l1, -11, 10 + i2, net.minecraftforge.common.ChestGenHooks.getItems(net.minecraftforge.common.ChestGenHooks.PYRAMID_DESERT_CHEST, p_74875_2_), net.minecraftforge.common.ChestGenHooks.getCount(net.minecraftforge.common.ChestGenHooks.PYRAMID_DESERT_CHEST, p_74875_2_)); + } + } + +@@ -362,6 +368,13 @@ + private static final List field_175815_j = Lists.newArrayList(new WeightedRandomChestContent[] {new WeightedRandomChestContent(Items.arrow, 0, 2, 7, 30)}); + private static ComponentScatteredFeaturePieces.JunglePyramid.Stones junglePyramidsRandomScatteredStones = new ComponentScatteredFeaturePieces.JunglePyramid.Stones(); + ++ static ++ { ++ net.minecraftforge.common.ChestGenHooks.init(net.minecraftforge.common.ChestGenHooks.PYRAMID_JUNGLE_DISPENSER, field_175815_j, 2, 2); ++ net.minecraftforge.common.ChestGenHooks.init(net.minecraftforge.common.ChestGenHooks.PYRAMID_JUNGLE_CHEST, field_175816_i, 2, 7); ++ net.minecraftforge.common.ChestGenHooks.addItem(net.minecraftforge.common.ChestGenHooks.PYRAMID_JUNGLE_CHEST, new WeightedRandomChestContent(new net.minecraft.item.ItemStack(Items.enchanted_book, 1, 0), 1, 1, 1)); ++ } ++ + public JunglePyramid() + { + } +@@ -518,9 +531,12 @@ + this.func_175811_a(worldIn, Blocks.redstone_wire.getDefaultState(), 4, -3, 1, p_74875_3_); + this.func_175811_a(worldIn, Blocks.mossy_cobblestone.getDefaultState(), 3, -3, 1, p_74875_3_); + ++ net.minecraftforge.common.ChestGenHooks dispenser = net.minecraftforge.common.ChestGenHooks.getInfo(net.minecraftforge.common.ChestGenHooks.PYRAMID_JUNGLE_DISPENSER); ++ net.minecraftforge.common.ChestGenHooks chest = net.minecraftforge.common.ChestGenHooks.getInfo(net.minecraftforge.common.ChestGenHooks.PYRAMID_JUNGLE_CHEST); ++ + if (!this.field_74945_j) + { +- this.field_74945_j = this.func_175806_a(worldIn, p_74875_3_, p_74875_2_, 3, -2, 1, EnumFacing.NORTH.getIndex(), field_175815_j, 2); ++ this.field_74945_j = this.func_175806_a(worldIn, p_74875_3_, p_74875_2_, 3, -2, 1, EnumFacing.NORTH.getIndex(), dispenser.getItems(p_74875_2_), dispenser.getCount(p_74875_2_)); + } + + this.func_175811_a(worldIn, Blocks.vine.getStateFromMeta(15), 3, -2, 2, p_74875_3_); +@@ -537,7 +553,7 @@ + + if (!this.field_74946_k) + { +- this.field_74946_k = this.func_175806_a(worldIn, p_74875_3_, p_74875_2_, 9, -2, 3, EnumFacing.WEST.getIndex(), field_175815_j, 2); ++ this.field_74946_k = this.func_175806_a(worldIn, p_74875_3_, p_74875_2_, 9, -2, 3, EnumFacing.WEST.getIndex(), dispenser.getItems(p_74875_2_), dispenser.getCount(p_74875_2_)); + } + + this.func_175811_a(worldIn, Blocks.vine.getStateFromMeta(15), 8, -1, 3, p_74875_3_); +@@ -545,7 +561,7 @@ + + if (!this.field_74947_h) + { +- this.field_74947_h = this.func_180778_a(worldIn, p_74875_3_, p_74875_2_, 8, -3, 3, WeightedRandomChestContent.func_177629_a(field_175816_i, new WeightedRandomChestContent[] {Items.enchanted_book.getRandom(p_74875_2_)}), 2 + p_74875_2_.nextInt(5)); ++ this.field_74947_h = this.func_180778_a(worldIn, p_74875_3_, p_74875_2_, 8, -3, 3, chest.getItems(p_74875_2_), chest.getCount(p_74875_2_)); + } + + this.func_175811_a(worldIn, Blocks.mossy_cobblestone.getDefaultState(), 9, -3, 2, p_74875_3_); +@@ -578,7 +594,7 @@ + + if (!this.field_74948_i) + { +- this.field_74948_i = this.func_180778_a(worldIn, p_74875_3_, p_74875_2_, 9, -3, 10, WeightedRandomChestContent.func_177629_a(field_175816_i, new WeightedRandomChestContent[] {Items.enchanted_book.getRandom(p_74875_2_)}), 2 + p_74875_2_.nextInt(5)); ++ this.field_74948_i = this.func_180778_a(worldIn, p_74875_3_, p_74875_2_, 9, -3, 10, chest.getItems(p_74875_2_), chest.getCount(p_74875_2_)); + } + + return true; diff --git a/patches/minecraft/net/minecraft/world/gen/structure/StructureMineshaftPieces.java.patch b/patches/minecraft/net/minecraft/world/gen/structure/StructureMineshaftPieces.java.patch new file mode 100644 index 0000000000..0c563bb502 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/gen/structure/StructureMineshaftPieces.java.patch @@ -0,0 +1,33 @@ +--- ../src-base/minecraft/net/minecraft/world/gen/structure/StructureMineshaftPieces.java ++++ ../src-work/minecraft/net/minecraft/world/gen/structure/StructureMineshaftPieces.java +@@ -32,6 +32,12 @@ + MapGenStructureIO.registerStructureComponent(StructureMineshaftPieces.Stairs.class, "MSStairs"); + } + ++ static ++ { ++ net.minecraftforge.common.ChestGenHooks.init(net.minecraftforge.common.ChestGenHooks.MINESHAFT_CORRIDOR, field_175893_a, 8, 8); ++ net.minecraftforge.common.ChestGenHooks.addItem(net.minecraftforge.common.ChestGenHooks.MINESHAFT_CORRIDOR, new WeightedRandomChestContent(new net.minecraft.item.ItemStack(Items.enchanted_book, 1, 0), 1, 1, 1)); ++ } ++ + private static StructureComponent func_175892_a(List p_175892_0_, Random p_175892_1_, int p_175892_2_, int p_175892_3_, int p_175892_4_, EnumFacing p_175892_5_, int p_175892_6_) + { + int i = p_175892_1_.nextInt(100); +@@ -351,14 +357,15 @@ + this.func_175809_a(worldIn, p_74875_3_, p_74875_2_, 0.05F, 1, 2, k1 - 1, Blocks.torch.getStateFromMeta(EnumFacing.UP.getIndex())); + this.func_175809_a(worldIn, p_74875_3_, p_74875_2_, 0.05F, 1, 2, k1 + 1, Blocks.torch.getStateFromMeta(EnumFacing.UP.getIndex())); + ++ net.minecraftforge.common.ChestGenHooks info = net.minecraftforge.common.ChestGenHooks.getInfo(net.minecraftforge.common.ChestGenHooks.MINESHAFT_CORRIDOR); + if (p_74875_2_.nextInt(100) == 0) + { +- this.func_180778_a(worldIn, p_74875_3_, p_74875_2_, 2, 0, k1 - 1, WeightedRandomChestContent.func_177629_a(StructureMineshaftPieces.field_175893_a, new WeightedRandomChestContent[] {Items.enchanted_book.getRandom(p_74875_2_)}), 3 + p_74875_2_.nextInt(4)); ++ this.func_180778_a(worldIn, p_74875_3_, p_74875_2_, 2, 0, k1 - 1, info.getItems(p_74875_2_), info.getCount(p_74875_2_)); + } + + if (p_74875_2_.nextInt(100) == 0) + { +- this.func_180778_a(worldIn, p_74875_3_, p_74875_2_, 0, 0, k1 + 1, WeightedRandomChestContent.func_177629_a(StructureMineshaftPieces.field_175893_a, new WeightedRandomChestContent[] {Items.enchanted_book.getRandom(p_74875_2_)}), 3 + p_74875_2_.nextInt(4)); ++ this.func_180778_a(worldIn, p_74875_3_, p_74875_2_, 0, 0, k1 + 1, info.getItems(p_74875_2_), info.getCount(p_74875_2_)); + } + + if (this.hasSpiders && !this.spawnerPlaced) diff --git a/patches/minecraft/net/minecraft/world/gen/structure/StructureStrongholdPieces.java.patch b/patches/minecraft/net/minecraft/world/gen/structure/StructureStrongholdPieces.java.patch new file mode 100644 index 0000000000..83e88c9b31 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/gen/structure/StructureStrongholdPieces.java.patch @@ -0,0 +1,75 @@ +--- ../src-base/minecraft/net/minecraft/world/gen/structure/StructureStrongholdPieces.java ++++ ../src-work/minecraft/net/minecraft/world/gen/structure/StructureStrongholdPieces.java +@@ -240,6 +240,12 @@ + { + } + ++ static ++ { ++ net.minecraftforge.common.ChestGenHooks.init(net.minecraftforge.common.ChestGenHooks.STRONGHOLD_CORRIDOR, strongholdChestContents, 2, 4); ++ net.minecraftforge.common.ChestGenHooks.addItem(net.minecraftforge.common.ChestGenHooks.STRONGHOLD_CORRIDOR, new WeightedRandomChestContent(new net.minecraft.item.ItemStack(Items.enchanted_book, 1, 0), 1, 1, 1)); ++ } ++ + public ChestCorridor(int p_i45582_1_, Random p_i45582_2_, StructureBoundingBox p_i45582_3_, EnumFacing p_i45582_4_) + { + super(p_i45582_1_); +@@ -296,7 +302,7 @@ + if (!this.hasMadeChest && p_74875_3_.func_175898_b(new BlockPos(this.getXWithOffset(3, 3), this.getYWithOffset(2), this.getZWithOffset(3, 3)))) + { + this.hasMadeChest = true; +- this.func_180778_a(worldIn, p_74875_3_, p_74875_2_, 3, 2, 3, WeightedRandomChestContent.func_177629_a(strongholdChestContents, new WeightedRandomChestContent[] {Items.enchanted_book.getRandom(p_74875_2_)}), 2 + p_74875_2_.nextInt(2)); ++ this.func_180778_a(worldIn, p_74875_3_, p_74875_2_, 3, 2, 3, net.minecraftforge.common.ChestGenHooks.getItems(net.minecraftforge.common.ChestGenHooks.STRONGHOLD_CORRIDOR, p_74875_2_), net.minecraftforge.common.ChestGenHooks.getCount(net.minecraftforge.common.ChestGenHooks.STRONGHOLD_CORRIDOR, p_74875_2_)); + } + + return true; +@@ -592,6 +598,12 @@ + private static final List strongholdLibraryChestContents = Lists.newArrayList(new WeightedRandomChestContent[] {new WeightedRandomChestContent(Items.book, 0, 1, 3, 20), new WeightedRandomChestContent(Items.paper, 0, 2, 7, 20), new WeightedRandomChestContent(Items.map, 0, 1, 1, 1), new WeightedRandomChestContent(Items.compass, 0, 1, 1, 1)}); + private boolean isLargeRoom; + ++ static ++ { ++ net.minecraftforge.common.ChestGenHooks.init(net.minecraftforge.common.ChestGenHooks.STRONGHOLD_LIBRARY, strongholdLibraryChestContents, 1, 5); ++ net.minecraftforge.common.ChestGenHooks.addItem(net.minecraftforge.common.ChestGenHooks.STRONGHOLD_LIBRARY, new WeightedRandomChestContent(new net.minecraft.item.ItemStack(Items.enchanted_book, 1, 0), 1, 5, 2)); ++ } ++ + public Library() + { + } +@@ -736,12 +748,13 @@ + this.func_175811_a(worldIn, Blocks.torch.getDefaultState(), i1, 8, j1 + 1, p_74875_3_); + } + +- this.func_180778_a(worldIn, p_74875_3_, p_74875_2_, 3, 3, 5, WeightedRandomChestContent.func_177629_a(strongholdLibraryChestContents, new WeightedRandomChestContent[] {Items.enchanted_book.getRandom(p_74875_2_, 1, 5, 2)}), 1 + p_74875_2_.nextInt(4)); ++ net.minecraftforge.common.ChestGenHooks info = net.minecraftforge.common.ChestGenHooks.getInfo(net.minecraftforge.common.ChestGenHooks.STRONGHOLD_LIBRARY); ++ this.func_180778_a(worldIn, p_74875_3_, p_74875_2_, 3, 3, 5, info.getItems(p_74875_2_), info.getCount(p_74875_2_)); + + if (this.isLargeRoom) + { + this.func_175811_a(worldIn, Blocks.air.getDefaultState(), 12, 9, 1, p_74875_3_); +- this.func_180778_a(worldIn, p_74875_3_, p_74875_2_, 12, 8, 1, WeightedRandomChestContent.func_177629_a(strongholdLibraryChestContents, new WeightedRandomChestContent[] {Items.enchanted_book.getRandom(p_74875_2_, 1, 5, 2)}), 1 + p_74875_2_.nextInt(4)); ++ this.func_180778_a(worldIn, p_74875_3_, p_74875_2_, 12, 8, 1, info.getItems(p_74875_2_), info.getCount(p_74875_2_)); + } + + return true; +@@ -1013,6 +1026,12 @@ + private static final List strongholdRoomCrossingChestContents = Lists.newArrayList(new WeightedRandomChestContent[] {new WeightedRandomChestContent(Items.iron_ingot, 0, 1, 5, 10), new WeightedRandomChestContent(Items.gold_ingot, 0, 1, 3, 5), new WeightedRandomChestContent(Items.redstone, 0, 4, 9, 5), new WeightedRandomChestContent(Items.coal, 0, 3, 8, 10), new WeightedRandomChestContent(Items.bread, 0, 1, 3, 15), new WeightedRandomChestContent(Items.apple, 0, 1, 3, 15), new WeightedRandomChestContent(Items.iron_pickaxe, 0, 1, 1, 1)}); + protected int roomType; + ++ static ++ { ++ net.minecraftforge.common.ChestGenHooks.init(net.minecraftforge.common.ChestGenHooks.STRONGHOLD_CROSSING, strongholdRoomCrossingChestContents, 1, 5); ++ net.minecraftforge.common.ChestGenHooks.addItem(net.minecraftforge.common.ChestGenHooks.STRONGHOLD_CROSSING, new WeightedRandomChestContent(new net.minecraft.item.ItemStack(Items.enchanted_book, 1, 0), 1, 1, 1)); ++ } ++ + public RoomCrossing() + { + } +@@ -1151,7 +1170,7 @@ + this.func_175811_a(worldIn, Blocks.ladder.getStateFromMeta(this.getMetadataWithOffset(Blocks.ladder, EnumFacing.WEST.getIndex())), 9, 1, 3, p_74875_3_); + this.func_175811_a(worldIn, Blocks.ladder.getStateFromMeta(this.getMetadataWithOffset(Blocks.ladder, EnumFacing.WEST.getIndex())), 9, 2, 3, p_74875_3_); + this.func_175811_a(worldIn, Blocks.ladder.getStateFromMeta(this.getMetadataWithOffset(Blocks.ladder, EnumFacing.WEST.getIndex())), 9, 3, 3, p_74875_3_); +- this.func_180778_a(worldIn, p_74875_3_, p_74875_2_, 3, 4, 8, WeightedRandomChestContent.func_177629_a(strongholdRoomCrossingChestContents, new WeightedRandomChestContent[] {Items.enchanted_book.getRandom(p_74875_2_)}), 1 + p_74875_2_.nextInt(4)); ++ this.func_180778_a(worldIn, p_74875_3_, p_74875_2_, 3, 4, 8, net.minecraftforge.common.ChestGenHooks.getItems(net.minecraftforge.common.ChestGenHooks.STRONGHOLD_CROSSING, p_74875_2_), net.minecraftforge.common.ChestGenHooks.getCount(net.minecraftforge.common.ChestGenHooks.STRONGHOLD_CROSSING, p_74875_2_)); + } + + return true; diff --git a/patches/minecraft/net/minecraft/world/gen/structure/StructureVillagePieces.java.patch b/patches/minecraft/net/minecraft/world/gen/structure/StructureVillagePieces.java.patch new file mode 100644 index 0000000000..7e6bfd221e --- /dev/null +++ b/patches/minecraft/net/minecraft/world/gen/structure/StructureVillagePieces.java.patch @@ -0,0 +1,84 @@ +--- ../src-base/minecraft/net/minecraft/world/gen/structure/StructureVillagePieces.java ++++ ../src-work/minecraft/net/minecraft/world/gen/structure/StructureVillagePieces.java +@@ -57,6 +57,7 @@ + list.add(new StructureVillagePieces.PieceWeight(StructureVillagePieces.Field2.class, 3, MathHelper.getRandomIntegerInRange(p_75084_0_, 2 + p_75084_1_, 4 + p_75084_1_ * 2))); + list.add(new StructureVillagePieces.PieceWeight(StructureVillagePieces.House2.class, 15, MathHelper.getRandomIntegerInRange(p_75084_0_, 0, 1 + p_75084_1_))); + list.add(new StructureVillagePieces.PieceWeight(StructureVillagePieces.House3.class, 8, MathHelper.getRandomIntegerInRange(p_75084_0_, 0 + p_75084_1_, 3 + p_75084_1_ * 2))); ++ net.minecraftforge.fml.common.registry.VillagerRegistry.addExtraVillageComponents(list, p_75084_0_, p_75084_1_); + Iterator iterator = list.iterator(); + + while (iterator.hasNext()) +@@ -129,6 +130,10 @@ + { + structurevillagepieces$village = StructureVillagePieces.House3.func_175849_a(p_176065_0_, p_176065_2_, p_176065_3_, p_176065_4_, p_176065_5_, p_176065_6_, p_176065_7_, p_176065_8_); + } ++ else ++ { ++ structurevillagepieces$village = net.minecraftforge.fml.common.registry.VillagerRegistry.getVillageComponent(p_176065_1_, p_176065_0_ , p_176065_2_, p_176065_3_, p_176065_4_, p_176065_5_, p_176065_6_, p_176065_7_, p_176065_8_); ++ } + + return structurevillagepieces$village; + } +@@ -833,6 +838,11 @@ + { + } + ++ static ++ { ++ net.minecraftforge.common.ChestGenHooks.init(net.minecraftforge.common.ChestGenHooks.VILLAGE_BLACKSMITH, villageBlacksmithChestContents, 3, 8); ++ } ++ + public House2(StructureVillagePieces.Start p_i45563_1_, int p_i45563_2_, Random p_i45563_3_, StructureBoundingBox p_i45563_4_, EnumFacing p_i45563_5_) + { + super(p_i45563_1_, p_i45563_2_); +@@ -911,7 +921,7 @@ + if (!this.hasMadeChest && p_74875_3_.func_175898_b(new BlockPos(this.getXWithOffset(5, 5), this.getYWithOffset(1), this.getZWithOffset(5, 5)))) + { + this.hasMadeChest = true; +- this.func_180778_a(worldIn, p_74875_3_, p_74875_2_, 5, 1, 5, villageBlacksmithChestContents, 3 + p_74875_2_.nextInt(6)); ++ this.func_180778_a(worldIn, p_74875_3_, p_74875_2_, 5, 1, 5, net.minecraftforge.common.ChestGenHooks.getItems(net.minecraftforge.common.ChestGenHooks.VILLAGE_BLACKSMITH, p_74875_2_), net.minecraftforge.common.ChestGenHooks.getCount(net.minecraftforge.common.ChestGenHooks.VILLAGE_BLACKSMITH, p_74875_2_)); + } + + for (int i = 6; i <= 8; ++i) +@@ -1403,6 +1413,7 @@ + public List structureVillageWeightedPieceList; + public List field_74932_i = Lists.newArrayList(); + public List field_74930_j = Lists.newArrayList(); ++ public BiomeGenBase biome; + + public Start() + { +@@ -1416,6 +1427,7 @@ + this.terrainType = p_i2104_7_; + BiomeGenBase biomegenbase = p_i2104_1_.func_180300_a(new BlockPos(p_i2104_4_, 0, p_i2104_5_), BiomeGenBase.field_180279_ad); + this.inDesert = biomegenbase == BiomeGenBase.desert || biomegenbase == BiomeGenBase.desertHills; ++ this.biome = biomegenbase; + this.func_175846_a(this.inDesert); + } + +@@ -1477,6 +1489,7 @@ + protected int field_143015_k = -1; + private int villagersSpawned; + private boolean field_143014_b; ++ private StructureVillagePieces.Start startPiece; + + public Village() + { +@@ -1489,6 +1502,7 @@ + if (p_i2107_1_ != null) + { + this.field_143014_b = p_i2107_1_.inDesert; ++ startPiece = p_i2107_1_; + } + } + +@@ -1613,6 +1627,9 @@ + + protected IBlockState func_175847_a(IBlockState p_175847_1_) + { ++ net.minecraftforge.event.terraingen.BiomeEvent.GetVillageBlockID event = new net.minecraftforge.event.terraingen.BiomeEvent.GetVillageBlockID(startPiece == null ? null : startPiece.biome, p_175847_1_); ++ net.minecraftforge.common.MinecraftForge.TERRAIN_GEN_BUS.post(event); ++ if (event.getResult() == net.minecraftforge.fml.common.eventhandler.Event.Result.DENY) return event.replacement; + if (this.field_143014_b) + { + if (p_175847_1_.getBlock() == Blocks.log || p_175847_1_.getBlock() == Blocks.log2) diff --git a/src/main/java/net/minecraftforge/fml/common/launcher/FMLDeobfTweaker.java b/src/main/java/net/minecraftforge/fml/common/launcher/FMLDeobfTweaker.java index 8079fe4c81..e8fa787536 100644 --- a/src/main/java/net/minecraftforge/fml/common/launcher/FMLDeobfTweaker.java +++ b/src/main/java/net/minecraftforge/fml/common/launcher/FMLDeobfTweaker.java @@ -31,7 +31,7 @@ public class FMLDeobfTweaker implements ITweaker { classLoader.registerTransformer(transformer); } classLoader.registerTransformer("net.minecraftforge.fml.common.asm.transformers.ModAccessTransformer"); -// classLoader.registerTransformer("net.minecraftforge.fml.common.asm.transformers.ItemStackTransformer"); + classLoader.registerTransformer("net.minecraftforge.fml.common.asm.transformers.ItemStackTransformer"); try { FMLRelaunchLog.fine("Validating minecraft"); diff --git a/src/main/java/net/minecraftforge/fml/common/network/PacketLoggingHandler.java b/src/main/java/net/minecraftforge/fml/common/network/PacketLoggingHandler.java index 64146631c2..1cea65cb7d 100644 --- a/src/main/java/net/minecraftforge/fml/common/network/PacketLoggingHandler.java +++ b/src/main/java/net/minecraftforge/fml/common/network/PacketLoggingHandler.java @@ -62,7 +62,7 @@ public class PacketLoggingHandler { String prefix = (direction == EnumPacketDirection.SERVERBOUND ? "SERVER: C->S" : "CLIENT: S->C"); @Override - protected void decode(ChannelHandlerContext context, ByteBuf input, List output) + protected void decode(ChannelHandlerContext context, ByteBuf input, List output) throws Exception { super.decode(context, input, output); for (ByteBuf pkt : (List)output) @@ -77,7 +77,7 @@ public class PacketLoggingHandler { String prefix = (direction == EnumPacketDirection.SERVERBOUND ? "SERVER: S->C" : "CLIENT: C->S"); @Override - protected void encode(ChannelHandlerContext context, ByteBuf input, ByteBuf output) + protected void encode(ChannelHandlerContext context, ByteBuf input, ByteBuf output) throws Exception { input.markReaderIndex(); FMLLog.log(Level.DEBUG, "%s:\n%s", prefix, ByteBufUtils.getContentDump(input)); diff --git a/src/main/java/net/minecraftforge/fml/common/network/handshake/NetworkDispatcher.java b/src/main/java/net/minecraftforge/fml/common/network/handshake/NetworkDispatcher.java index aa9412512c..e4bcfc6a6f 100644 --- a/src/main/java/net/minecraftforge/fml/common/network/handshake/NetworkDispatcher.java +++ b/src/main/java/net/minecraftforge/fml/common/network/handshake/NetworkDispatcher.java @@ -306,14 +306,14 @@ public class NetworkDispatcher extends SimpleChannelInboundHandler imple } else { - manager.sendPacket(new S40PacketDisconnect(chatcomponenttext), new GenericFutureListener>() + manager.sendPacket(new S40PacketDisconnect(chatcomponenttext), new GenericFutureListener>() { @Override - public void operationComplete(Future result) + public void operationComplete(Future result) { manager.closeChannel(chatcomponenttext); } - }); + }, new GenericFutureListener[0]); } manager.channel().config().setAutoRead(false); } diff --git a/src/main/java/net/minecraftforge/fml/common/network/internal/EntitySpawnHandler.java b/src/main/java/net/minecraftforge/fml/common/network/internal/EntitySpawnHandler.java index 88370df78b..00c1f70794 100644 --- a/src/main/java/net/minecraftforge/fml/common/network/internal/EntitySpawnHandler.java +++ b/src/main/java/net/minecraftforge/fml/common/network/internal/EntitySpawnHandler.java @@ -3,8 +3,6 @@ package net.minecraftforge.fml.common.network.internal; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.SimpleChannelInboundHandler; -import java.util.List; - import org.apache.logging.log4j.Level; import net.minecraft.client.entity.EntityPlayerSP; @@ -128,7 +126,7 @@ public class EntitySpawnHandler extends SimpleChannelInboundHandler) spawnMsg.dataWatcherList); + entity.getDataWatcher().updateWatchedObjectsFromList(spawnMsg.dataWatcherList); } if (spawnMsg.throwerId > 0) diff --git a/src/main/java/net/minecraftforge/fml/common/network/internal/FMLMessage.java b/src/main/java/net/minecraftforge/fml/common/network/internal/FMLMessage.java index 534dc8bedb..bc1178dd67 100644 --- a/src/main/java/net/minecraftforge/fml/common/network/internal/FMLMessage.java +++ b/src/main/java/net/minecraftforge/fml/common/network/internal/FMLMessage.java @@ -157,8 +157,7 @@ public abstract class FMLMessage { double speedScaledX; double speedScaledY; double speedScaledZ; - @SuppressWarnings("rawtypes") - List dataWatcherList; + List dataWatcherList; ByteBuf dataStream; public EntitySpawnMessage() {} diff --git a/src/main/java/net/minecraftforge/fml/common/registry/VillagerRegistry.java b/src/main/java/net/minecraftforge/fml/common/registry/VillagerRegistry.java index b4af637631..8ef6153626 100644 --- a/src/main/java/net/minecraftforge/fml/common/registry/VillagerRegistry.java +++ b/src/main/java/net/minecraftforge/fml/common/registry/VillagerRegistry.java @@ -38,7 +38,10 @@ import net.minecraft.util.RegistryNamespacedDefaultedByKey; import net.minecraft.util.ResourceLocation; import net.minecraft.util.Tuple; import net.minecraft.village.MerchantRecipeList; +import net.minecraft.world.gen.structure.StructureComponent; import net.minecraft.world.gen.structure.StructureVillagePieces; +import net.minecraft.world.gen.structure.StructureVillagePieces.PieceWeight; +import net.minecraft.world.gen.structure.StructureVillagePieces.Village; import net.minecraftforge.fml.common.FMLLog; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @@ -103,7 +106,7 @@ public class VillagerRegistry * @param facing * @param p5 */ - Object buildComponent(StructureVillagePieces.PieceWeight villagePiece, StructureVillagePieces.Start startPiece, @SuppressWarnings("rawtypes") List pieces, Random random, int p1, + Village buildComponent(StructureVillagePieces.PieceWeight villagePiece, StructureVillagePieces.Start startPiece, List pieces, Random random, int p1, int p2, int p3, EnumFacing facing, int p5); } @@ -181,17 +184,16 @@ public class VillagerRegistry return Collections.unmodifiableCollection(instance().newVillagerIds); } - public static void addExtraVillageComponents(@SuppressWarnings("rawtypes") ArrayList components, Random random, int i) + public static void addExtraVillageComponents(List list, Random random, int i) { - @SuppressWarnings("unchecked") - List parts = components; + List parts = list; for (IVillageCreationHandler handler : instance().villageCreationHandlers.values()) { parts.add(handler.getVillagePieceWeight(random, i)); } } - public static Object getVillageComponent(StructureVillagePieces.PieceWeight villagePiece, StructureVillagePieces.Start startPiece, @SuppressWarnings("rawtypes") List pieces, Random random, + public static Village getVillageComponent(StructureVillagePieces.PieceWeight villagePiece, StructureVillagePieces.Start startPiece, List pieces, Random random, int p1, int p2, int p3, EnumFacing facing, int p5) { return instance().villageCreationHandlers.get(villagePiece.villagePieceClass).buildComponent(villagePiece, startPiece, pieces, random, p1, p2, p3, facing, p5);