From 8a11e3bac4e9b0a5b81452989351e5b8d21a6fa8 Mon Sep 17 00:00:00 2001 From: tterrag Date: Sat, 22 Dec 2018 13:31:18 -0500 Subject: [PATCH] Port most of the world patches (#5294) --- .../net/minecraft/world/WorldType.java.patch | 55 ++----- .../world/dimension/Dimension.java.patch | 42 ++--- .../gen/AbstractChunkGenerator.java.patch | 10 ++ .../world/gen/ChunkGeneratorEnd.java.patch | 43 +++++ .../world/gen/ChunkGeneratorNether.java.patch | 49 ++++++ .../gen/ChunkGeneratorOverworld.java.patch | 30 ++++ .../structure/StructurePiece.java.patch | 12 ++ .../structure/StructureStart.java.patch | 22 +++ .../structure/VillagePieces.java.patch | 101 ++++++++++++ .../structure/VillageStructure.java.patch | 11 ++ .../gen/feature/template/Template.java.patch | 11 ++ .../world/gen/layer/GenLayerBiome.java.patch | 85 ++++++++++ .../world/gen/layer/LayerUtil.java.patch | 34 ++++ .../minecraft/world/WorldProvider.java.patch | 100 ------------ .../world/gen/ChunkGeneratorEnd.java.patch | 73 --------- .../world/gen/ChunkGeneratorFlat.java.patch | 29 ---- .../world/gen/ChunkGeneratorHell.java.patch | 120 -------------- .../gen/ChunkGeneratorOverworld.java.patch | 102 ------------ .../world/gen/layer/GenLayer.java.patch | 52 ------ .../world/gen/layer/GenLayerBiome.java.patch | 93 ----------- .../structure/StructureComponent.java.patch | 13 -- .../gen/structure/StructureStart.java.patch | 23 --- .../StructureVillagePieces.java.patch | 93 ----------- .../structure/template/Template.java.patch | 19 --- .../common/extensions/IForgeDimension.java | 84 +++++++--- .../common/extensions/IForgeWorldType.java | 104 ++++++++++++ .../event/ForgeEventFactory.java | 22 +-- .../event/terraingen/BiomeEvent.java | 150 ++++++++++++++++++ .../event/terraingen/ChunkGeneratorEvent.java | 104 ++++++++++++ .../event/terraingen/InitNoiseGensEvent.java | 126 +++++++++++++++ .../event/terraingen/TerrainGen.java | 35 ++++ .../event/terraingen/WorldTypeEvent.java | 146 +++++++++++++++++ .../fml/common/registry/VillagerRegistry.java | 63 ++++---- src/main/resources/forge_at.cfg | 2 + 34 files changed, 1203 insertions(+), 855 deletions(-) create mode 100644 patches/minecraft/net/minecraft/world/gen/AbstractChunkGenerator.java.patch create mode 100644 patches/minecraft/net/minecraft/world/gen/ChunkGeneratorEnd.java.patch create mode 100644 patches/minecraft/net/minecraft/world/gen/ChunkGeneratorNether.java.patch create mode 100644 patches/minecraft/net/minecraft/world/gen/ChunkGeneratorOverworld.java.patch create mode 100644 patches/minecraft/net/minecraft/world/gen/feature/structure/StructurePiece.java.patch create mode 100644 patches/minecraft/net/minecraft/world/gen/feature/structure/StructureStart.java.patch create mode 100644 patches/minecraft/net/minecraft/world/gen/feature/structure/VillagePieces.java.patch create mode 100644 patches/minecraft/net/minecraft/world/gen/feature/structure/VillageStructure.java.patch create mode 100644 patches/minecraft/net/minecraft/world/gen/feature/template/Template.java.patch create mode 100644 patches/minecraft/net/minecraft/world/gen/layer/GenLayerBiome.java.patch create mode 100644 patches/minecraft/net/minecraft/world/gen/layer/LayerUtil.java.patch delete mode 100644 patches_old/minecraft/net/minecraft/world/gen/ChunkGeneratorEnd.java.patch delete mode 100644 patches_old/minecraft/net/minecraft/world/gen/ChunkGeneratorFlat.java.patch delete mode 100644 patches_old/minecraft/net/minecraft/world/gen/ChunkGeneratorHell.java.patch delete mode 100644 patches_old/minecraft/net/minecraft/world/gen/ChunkGeneratorOverworld.java.patch delete mode 100644 patches_old/minecraft/net/minecraft/world/gen/layer/GenLayer.java.patch delete mode 100644 patches_old/minecraft/net/minecraft/world/gen/layer/GenLayerBiome.java.patch delete mode 100644 patches_old/minecraft/net/minecraft/world/gen/structure/StructureComponent.java.patch delete mode 100644 patches_old/minecraft/net/minecraft/world/gen/structure/StructureStart.java.patch delete mode 100644 patches_old/minecraft/net/minecraft/world/gen/structure/StructureVillagePieces.java.patch delete mode 100644 patches_old/minecraft/net/minecraft/world/gen/structure/template/Template.java.patch create mode 100644 src/main/java/net/minecraftforge/common/extensions/IForgeWorldType.java create mode 100644 src/main/java/net/minecraftforge/event/terraingen/BiomeEvent.java create mode 100644 src/main/java/net/minecraftforge/event/terraingen/ChunkGeneratorEvent.java create mode 100644 src/main/java/net/minecraftforge/event/terraingen/InitNoiseGensEvent.java create mode 100644 src/main/java/net/minecraftforge/event/terraingen/TerrainGen.java create mode 100644 src/main/java/net/minecraftforge/event/terraingen/WorldTypeEvent.java diff --git a/patches/minecraft/net/minecraft/world/WorldType.java.patch b/patches/minecraft/net/minecraft/world/WorldType.java.patch index 1279f314a..118c8b687 100644 --- a/patches/minecraft/net/minecraft/world/WorldType.java.patch +++ b/patches/minecraft/net/minecraft/world/WorldType.java.patch @@ -1,5 +1,14 @@ --- a/net/minecraft/world/WorldType.java +++ b/net/minecraft/world/WorldType.java +@@ -3,7 +3,7 @@ + import net.minecraftforge.api.distmarker.Dist; + import net.minecraftforge.api.distmarker.OnlyIn; + +-public class WorldType { ++public class WorldType implements net.minecraftforge.common.extensions.IForgeWorldType { + public static WorldType[] field_77139_a = new WorldType[16]; + public static final WorldType field_77137_b = (new WorldType(0, "default", 1)).func_77129_f(); + public static final WorldType field_77138_c = (new WorldType(1, "flat")).func_205392_a(true); @@ -22,6 +22,10 @@ private boolean field_151361_l; private boolean field_205395_p; @@ -37,49 +46,3 @@ public String func_211888_a() { return this.field_77133_f; } -@@ -117,4 +133,45 @@ - this.field_151361_l = true; - return this; - } -+ -+ /** -+ * Called when 'Create New World' button is pressed before starting game -+ */ -+ public void onGUICreateWorldPress() { } -+ -+ /** -+ * Called when the 'Customize' button is pressed on world creation GUI -+ * @param mc The Minecraft instance -+ * @param gui the createworld GUI -+ */ -+ @OnlyIn(Dist.CLIENT) -+ public void onCustomizeButton(net.minecraft.client.Minecraft mc, net.minecraft.client.gui.GuiCreateWorld gui) { -+ if (this == WorldType.field_77138_c) -+ mc.func_147108_a(new net.minecraft.client.gui.GuiCreateFlatWorld(gui, gui.field_146334_a)); -+ else if (this == WorldType.field_180271_f) -+ mc.func_147108_a(new net.minecraft.client.gui.GuiCreateBuffetWorld(gui, gui.field_146334_a)); -+ } -+ -+ public boolean handleSlimeSpawnReduction(java.util.Random random, World world) { -+ return this == field_77138_c ? random.nextInt(4) != 1 : false; -+ } -+ -+ public double getHorizon(World world) { -+ return this == field_77138_c ? 0.0D : 63.0D; -+ } -+ -+ /** -+ * Get the height to render the clouds for this world type -+ * @return The height to render clouds at -+ */ -+ public float getCloudHeight() { -+ return 128.0F; -+ } -+ -+ @SuppressWarnings("deprecation") -+ public net.minecraft.world.gen.IChunkGenerator createChunkGenerator(World world) { -+ return world.field_73011_w.func_186060_c(); -+ } -+ -+ - } diff --git a/patches/minecraft/net/minecraft/world/dimension/Dimension.java.patch b/patches/minecraft/net/minecraft/world/dimension/Dimension.java.patch index 44073d416..b4ef43445 100644 --- a/patches/minecraft/net/minecraft/world/dimension/Dimension.java.patch +++ b/patches/minecraft/net/minecraft/world/dimension/Dimension.java.patch @@ -18,6 +18,15 @@ } @OnlyIn(Dist.CLIENT) +@@ -79,7 +79,7 @@ + + @OnlyIn(Dist.CLIENT) + public double func_76565_k() { +- return this.field_76579_a.func_72912_H().func_76067_t() == WorldType.field_77138_c ? 1.0D : 0.03125D; ++ return this.field_76579_a.func_72912_H().func_76067_t().voidFadeMagnitude(); + } + + public boolean func_177500_n() { @@ -120,6 +120,7 @@ protected abstract void func_76572_b(); @@ -26,7 +35,7 @@ public abstract IChunkGenerator func_186060_c(); @Nullable -@@ -141,4 +142,101 @@ +@@ -141,4 +142,72 @@ public abstract boolean func_76568_b(int p_76568_1_, int p_76568_2_); public abstract DimensionType func_186058_p(); @@ -94,37 +103,8 @@ + field_76579_a.func_72912_H().func_76069_a(false); + } + -+ /** -+ * Determines if the player can sleep in this world (or if the bed should explode for example). -+ * -+ * @param player The player that is attempting to sleep -+ * @param pos The location where the player tries to sleep at (the position of the clicked on bed for example) -+ * @return the result of a player trying to sleep at the given location -+ */ -+ public SleepResult canSleepAt(net.minecraft.entity.player.EntityPlayer player, BlockPos pos) { -+ return (this.func_76567_e() && this.field_76579_a.func_180494_b(pos) != net.minecraft.init.Biomes.field_76778_j) ? SleepResult.ALLOW : SleepResult.BED_EXPLODES; -+ } -+ -+ /** -+ * If this method returns true, then chunks received by the client will -+ * have {@link net.minecraft.world.chunk.Chunk#resetRelightChecks} called -+ * on them, queuing lighting checks for all air blocks in the chunk (and -+ * any adjacent light-emitting blocks). -+ * -+ * Returning true here is recommended if the chunk generator used also -+ * does this for newly generated chunks. -+ * -+ * @return true if lighting checks should be performed -+ */ -+ public boolean shouldClientCheckLighting() { -+ return !(this instanceof OverworldDimension); -+ } -+ ++ @Override + public World getWorld() { + return this.field_76579_a; -+ } -+ -+ public enum SleepResult { -+ ALLOW, DENY, BED_EXPLODES + } } diff --git a/patches/minecraft/net/minecraft/world/gen/AbstractChunkGenerator.java.patch b/patches/minecraft/net/minecraft/world/gen/AbstractChunkGenerator.java.patch new file mode 100644 index 000000000..455956957 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/gen/AbstractChunkGenerator.java.patch @@ -0,0 +1,10 @@ +--- a/net/minecraft/world/gen/AbstractChunkGenerator.java ++++ b/net/minecraft/world/gen/AbstractChunkGenerator.java +@@ -106,6 +106,7 @@ + } + + public void func_205471_a(IChunk p_205471_1_, Biome[] p_205471_2_, SharedSeedRandom p_205471_3_, int p_205471_4_) { ++ if (!net.minecraftforge.event.ForgeEventFactory.onReplaceBiomeBlocks(this, p_205471_1_, this.field_202095_a)) return; + double d0 = 0.03125D; + ChunkPos chunkpos = p_205471_1_.func_76632_l(); + int i = chunkpos.func_180334_c(); diff --git a/patches/minecraft/net/minecraft/world/gen/ChunkGeneratorEnd.java.patch b/patches/minecraft/net/minecraft/world/gen/ChunkGeneratorEnd.java.patch new file mode 100644 index 000000000..9a8699037 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/gen/ChunkGeneratorEnd.java.patch @@ -0,0 +1,43 @@ +--- a/net/minecraft/world/gen/ChunkGeneratorEnd.java ++++ b/net/minecraft/world/gen/ChunkGeneratorEnd.java +@@ -20,9 +20,9 @@ + private NoiseGeneratorOctaves field_185969_i; + private NoiseGeneratorOctaves field_185970_j; + private NoiseGeneratorOctaves field_185971_k; +- private final NoiseGeneratorOctaves field_73214_a; +- private final NoiseGeneratorOctaves field_73212_b; +- private final NoiseGeneratorPerlin field_205478_l; ++ private NoiseGeneratorOctaves field_73214_a; ++ private NoiseGeneratorOctaves field_73212_b; ++ private NoiseGeneratorPerlin field_205478_l; + private final BlockPos field_191061_n; + private final EndGenSettings field_202116_l; + private final IBlockState field_205479_o; +@@ -42,6 +42,16 @@ + this.field_73212_b = new NoiseGeneratorOctaves(sharedseedrandom, 16); + sharedseedrandom.func_202423_a(262); + this.field_205478_l = new NoiseGeneratorPerlin(new SharedSeedRandom(this.field_202096_b), 4); ++ ++ net.minecraftforge.event.terraingen.InitNoiseGensEvent.ContextEnd ctx = ++ new net.minecraftforge.event.terraingen.InitNoiseGensEvent.ContextEnd(field_185969_i, field_185970_j, field_185971_k, field_73214_a, field_73212_b, field_205478_l); ++ ctx = net.minecraftforge.event.terraingen.TerrainGen.getModdedNoiseGenerators(p_i48956_1_, sharedseedrandom, ctx); ++ this.field_185969_i = ctx.getLPerlin1(); ++ this.field_185970_j = ctx.getLPerlin2(); ++ this.field_185971_k = ctx.getPerlin(); ++ this.field_73214_a = ctx.getDepth(); ++ this.field_73212_b = ctx.getScale(); ++ this.field_205478_l = ctx.getIsland(); + } + + public void func_202114_a(int p_202114_1_, int p_202114_2_, IChunk p_202114_3_) { +@@ -121,6 +131,10 @@ + + private double[] func_202113_a(int p_202113_1_, int p_202113_2_, int p_202113_3_, int p_202113_4_, int p_202113_5_, int p_202113_6_) { + double[] adouble = new double[p_202113_4_ * p_202113_5_ * p_202113_6_]; ++ net.minecraftforge.event.terraingen.ChunkGeneratorEvent.InitNoiseField event = new net.minecraftforge.event.terraingen.ChunkGeneratorEvent.InitNoiseField(this, adouble, p_202113_1_, p_202113_2_, p_202113_3_, p_202113_4_, p_202113_5_, p_202113_6_); ++ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event); ++ if (event.getResult() == net.minecraftforge.eventbus.api.Event.Result.DENY) return event.getNoisefield(); ++ + double d0 = 684.412D; + double d1 = 684.412D; + d0 = d0 * 2.0D; diff --git a/patches/minecraft/net/minecraft/world/gen/ChunkGeneratorNether.java.patch b/patches/minecraft/net/minecraft/world/gen/ChunkGeneratorNether.java.patch new file mode 100644 index 000000000..f08f836e4 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/gen/ChunkGeneratorNether.java.patch @@ -0,0 +1,49 @@ +--- a/net/minecraft/world/gen/ChunkGeneratorNether.java ++++ b/net/minecraft/world/gen/ChunkGeneratorNether.java +@@ -20,12 +20,12 @@ + protected static final IBlockState field_185940_a = Blocks.field_150350_a.func_176223_P(); + protected static final IBlockState field_185941_b = Blocks.field_150424_aL.func_176223_P(); + protected static final IBlockState field_185943_d = Blocks.field_150353_l.func_176223_P(); +- private final NoiseGeneratorOctaves field_185957_u; +- private final NoiseGeneratorOctaves field_185958_v; +- private final NoiseGeneratorOctaves field_185959_w; +- private final NoiseGeneratorOctaves field_73177_m; +- private final NoiseGeneratorOctaves field_185946_g; +- private final NoiseGeneratorOctaves field_185947_h; ++ private NoiseGeneratorOctaves field_185957_u; ++ private NoiseGeneratorOctaves field_185958_v; ++ private NoiseGeneratorOctaves field_185959_w; ++ private NoiseGeneratorOctaves field_73177_m; ++ private NoiseGeneratorOctaves field_185946_g; ++ private NoiseGeneratorOctaves field_185947_h; + private final NetherGenSettings field_202107_q; + private final IBlockState field_205474_p; + private final IBlockState field_205604_n; +@@ -44,6 +44,16 @@ + this.field_185946_g = new NoiseGeneratorOctaves(sharedseedrandom, 10); + this.field_185947_h = new NoiseGeneratorOctaves(sharedseedrandom, 16); + p_i48694_1_.func_181544_b(63); ++ ++ net.minecraftforge.event.terraingen.InitNoiseGensEvent.ContextHell ctx = ++ new net.minecraftforge.event.terraingen.InitNoiseGensEvent.ContextHell(field_185957_u, field_185958_v, field_185959_w, field_73177_m, field_185946_g, field_185947_h); ++ ctx = net.minecraftforge.event.terraingen.TerrainGen.getModdedNoiseGenerators(p_i48694_1_, sharedseedrandom, ctx); ++ this.field_185957_u = ctx.getLPerlin1(); ++ this.field_185958_v = ctx.getLPerlin2(); ++ this.field_185959_w = ctx.getPerlin(); ++ this.field_73177_m = ctx.getPerlin2(); ++ this.field_185946_g = ctx.getScale(); ++ this.field_185947_h = ctx.getDepth(); + } + + public void func_185936_a(int p_185936_1_, int p_185936_2_, IChunk p_185936_3_) { +@@ -155,6 +165,10 @@ + + private double[] func_202104_a(int p_202104_1_, int p_202104_2_, int p_202104_3_, int p_202104_4_, int p_202104_5_, int p_202104_6_) { + double[] adouble = new double[p_202104_4_ * p_202104_5_ * p_202104_6_]; ++ net.minecraftforge.event.terraingen.ChunkGeneratorEvent.InitNoiseField event = new net.minecraftforge.event.terraingen.ChunkGeneratorEvent.InitNoiseField(this, adouble, p_202104_1_, p_202104_2_, p_202104_3_, p_202104_4_, p_202104_5_, p_202104_6_); ++ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event); ++ if (event.getResult() == net.minecraftforge.eventbus.api.Event.Result.DENY) return event.getNoisefield(); ++ + double d0 = 684.412D; + double d1 = 2053.236D; + this.field_185946_g.func_202647_a(p_202104_1_, p_202104_2_, p_202104_3_, p_202104_4_, 1, p_202104_6_, 1.0D, 0.0D, 1.0D); diff --git a/patches/minecraft/net/minecraft/world/gen/ChunkGeneratorOverworld.java.patch b/patches/minecraft/net/minecraft/world/gen/ChunkGeneratorOverworld.java.patch new file mode 100644 index 000000000..f5ed0a52a --- /dev/null +++ b/patches/minecraft/net/minecraft/world/gen/ChunkGeneratorOverworld.java.patch @@ -0,0 +1,30 @@ +--- a/net/minecraft/world/gen/ChunkGeneratorOverworld.java ++++ b/net/minecraft/world/gen/ChunkGeneratorOverworld.java +@@ -28,8 +28,8 @@ + private NoiseGeneratorOctaves field_185993_l; + private NoiseGeneratorPerlin field_185994_m; + private final OverworldGenSettings field_186000_s; +- private final NoiseGeneratorOctaves field_185983_b; +- private final NoiseGeneratorOctaves field_185984_c; ++ private NoiseGeneratorOctaves field_185983_b; ++ private NoiseGeneratorOctaves field_185984_c; + private final WorldType field_185997_p; + private final float[] field_185999_r; + private final PhantomSpawner field_203230_r = new PhantomSpawner(); +@@ -58,6 +58,16 @@ + this.field_186000_s = p_i48957_3_; + this.field_205475_r = this.field_186000_s.func_205532_l(); + this.field_205476_s = this.field_186000_s.func_205533_m(); ++ ++ net.minecraftforge.event.terraingen.InitNoiseGensEvent.ContextOverworld ctx = ++ new net.minecraftforge.event.terraingen.InitNoiseGensEvent.ContextOverworld(field_185991_j, field_185992_k, field_185993_l, field_185994_m, field_185983_b, field_185984_c); ++ ctx = net.minecraftforge.event.terraingen.TerrainGen.getModdedNoiseGenerators(p_i48957_1_, sharedseedrandom, ctx); ++ this.field_185991_j = ctx.getLPerlin1(); ++ this.field_185992_k = ctx.getLPerlin2(); ++ this.field_185993_l = ctx.getPerlin(); ++ this.field_185994_m = ctx.getHeight(); ++ this.field_185983_b = ctx.getScale(); ++ this.field_185984_c = ctx.getDepth(); + } + + public void func_202088_a(IChunk p_202088_1_) { diff --git a/patches/minecraft/net/minecraft/world/gen/feature/structure/StructurePiece.java.patch b/patches/minecraft/net/minecraft/world/gen/feature/structure/StructurePiece.java.patch new file mode 100644 index 000000000..299cef93f --- /dev/null +++ b/patches/minecraft/net/minecraft/world/gen/feature/structure/StructurePiece.java.patch @@ -0,0 +1,12 @@ +--- a/net/minecraft/world/gen/feature/structure/StructurePiece.java ++++ b/net/minecraft/world/gen/feature/structure/StructurePiece.java +@@ -48,6 +48,9 @@ + } + + public final NBTTagCompound func_143010_b() { ++ if (StructureIO.func_143036_a(this) == null) { // FORGE: Friendlier error then the Null String error below. ++ throw new RuntimeException("StructureComponent \"" + this.getClass().getName() + "\" missing ID Mapping, Modder see MapGenStructureIO"); ++ } + NBTTagCompound nbttagcompound = new NBTTagCompound(); + nbttagcompound.func_74778_a("id", StructureIO.func_143036_a(this)); + nbttagcompound.func_74782_a("BB", this.field_74887_e.func_151535_h()); diff --git a/patches/minecraft/net/minecraft/world/gen/feature/structure/StructureStart.java.patch b/patches/minecraft/net/minecraft/world/gen/feature/structure/StructureStart.java.patch new file mode 100644 index 000000000..bf4d58d91 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/gen/feature/structure/StructureStart.java.patch @@ -0,0 +1,22 @@ +--- a/net/minecraft/world/gen/feature/structure/StructureStart.java ++++ b/net/minecraft/world/gen/feature/structure/StructureStart.java +@@ -68,6 +68,9 @@ + } + + public NBTTagCompound func_143021_a(int p_143021_1_, int p_143021_2_) { ++ if (StructureIO.func_143033_a(this) == null) { // FORGE: This is just a more friendly error instead of the 'Null String' below ++ throw new RuntimeException("StructureStart \"" + this.getClass().getName() + "\" missing ID Mapping, Modder see MapGenStructureIO"); ++ } + NBTTagCompound nbttagcompound = new NBTTagCompound(); + if (this.func_75069_d()) { + nbttagcompound.func_74778_a("id", StructureIO.func_143033_a(this)); +@@ -105,7 +108,8 @@ + NBTTagList nbttaglist = p_143020_2_.func_150295_c("Children", 10); + + for(int i = 0; i < nbttaglist.size(); ++i) { +- this.field_75075_a.add(StructureIO.func_143032_b(nbttaglist.func_150305_b(i), p_143020_1_)); ++ StructurePiece tmp = StructureIO.func_143032_b(nbttaglist.func_150305_b(i), p_143020_1_); ++ if (tmp != null) this.field_75075_a.add(tmp); //Forge: Prevent NPEs further down the line when a componenet can't be loaded. + } + + this.func_143017_b(p_143020_2_); diff --git a/patches/minecraft/net/minecraft/world/gen/feature/structure/VillagePieces.java.patch b/patches/minecraft/net/minecraft/world/gen/feature/structure/VillagePieces.java.patch new file mode 100644 index 000000000..c070a4637 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/gen/feature/structure/VillagePieces.java.patch @@ -0,0 +1,101 @@ +--- a/net/minecraft/world/gen/feature/structure/VillagePieces.java ++++ b/net/minecraft/world/gen/feature/structure/VillagePieces.java +@@ -64,6 +64,7 @@ + list.add(new VillagePieces.PieceWeight(VillagePieces.Field2.class, 3, MathHelper.func_76136_a(p_75084_0_, 2 + p_75084_1_, 4 + p_75084_1_ * 2))); + list.add(new VillagePieces.PieceWeight(VillagePieces.House2.class, 15, MathHelper.func_76136_a(p_75084_0_, 0, 1 + p_75084_1_))); + list.add(new VillagePieces.PieceWeight(VillagePieces.House3.class, 8, MathHelper.func_76136_a(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()) { +@@ -111,6 +112,8 @@ + villagepieces$village = VillagePieces.House2.func_175855_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 if (oclass == VillagePieces.House3.class) { + villagepieces$village = VillagePieces.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 { ++ villagepieces$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 villagepieces$village; +@@ -1288,17 +1291,24 @@ + public List field_74931_h; + public List field_74932_i = Lists.newArrayList(); + public List field_74930_j = Lists.newArrayList(); ++ public @javax.annotation.Nullable net.minecraft.world.biome.Biome biome; + + public Start() { + } + + public Start(int p_i48769_1_, Random p_i48769_2_, int p_i48769_3_, int p_i48769_4_, List p_i48769_5_, VillageConfig p_i48769_6_) { ++ this(p_i48769_1_, p_i48769_2_, p_i48769_3_, p_i48769_4_, p_i48769_5_, p_i48769_6_, null); ++ } ++ ++ public Start(int p_i48769_1_, Random p_i48769_2_, int p_i48769_3_, int p_i48769_4_, List p_i48769_5_, VillageConfig p_i48769_6_, net.minecraft.world.biome.Biome biome) { + super((VillagePieces.Start)null, 0, p_i48769_2_, p_i48769_3_, p_i48769_4_); + this.field_74931_h = p_i48769_5_; + this.field_74928_c = p_i48769_6_.field_202461_a; + this.field_189928_h = p_i48769_6_.field_202462_b; + this.func_202579_a(this.field_189928_h); + this.field_189929_i = p_i48769_2_.nextInt(50) == 0; ++ this.biome = biome; ++ this.startPiece = this; + } + } + +@@ -1363,11 +1373,12 @@ + } + } + +- abstract static class Village extends StructurePiece { ++ public abstract static class Village extends StructurePiece { + protected int field_143015_k = -1; + private int field_74896_a; + protected VillagePieces.Type field_189928_h; + protected boolean field_189929_i; ++ protected VillagePieces.Start startPiece; + + public Village() { + } +@@ -1377,6 +1388,7 @@ + if (p_i2107_1_ != null) { + this.field_189928_h = p_i2107_1_.field_189928_h; + this.field_189929_i = p_i2107_1_.field_189929_i; ++ this.startPiece = p_i2107_1_; + } + + } +@@ -1480,13 +1492,12 @@ + EntityZombieVillager entityzombievillager = new EntityZombieVillager(p_74893_1_.func_201672_e()); + entityzombievillager.func_70012_b((double)j + 0.5D, (double)k, (double)l + 0.5D, 0.0F, 0.0F); + entityzombievillager.func_204210_a(p_74893_1_.func_175649_E(new BlockPos(entityzombievillager)), (IEntityLivingData)null, (NBTTagCompound)null); +- entityzombievillager.func_190733_a(this.func_180779_c(i, 0)); + entityzombievillager.func_110163_bv(); + p_74893_1_.func_72838_d(entityzombievillager); + } else { + EntityVillager entityvillager = new EntityVillager(p_74893_1_.func_201672_e()); + entityvillager.func_70012_b((double)j + 0.5D, (double)k, (double)l + 0.5D, 0.0F, 0.0F); +- entityvillager.func_70938_b(this.func_180779_c(i, p_74893_1_.func_201674_k().nextInt(6))); ++ entityvillager.setProfession(this.chooseForgeProfession(i, entityvillager.getProfessionForge())); + entityvillager.func_190672_a(p_74893_1_.func_175649_E(new BlockPos(entityvillager)), (IEntityLivingData)null, (NBTTagCompound)null, false); + p_74893_1_.func_72838_d(entityvillager); + } +@@ -1495,11 +1506,19 @@ + } + } + ++ @Deprecated // Use Forge version below + protected int func_180779_c(int p_180779_1_, int p_180779_2_) { + return p_180779_2_; + } ++ ++ protected net.minecraftforge.fml.common.registry.VillagerRegistry.VillagerProfession chooseForgeProfession(int count, net.minecraftforge.fml.common.registry.VillagerRegistry.VillagerProfession prof) { ++ return net.minecraftforge.fml.common.registry.VillagerRegistry.getById(func_180779_c(count, net.minecraftforge.fml.common.registry.VillagerRegistry.getId(prof))); ++ } + + 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.EVENT_BUS.post(event); ++ if (event.getResult() == net.minecraftforge.eventbus.api.Event.Result.DENY) return event.getReplacement(); + Block block = p_175847_1_.func_177230_c(); + if (this.field_189928_h == VillagePieces.Type.SANDSTONE) { + if (block.func_203417_a(BlockTags.field_200031_h) || block == Blocks.field_150347_e) { diff --git a/patches/minecraft/net/minecraft/world/gen/feature/structure/VillageStructure.java.patch b/patches/minecraft/net/minecraft/world/gen/feature/structure/VillageStructure.java.patch new file mode 100644 index 000000000..9c04beb37 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/gen/feature/structure/VillageStructure.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/gen/feature/structure/VillageStructure.java ++++ b/net/minecraft/world/gen/feature/structure/VillageStructure.java +@@ -67,7 +67,7 @@ + super(p_i48753_4_, p_i48753_5_, p_i48753_6_, p_i48753_3_, p_i48753_1_.func_72905_C()); + VillageConfig villageconfig = (VillageConfig)p_i48753_2_.func_202087_b(p_i48753_6_, Feature.field_202328_f); + List list = VillagePieces.func_75084_a(p_i48753_3_, villageconfig.field_202461_a); +- VillagePieces.Start villagepieces$start = new VillagePieces.Start(0, p_i48753_3_, (p_i48753_4_ << 4) + 2, (p_i48753_5_ << 4) + 2, list, villageconfig); ++ VillagePieces.Start villagepieces$start = new VillagePieces.Start(0, p_i48753_3_, (p_i48753_4_ << 4) + 2, (p_i48753_5_ << 4) + 2, list, villageconfig, p_i48753_6_); + this.field_75075_a.add(villagepieces$start); + villagepieces$start.func_74861_a(villagepieces$start, this.field_75075_a, p_i48753_3_); + List list1 = villagepieces$start.field_74930_j; diff --git a/patches/minecraft/net/minecraft/world/gen/feature/template/Template.java.patch b/patches/minecraft/net/minecraft/world/gen/feature/template/Template.java.patch new file mode 100644 index 000000000..613945576 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/gen/feature/template/Template.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/gen/feature/template/Template.java ++++ b/net/minecraft/world/gen/feature/template/Template.java +@@ -185,6 +185,8 @@ + + for(Template.BlockInfo template$blockinfo : list) { + BlockPos blockpos = func_186266_a(p_189960_4_, template$blockinfo.field_186242_a).func_177971_a(p_189960_2_); ++ // Forge: skip processing blocks outside BB to prevent cascading worldgen issues ++ if (mutableboundingbox != null && !mutableboundingbox.func_175898_b(blockpos)) continue; + Template.BlockInfo template$blockinfo1 = p_189960_3_ != null ? p_189960_3_.func_189943_a(p_189960_1_, blockpos, template$blockinfo) : template$blockinfo; + if (template$blockinfo1 != null) { + Block block1 = template$blockinfo1.field_186243_b.func_177230_c(); 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 000000000..f360db959 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/gen/layer/GenLayerBiome.java.patch @@ -0,0 +1,85 @@ +--- a/net/minecraft/world/gen/layer/GenLayerBiome.java ++++ b/net/minecraft/world/gen/layer/GenLayerBiome.java +@@ -24,18 +24,36 @@ + private static final int field_202740_n = Biome.func_185362_a(Biomes.field_76780_h); + private static final int field_202741_o = Biome.func_185362_a(Biomes.field_76768_g); + private static final int field_202742_p = Biome.func_185362_a(Biomes.field_150584_S); +- private static final int[] field_202743_q = new int[]{field_202728_b, field_202730_d, field_202729_c, field_202740_n, field_202736_j, field_202741_o}; +- private static final int[] field_202744_r = new int[]{field_202728_b, field_202728_b, field_202728_b, field_202739_m, field_202739_m, field_202736_j}; +- private static final int[] field_202745_s = new int[]{field_202730_d, field_202738_l, field_202729_c, field_202736_j, field_202727_a, field_202740_n}; +- private static final int[] field_202746_t = new int[]{field_202730_d, field_202729_c, field_202741_o, field_202736_j}; +- private static final int[] field_202747_u = new int[]{field_202731_e, field_202731_e, field_202731_e, field_202742_p}; ++ ++ @SuppressWarnings("unchecked") ++ private java.util.List[] biomes = new java.util.ArrayList[net.minecraftforge.common.BiomeManager.BiomeType.values().length]; ++ + private final OverworldGenSettings field_175973_g; +- private int[] field_151623_c; + + public GenLayerBiome(WorldType p_i48641_1_, OverworldGenSettings p_i48641_2_) { +- this.field_151623_c = field_202744_r; ++ 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(Biomes.field_76769_d, 30)); ++ biomes[desertIdx].add(new net.minecraftforge.common.BiomeManager.BiomeEntry(Biomes.field_150588_X, 20)); ++ biomes[desertIdx].add(new net.minecraftforge.common.BiomeManager.BiomeEntry(Biomes.field_76772_c, 10)); ++ + if (p_i48641_1_ == WorldType.field_77136_e) { +- this.field_151623_c = field_202743_q; ++ biomes[desertIdx].clear(); ++ biomes[desertIdx].add(new net.minecraftforge.common.BiomeManager.BiomeEntry(Biomes.field_76769_d, 10)); ++ biomes[desertIdx].add(new net.minecraftforge.common.BiomeManager.BiomeEntry(Biomes.field_76767_f, 10)); ++ biomes[desertIdx].add(new net.minecraftforge.common.BiomeManager.BiomeEntry(Biomes.field_76770_e, 10)); ++ biomes[desertIdx].add(new net.minecraftforge.common.BiomeManager.BiomeEntry(Biomes.field_76780_h, 10)); ++ biomes[desertIdx].add(new net.minecraftforge.common.BiomeManager.BiomeEntry(Biomes.field_76772_c, 10)); ++ biomes[desertIdx].add(new net.minecraftforge.common.BiomeManager.BiomeEntry(Biomes.field_76768_g, 10)); + this.field_175973_g = null; + } else { + this.field_175973_g = p_i48641_2_; +@@ -56,21 +74,21 @@ + return p_202726_1_.func_202696_a(3) == 0 ? field_202733_g : field_202734_h; + } + +- return this.field_151623_c[p_202726_1_.func_202696_a(this.field_151623_c.length)]; ++ return Biome.func_185362_a(getWeightedBiomeEntry(net.minecraftforge.common.BiomeManager.BiomeType.DESERT, p_202726_1_).biome); + case 2: + if (i > 0) { + return field_202732_f; + } + +- return field_202745_s[p_202726_1_.func_202696_a(field_202745_s.length)]; ++ return Biome.func_185362_a(getWeightedBiomeEntry(net.minecraftforge.common.BiomeManager.BiomeType.WARM, p_202726_1_).biome); + case 3: + if (i > 0) { + return field_202737_k; + } + +- return field_202746_t[p_202726_1_.func_202696_a(field_202746_t.length)]; ++ return Biome.func_185362_a(getWeightedBiomeEntry(net.minecraftforge.common.BiomeManager.BiomeType.COOL, p_202726_1_).biome); + case 4: +- return field_202747_u[p_202726_1_.func_202696_a(field_202747_u.length)]; ++ return Biome.func_185362_a(getWeightedBiomeEntry(net.minecraftforge.common.BiomeManager.BiomeType.ICY, p_202726_1_).biome); + default: + return field_202735_i; + } +@@ -79,4 +97,11 @@ + } + } + } ++ ++ protected net.minecraftforge.common.BiomeManager.BiomeEntry getWeightedBiomeEntry(net.minecraftforge.common.BiomeManager.BiomeType type, IContext context) { ++ java.util.List biomeList = biomes[type.ordinal()]; ++ int totalWeight = net.minecraft.util.WeightedRandom.func_76272_a(biomeList); ++ int weight = net.minecraftforge.common.BiomeManager.isTypeListModded(type)?context.func_202696_a(totalWeight):context.func_202696_a(totalWeight / 10) * 10; ++ return (net.minecraftforge.common.BiomeManager.BiomeEntry)net.minecraft.util.WeightedRandom.func_180166_a(biomeList, weight); ++ } + } diff --git a/patches/minecraft/net/minecraft/world/gen/layer/LayerUtil.java.patch b/patches/minecraft/net/minecraft/world/gen/layer/LayerUtil.java.patch new file mode 100644 index 000000000..0738dff08 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/gen/layer/LayerUtil.java.patch @@ -0,0 +1,34 @@ +--- a/net/minecraft/world/gen/layer/LayerUtil.java ++++ b/net/minecraft/world/gen/layer/LayerUtil.java +@@ -67,12 +67,12 @@ + if (p_202828_0_ == WorldType.field_77135_d) { + i = 6; + } ++ ++ i = getModdedBiomeSize(p_202828_0_, i); + + IAreaFactory lvt_7_1_ = func_202829_a(1000L, GenLayerZoom.NORMAL, iareafactory, 0, p_202828_2_); + lvt_7_1_ = GenLayerRiverInit.INSTANCE.func_202713_a((IContextExtended)p_202828_2_.apply(100L), lvt_7_1_); +- IAreaFactory lvt_8_1_ = (new GenLayerBiome(p_202828_0_, p_202828_1_)).func_202713_a((IContextExtended)p_202828_2_.apply(200L), iareafactory); +- lvt_8_1_ = func_202829_a(1000L, GenLayerZoom.NORMAL, lvt_8_1_, 2, p_202828_2_); +- lvt_8_1_ = GenLayerBiomeEdge.INSTANCE.func_202713_a((IContextExtended)p_202828_2_.apply(1000L), lvt_8_1_); ++ IAreaFactory lvt_8_1_ = p_202828_0_.getBiomeLayer(iareafactory, p_202828_1_, p_202828_2_); + IAreaFactory lvt_9_1_ = func_202829_a(1000L, GenLayerZoom.NORMAL, lvt_7_1_, 2, p_202828_2_); + lvt_8_1_ = GenLayerHills.INSTANCE.func_202707_a((IContextExtended)p_202828_2_.apply(1000L), lvt_8_1_, lvt_9_1_); + lvt_7_1_ = func_202829_a(1000L, GenLayerZoom.NORMAL, lvt_7_1_, 2, p_202828_2_); +@@ -133,6 +133,15 @@ + } + } + } ++ ++ /* ======================================== FORGE START =====================================*/ ++ public static int getModdedBiomeSize(net.minecraft.world.WorldType worldType, int original) ++ { ++ net.minecraftforge.event.terraingen.WorldTypeEvent.BiomeSize event = new net.minecraftforge.event.terraingen.WorldTypeEvent.BiomeSize(worldType, original); ++ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event); ++ return event.getNewSize(); ++ } ++ /* ========================================= FORGE END ======================================*/ + + protected static boolean func_202827_a(int p_202827_0_) { + return p_202827_0_ == field_203632_a || p_202827_0_ == field_203633_b || p_202827_0_ == field_202832_c || p_202827_0_ == field_203634_d || p_202827_0_ == field_202831_b || p_202827_0_ == field_203635_f || p_202827_0_ == field_203636_g || p_202827_0_ == field_202830_a || p_202827_0_ == field_203637_i || p_202827_0_ == field_203638_j; diff --git a/patches_old/minecraft/net/minecraft/world/WorldProvider.java.patch b/patches_old/minecraft/net/minecraft/world/WorldProvider.java.patch index 8ffa18bca..3e1699e05 100644 --- a/patches_old/minecraft/net/minecraft/world/WorldProvider.java.patch +++ b/patches_old/minecraft/net/minecraft/world/WorldProvider.java.patch @@ -40,15 +40,6 @@ } public boolean func_76566_a(int p_76566_1_, int p_76566_2_) -@@ -179,7 +154,7 @@ - @SideOnly(Side.CLIENT) - public float func_76571_f() - { -- return 128.0F; -+ return this.field_76577_b.getCloudHeight(); - } - - @SideOnly(Side.CLIENT) @@ -196,13 +171,13 @@ public int func_76557_i() @@ -56,84 +47,11 @@ - return this.field_76577_b == WorldType.field_77138_c ? 4 : this.field_76579_a.func_181545_F() + 1; + return this.field_76577_b.getMinimumSpawnHeight(this.field_76579_a); } - - @SideOnly(Side.CLIENT) - public double func_76565_k() - { -- return this.field_76577_b == WorldType.field_77138_c ? 1.0D : 0.03125D; -+ return this.field_76577_b.voidFadeMagnitude(); - } - - @SideOnly(Side.CLIENT) @@ -241,6 +216,371 @@ return new WorldBorder(); } + /*======================================= Forge Start =========================================*/ -+ /** -+ * Returns the sub-folder of the world folder that this WorldProvider saves to. -+ * EXA: DIM1, DIM-1 -+ * @return The sub-folder name to save this world's chunks to. -+ */ -+ @Nullable -+ public String getSaveFolder() -+ { -+ return (dimensionId == 0 ? null : "DIM" + dimensionId); -+ } -+ -+ /** -+ * If this method returns true, then chunks received by the client will -+ * have {@link net.minecraft.world.chunk.Chunk#resetRelightChecks} called -+ * on them, queuing lighting checks for all air blocks in the chunk (and -+ * any adjacent light-emitting blocks). -+ * -+ * Returning true here is recommended if the chunk generator used also -+ * does this for newly generated chunks. -+ * -+ * @return true if lighting checks should be performed -+ */ -+ public boolean shouldClientCheckLighting() -+ { -+ return !(this instanceof WorldProviderSurface); -+ } -+ -+ -+ /** -+ * Allows for manipulating the coloring of the lightmap texture. -+ * Will be called for each 16*16 combination of sky/block light values. -+ * -+ * @param partialTicks Progress between ticks. -+ * @param sunBrightness Current sun brightness. -+ * @param skyLight Sky light brightness factor. -+ * @param blockLight Block light brightness factor. -+ * @param colors The color values that will be used: [r, g, b]. -+ * -+ * @see net.minecraft.client.renderer.EntityRenderer#updateLightmap(float) -+ */ -+ public void getLightmapColors(float partialTicks, float sunBrightness, float skyLight, float blockLight, float[] colors) {} -+ -+ /** -+ * Determines the dimension the player will be respawned in, typically this brings them back to the overworld. -+ * -+ * @param player The player that is respawning -+ * @return The dimension to respawn the player in -+ */ -+ public int getRespawnDimension(net.minecraft.entity.player.EntityPlayerMP player) -+ { -+ return player.getSpawnDimension(); -+ } -+ -+ /** -+ * Determines if the player can sleep in this world (or if the bed should explode for example). -+ * -+ * @param player The player that is attempting to sleep -+ * @param pos The location where the player tries to sleep at (the position of the clicked on bed for example) -+ * @return the result of a player trying to sleep at the given location -+ */ -+ public WorldSleepResult canSleepAt(net.minecraft.entity.player.EntityPlayer player, BlockPos pos) -+ { -+ return (this.func_76567_e() && this.field_76579_a.func_180494_b(pos) != net.minecraft.init.Biomes.field_76778_j) ? WorldSleepResult.ALLOW : WorldSleepResult.BED_EXPLODES; -+ } + public boolean canBlockFreeze(BlockPos pos, boolean byWater) + { + return field_76579_a.canBlockFreezeBody(pos, byWater); @@ -143,24 +61,6 @@ + { + return field_76579_a.canSnowAtBody(pos, checkLight); + } -+ -+ public void resetRainAndThunder() -+ { -+ field_76579_a.field_72986_A.func_76080_g(0); -+ field_76579_a.field_72986_A.func_76084_b(false); -+ field_76579_a.field_72986_A.func_76090_f(0); -+ field_76579_a.field_72986_A.func_76069_a(false); -+ } -+ -+ public boolean canDoLightning(net.minecraft.world.chunk.Chunk chunk) -+ { -+ return true; -+ } -+ -+ public boolean canDoRainSnowIce(net.minecraft.world.chunk.Chunk chunk) -+ { -+ return true; -+ } + public void func_186061_a(EntityPlayerMP p_186061_1_) { diff --git a/patches_old/minecraft/net/minecraft/world/gen/ChunkGeneratorEnd.java.patch b/patches_old/minecraft/net/minecraft/world/gen/ChunkGeneratorEnd.java.patch deleted file mode 100644 index 0a8b5667b..000000000 --- a/patches_old/minecraft/net/minecraft/world/gen/ChunkGeneratorEnd.java.patch +++ /dev/null @@ -1,73 +0,0 @@ ---- ../src-base/minecraft/net/minecraft/world/gen/ChunkGeneratorEnd.java -+++ ../src-work/minecraft/net/minecraft/world/gen/ChunkGeneratorEnd.java -@@ -43,6 +43,9 @@ - double[] field_185967_f; - double[] field_185968_g; - private final WorldGenEndIsland field_185975_r = new WorldGenEndIsland(); -+ // temporary variables used during event handling -+ private int chunkX = 0; -+ private int chunkZ = 0; - - public ChunkGeneratorEnd(World p_i47241_1_, boolean p_i47241_2_, long p_i47241_3_, BlockPos p_i47241_5_) - { -@@ -56,6 +59,17 @@ - this.field_73214_a = new NoiseGeneratorOctaves(this.field_73220_k, 10); - this.field_73212_b = new NoiseGeneratorOctaves(this.field_73220_k, 16); - this.field_185973_o = new NoiseGeneratorSimplex(this.field_73220_k); -+ -+ net.minecraftforge.event.terraingen.InitNoiseGensEvent.ContextEnd ctx = -+ new net.minecraftforge.event.terraingen.InitNoiseGensEvent.ContextEnd(field_185969_i, field_185970_j, field_185971_k, field_73214_a, field_73212_b, field_185973_o); -+ ctx = net.minecraftforge.event.terraingen.TerrainGen.getModdedNoiseGenerators(p_i47241_1_, this.field_73220_k, ctx); -+ this.field_185969_i = ctx.getLPerlin1(); -+ this.field_185970_j = ctx.getLPerlin2(); -+ this.field_185971_k = ctx.getPerlin(); -+ this.field_73214_a = ctx.getDepth(); -+ this.field_73212_b = ctx.getScale(); -+ this.field_185973_o = ctx.getIsland(); -+ this.field_185972_n = (MapGenEndCity) net.minecraftforge.event.terraingen.TerrainGen.getModdedMapGen(this.field_185972_n, net.minecraftforge.event.terraingen.InitMapGenEvent.EventType.END_CITY); - } - - public void func_180518_a(int p_180518_1_, int p_180518_2_, ChunkPrimer p_180518_3_) -@@ -128,6 +142,7 @@ - - public void func_185962_a(ChunkPrimer p_185962_1_) - { -+ if (!net.minecraftforge.event.ForgeEventFactory.onReplaceBiomeBlocks(this, this.chunkX, this.chunkZ, p_185962_1_, this.field_73230_p)) return; - for (int i = 0; i < 16; ++i) - { - for (int j = 0; j < 16; ++j) -@@ -173,6 +188,7 @@ - - public Chunk func_185932_a(int p_185932_1_, int p_185932_2_) - { -+ this.chunkX = p_185932_1_; this.chunkZ = p_185932_2_; - this.field_73220_k.setSeed((long)p_185932_1_ * 341873128712L + (long)p_185932_2_ * 132897987541L); - ChunkPrimer chunkprimer = new ChunkPrimer(); - this.field_73231_z = this.field_73230_p.func_72959_q().func_76933_b(this.field_73231_z, p_185932_1_ * 16, p_185932_2_ * 16, 16, 16); -@@ -254,6 +270,10 @@ - - private double[] func_185963_a(double[] p_185963_1_, int p_185963_2_, int p_185963_3_, int p_185963_4_, int p_185963_5_, int p_185963_6_, int p_185963_7_) - { -+ net.minecraftforge.event.terraingen.ChunkGeneratorEvent.InitNoiseField event = new net.minecraftforge.event.terraingen.ChunkGeneratorEvent.InitNoiseField(this, p_185963_1_, p_185963_2_, p_185963_3_, p_185963_4_, p_185963_5_, p_185963_6_, p_185963_7_); -+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event); -+ if (event.getResult() == net.minecraftforge.fml.common.eventhandler.Event.Result.DENY) return event.getNoisefield(); -+ - if (p_185963_1_ == null) - { - p_185963_1_ = new double[p_185963_5_ * p_185963_6_ * p_185963_7_]; -@@ -326,6 +346,7 @@ - public void func_185931_b(int p_185931_1_, int p_185931_2_) - { - BlockFalling.field_149832_M = true; -+ net.minecraftforge.event.ForgeEventFactory.onChunkPopulate(true, this, this.field_73230_p, this.field_73220_k, p_185931_1_, p_185931_2_, false); - BlockPos blockpos = new BlockPos(p_185931_1_ * 16, 0, p_185931_2_ * 16); - - if (this.field_73229_q) -@@ -394,6 +415,7 @@ - } - } - -+ net.minecraftforge.event.ForgeEventFactory.onChunkPopulate(false, this, this.field_73230_p, this.field_73220_k, p_185931_1_, p_185931_2_, false); - BlockFalling.field_149832_M = false; - } - diff --git a/patches_old/minecraft/net/minecraft/world/gen/ChunkGeneratorFlat.java.patch b/patches_old/minecraft/net/minecraft/world/gen/ChunkGeneratorFlat.java.patch deleted file mode 100644 index 1592b257a..000000000 --- a/patches_old/minecraft/net/minecraft/world/gen/ChunkGeneratorFlat.java.patch +++ /dev/null @@ -1,29 +0,0 @@ ---- ../src-base/minecraft/net/minecraft/world/gen/ChunkGeneratorFlat.java -+++ ../src-work/minecraft/net/minecraft/world/gen/ChunkGeneratorFlat.java -@@ -162,6 +162,7 @@ - - public void func_185931_b(int p_185931_1_, int p_185931_2_) - { -+ net.minecraft.block.BlockFalling.field_149832_M = true; - int i = p_185931_1_ * 16; - int j = p_185931_2_ * 16; - BlockPos blockpos = new BlockPos(i, 0, j); -@@ -173,6 +174,8 @@ - this.field_73161_b.setSeed((long)p_185931_1_ * k + (long)p_185931_2_ * l ^ this.field_73163_a.func_72905_C()); - ChunkPos chunkpos = new ChunkPos(p_185931_1_, p_185931_2_); - -+ net.minecraftforge.event.ForgeEventFactory.onChunkPopulate(true, this, this.field_73163_a, this.field_73161_b, p_185931_1_, p_185931_2_, flag); -+ - for (MapGenStructure mapgenstructure : this.field_82696_f.values()) - { - boolean flag1 = mapgenstructure.func_175794_a(this.field_73163_a, this.field_73161_b, chunkpos); -@@ -210,6 +213,9 @@ - { - biome.func_180624_a(this.field_73163_a, this.field_73161_b, blockpos); - } -+ -+ net.minecraftforge.event.ForgeEventFactory.onChunkPopulate(false, this, this.field_73163_a, this.field_73161_b, p_185931_1_, p_185931_2_, flag); -+ net.minecraft.block.BlockFalling.field_149832_M = false; - } - - public boolean func_185933_a(Chunk p_185933_1_, int p_185933_2_, int p_185933_3_) diff --git a/patches_old/minecraft/net/minecraft/world/gen/ChunkGeneratorHell.java.patch b/patches_old/minecraft/net/minecraft/world/gen/ChunkGeneratorHell.java.patch deleted file mode 100644 index a62ecec31..000000000 --- a/patches_old/minecraft/net/minecraft/world/gen/ChunkGeneratorHell.java.patch +++ /dev/null @@ -1,120 +0,0 @@ ---- ../src-base/minecraft/net/minecraft/world/gen/ChunkGeneratorHell.java -+++ ../src-work/minecraft/net/minecraft/world/gen/ChunkGeneratorHell.java -@@ -77,6 +77,19 @@ - this.field_185946_g = new NoiseGeneratorOctaves(this.field_185954_p, 10); - this.field_185947_h = new NoiseGeneratorOctaves(this.field_185954_p, 16); - p_i45637_1_.func_181544_b(63); -+ -+ net.minecraftforge.event.terraingen.InitNoiseGensEvent.ContextHell ctx = -+ new net.minecraftforge.event.terraingen.InitNoiseGensEvent.ContextHell(field_185957_u, field_185958_v, field_185959_w, field_73177_m, field_73174_n, field_185946_g, field_185947_h); -+ ctx = net.minecraftforge.event.terraingen.TerrainGen.getModdedNoiseGenerators(p_i45637_1_, this.field_185954_p, ctx); -+ this.field_185957_u = ctx.getLPerlin1(); -+ this.field_185958_v = ctx.getLPerlin2(); -+ this.field_185959_w = ctx.getPerlin(); -+ this.field_73177_m = ctx.getPerlin2(); -+ this.field_73174_n = ctx.getPerlin3(); -+ this.field_185946_g = ctx.getScale(); -+ this.field_185947_h = ctx.getDepth(); -+ this.field_73172_c = (MapGenNetherBridge)net.minecraftforge.event.terraingen.TerrainGen.getModdedMapGen(field_73172_c, net.minecraftforge.event.terraingen.InitMapGenEvent.EventType.NETHER_BRIDGE); -+ this.field_185939_I = net.minecraftforge.event.terraingen.TerrainGen.getModdedMapGen(field_185939_I, net.minecraftforge.event.terraingen.InitMapGenEvent.EventType.NETHER_CAVE); - } - - public void func_185936_a(int p_185936_1_, int p_185936_2_, ChunkPrimer p_185936_3_) -@@ -155,6 +168,7 @@ - - public void func_185937_b(int p_185937_1_, int p_185937_2_, ChunkPrimer p_185937_3_) - { -+ if (!net.minecraftforge.event.ForgeEventFactory.onReplaceBiomeBlocks(this, p_185937_1_, p_185937_2_, p_185937_3_, this.field_185952_n)) return; - int i = this.field_185952_n.func_181545_F() + 1; - double d0 = 0.03125D; - this.field_73185_q = this.field_73177_m.func_76304_a(this.field_73185_q, p_185937_1_ * 16, p_185937_2_ * 16, 0, 16, 16, 1, 0.03125D, 0.03125D, 1.0D); -@@ -277,6 +291,10 @@ - p_185938_1_ = new double[p_185938_5_ * p_185938_6_ * p_185938_7_]; - } - -+ net.minecraftforge.event.terraingen.ChunkGeneratorEvent.InitNoiseField event = new net.minecraftforge.event.terraingen.ChunkGeneratorEvent.InitNoiseField(this, p_185938_1_, p_185938_2_, p_185938_3_, p_185938_4_, p_185938_5_, p_185938_6_, p_185938_7_); -+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event); -+ if (event.getResult() == net.minecraftforge.fml.common.eventhandler.Event.Result.DENY) return event.getNoisefield(); -+ - double d0 = 684.412D; - double d1 = 2053.236D; - this.field_73168_g = this.field_185946_g.func_76304_a(this.field_73168_g, p_185938_2_, p_185938_3_, p_185938_4_, p_185938_5_, 1, p_185938_7_, 1.0D, 0.0D, 1.0D); -@@ -358,6 +376,7 @@ - public void func_185931_b(int p_185931_1_, int p_185931_2_) - { - BlockFalling.field_149832_M = true; -+ net.minecraftforge.event.ForgeEventFactory.onChunkPopulate(true, this, this.field_185952_n, this.field_185954_p, p_185931_1_, p_185931_2_, false); - int i = p_185931_1_ * 16; - int j = p_185931_2_ * 16; - BlockPos blockpos = new BlockPos(i, 0, j); -@@ -365,16 +384,20 @@ - ChunkPos chunkpos = new ChunkPos(p_185931_1_, p_185931_2_); - this.field_73172_c.func_175794_a(this.field_185952_n, this.field_185954_p, chunkpos); - -+ if (net.minecraftforge.event.terraingen.TerrainGen.populate(this, this.field_185952_n, this.field_185954_p, p_185931_1_, p_185931_2_, false, net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType.NETHER_LAVA)) - for (int k = 0; k < 8; ++k) - { - this.field_177472_y.func_180709_b(this.field_185952_n, this.field_185954_p, blockpos.func_177982_a(this.field_185954_p.nextInt(16) + 8, this.field_185954_p.nextInt(120) + 4, this.field_185954_p.nextInt(16) + 8)); - } - -+ if (net.minecraftforge.event.terraingen.TerrainGen.populate(this, this.field_185952_n, this.field_185954_p, p_185931_1_, p_185931_2_, false, net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType.FIRE)) - for (int i1 = 0; i1 < this.field_185954_p.nextInt(this.field_185954_p.nextInt(10) + 1) + 1; ++i1) - { - this.field_177470_t.func_180709_b(this.field_185952_n, this.field_185954_p, blockpos.func_177982_a(this.field_185954_p.nextInt(16) + 8, this.field_185954_p.nextInt(120) + 4, this.field_185954_p.nextInt(16) + 8)); - } - -+ if (net.minecraftforge.event.terraingen.TerrainGen.populate(this, this.field_185952_n, this.field_185954_p, p_185931_1_, p_185931_2_, false, net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType.GLOWSTONE)) -+ { - for (int j1 = 0; j1 < this.field_185954_p.nextInt(this.field_185954_p.nextInt(10) + 1); ++j1) - { - this.field_177469_u.func_180709_b(this.field_185952_n, this.field_185954_p, blockpos.func_177982_a(this.field_185954_p.nextInt(16) + 8, this.field_185954_p.nextInt(120) + 4, this.field_185954_p.nextInt(16) + 8)); -@@ -384,7 +407,13 @@ - { - this.field_177468_v.func_180709_b(this.field_185952_n, this.field_185954_p, blockpos.func_177982_a(this.field_185954_p.nextInt(16) + 8, this.field_185954_p.nextInt(128), this.field_185954_p.nextInt(16) + 8)); - } -+ }//Forge: End doGLowstone - -+ net.minecraftforge.event.ForgeEventFactory.onChunkPopulate(false, this, this.field_185952_n, this.field_185954_p, p_185931_1_, p_185931_2_, false); -+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.terraingen.DecorateBiomeEvent.Pre(this.field_185952_n, this.field_185954_p, chunkpos)); -+ -+ if (net.minecraftforge.event.terraingen.TerrainGen.decorate(this.field_185952_n, this.field_185954_p, chunkpos, net.minecraftforge.event.terraingen.DecorateBiomeEvent.Decorate.EventType.SHROOM)) -+ { - if (this.field_185954_p.nextBoolean()) - { - this.field_177471_z.func_180709_b(this.field_185952_n, this.field_185954_p, blockpos.func_177982_a(this.field_185954_p.nextInt(16) + 8, this.field_185954_p.nextInt(128), this.field_185954_p.nextInt(16) + 8)); -@@ -394,7 +423,10 @@ - { - this.field_177465_A.func_180709_b(this.field_185952_n, this.field_185954_p, blockpos.func_177982_a(this.field_185954_p.nextInt(16) + 8, this.field_185954_p.nextInt(128), this.field_185954_p.nextInt(16) + 8)); - } -+ } - -+ -+ if (net.minecraftforge.event.terraingen.TerrainGen.generateOre(this.field_185952_n, this.field_185954_p, field_177467_w, blockpos, net.minecraftforge.event.terraingen.OreGenEvent.GenerateMinable.EventType.QUARTZ)) - for (int l1 = 0; l1 < 16; ++l1) - { - this.field_177467_w.func_180709_b(this.field_185952_n, this.field_185954_p, blockpos.func_177982_a(this.field_185954_p.nextInt(16), this.field_185954_p.nextInt(108) + 10, this.field_185954_p.nextInt(16))); -@@ -402,17 +434,23 @@ - - int i2 = this.field_185952_n.func_181545_F() / 2 + 1; - -+ if (net.minecraftforge.event.terraingen.TerrainGen.populate(this, this.field_185952_n, this.field_185954_p, p_185931_1_, p_185931_2_, false, net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType.NETHER_MAGMA)) - for (int l = 0; l < 4; ++l) - { - this.field_189888_D.func_180709_b(this.field_185952_n, this.field_185954_p, blockpos.func_177982_a(this.field_185954_p.nextInt(16), i2 - 5 + this.field_185954_p.nextInt(10), this.field_185954_p.nextInt(16))); - } - -+ if (net.minecraftforge.event.terraingen.TerrainGen.populate(this, this.field_185952_n, this.field_185954_p, p_185931_1_, p_185931_2_, false, net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType.NETHER_LAVA2)) - for (int j2 = 0; j2 < 16; ++j2) - { -- this.field_177473_x.func_180709_b(this.field_185952_n, this.field_185954_p, blockpos.func_177982_a(this.field_185954_p.nextInt(16), this.field_185954_p.nextInt(108) + 10, this.field_185954_p.nextInt(16))); -+ int offset = net.minecraftforge.common.ForgeModContainer.fixVanillaCascading ? 8 : 0; // MC-117810 -+ this.field_177473_x.func_180709_b(this.field_185952_n, this.field_185954_p, blockpos.func_177982_a(this.field_185954_p.nextInt(16) + offset, this.field_185954_p.nextInt(108) + 10, this.field_185954_p.nextInt(16) + offset)); - } - - biome.func_180624_a(this.field_185952_n, this.field_185954_p, new BlockPos(i, 0, j)); -+ -+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.terraingen.DecorateBiomeEvent.Post(this.field_185952_n, this.field_185954_p, blockpos)); -+ - BlockFalling.field_149832_M = false; - } - diff --git a/patches_old/minecraft/net/minecraft/world/gen/ChunkGeneratorOverworld.java.patch b/patches_old/minecraft/net/minecraft/world/gen/ChunkGeneratorOverworld.java.patch deleted file mode 100644 index 49424b6a3..000000000 --- a/patches_old/minecraft/net/minecraft/world/gen/ChunkGeneratorOverworld.java.patch +++ /dev/null @@ -1,102 +0,0 @@ ---- ../src-base/minecraft/net/minecraft/world/gen/ChunkGeneratorOverworld.java -+++ ../src-work/minecraft/net/minecraft/world/gen/ChunkGeneratorOverworld.java -@@ -61,6 +61,16 @@ - - public ChunkGeneratorOverworld(World p_i46668_1_, long p_i46668_2_, boolean p_i46668_4_, String p_i46668_5_) - { -+ { -+ field_186003_v = net.minecraftforge.event.terraingen.TerrainGen.getModdedMapGen(field_186003_v, net.minecraftforge.event.terraingen.InitMapGenEvent.EventType.CAVE); -+ field_186004_w = (MapGenStronghold)net.minecraftforge.event.terraingen.TerrainGen.getModdedMapGen(field_186004_w, net.minecraftforge.event.terraingen.InitMapGenEvent.EventType.STRONGHOLD); -+ field_186005_x = (MapGenVillage)net.minecraftforge.event.terraingen.TerrainGen.getModdedMapGen(field_186005_x, net.minecraftforge.event.terraingen.InitMapGenEvent.EventType.VILLAGE); -+ field_186006_y = (MapGenMineshaft)net.minecraftforge.event.terraingen.TerrainGen.getModdedMapGen(field_186006_y, net.minecraftforge.event.terraingen.InitMapGenEvent.EventType.MINESHAFT); -+ field_186007_z = (MapGenScatteredFeature)net.minecraftforge.event.terraingen.TerrainGen.getModdedMapGen(field_186007_z, net.minecraftforge.event.terraingen.InitMapGenEvent.EventType.SCATTERED_FEATURE); -+ field_185979_A = net.minecraftforge.event.terraingen.TerrainGen.getModdedMapGen(field_185979_A, net.minecraftforge.event.terraingen.InitMapGenEvent.EventType.RAVINE); -+ field_185980_B = (StructureOceanMonument)net.minecraftforge.event.terraingen.TerrainGen.getModdedMapGen(field_185980_B, net.minecraftforge.event.terraingen.InitMapGenEvent.EventType.OCEAN_MONUMENT); -+ field_191060_C = (WoodlandMansion)net.minecraftforge.event.terraingen.TerrainGen.getModdedMapGen(field_191060_C, net.minecraftforge.event.terraingen.InitMapGenEvent.EventType.WOODLAND_MANSION); -+ } - this.field_185995_n = p_i46668_1_; - this.field_185996_o = p_i46668_4_; - this.field_185997_p = p_i46668_1_.func_72912_H().func_76067_t(); -@@ -90,6 +100,17 @@ - this.field_186001_t = this.field_186000_s.field_177778_E ? Blocks.field_150353_l.func_176223_P() : Blocks.field_150355_j.func_176223_P(); - p_i46668_1_.func_181544_b(this.field_186000_s.field_177841_q); - } -+ -+ net.minecraftforge.event.terraingen.InitNoiseGensEvent.ContextOverworld ctx = -+ new net.minecraftforge.event.terraingen.InitNoiseGensEvent.ContextOverworld(field_185991_j, field_185992_k, field_185993_l, field_185994_m, field_185983_b, field_185984_c, field_185985_d); -+ ctx = net.minecraftforge.event.terraingen.TerrainGen.getModdedNoiseGenerators(p_i46668_1_, this.field_185990_i, ctx); -+ this.field_185991_j = ctx.getLPerlin1(); -+ this.field_185992_k = ctx.getLPerlin2(); -+ this.field_185993_l = ctx.getPerlin(); -+ this.field_185994_m = ctx.getHeight(); -+ this.field_185983_b = ctx.getScale(); -+ this.field_185984_c = ctx.getDepth(); -+ this.field_185985_d = ctx.getForest(); - } - - public void func_185976_a(int p_185976_1_, int p_185976_2_, ChunkPrimer p_185976_3_) -@@ -163,6 +184,7 @@ - - public void func_185977_a(int p_185977_1_, int p_185977_2_, ChunkPrimer p_185977_3_, Biome[] p_185977_4_) - { -+ if (!net.minecraftforge.event.ForgeEventFactory.onReplaceBiomeBlocks(this, p_185977_1_, p_185977_2_, p_185977_3_, this.field_185995_n)) return; - double d0 = 0.03125D; - this.field_186002_u = this.field_185994_m.func_151599_a(this.field_186002_u, (double)(p_185977_1_ * 16), (double)(p_185977_2_ * 16), 16, 16, 0.0625D, 0.0625D, 1.0D); - -@@ -370,6 +392,8 @@ - boolean flag = false; - ChunkPos chunkpos = new ChunkPos(p_185931_1_, p_185931_2_); - -+ net.minecraftforge.event.ForgeEventFactory.onChunkPopulate(true, this, this.field_185995_n, this.field_185990_i, p_185931_1_, p_185931_2_, flag); -+ - if (this.field_185996_o) - { - if (this.field_186000_s.field_177829_w) -@@ -404,6 +428,7 @@ - } - - if (biome != Biomes.field_76769_d && biome != Biomes.field_76786_s && this.field_186000_s.field_177781_A && !flag && this.field_185990_i.nextInt(this.field_186000_s.field_177782_B) == 0) -+ if (net.minecraftforge.event.terraingen.TerrainGen.populate(this, this.field_185995_n, this.field_185990_i, p_185931_1_, p_185931_2_, flag, net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType.LAKE)) - { - int i1 = this.field_185990_i.nextInt(16) + 8; - int j1 = this.field_185990_i.nextInt(256); -@@ -412,6 +437,7 @@ - } - - if (!flag && this.field_185990_i.nextInt(this.field_186000_s.field_177777_D / 10) == 0 && this.field_186000_s.field_177783_C) -+ if (net.minecraftforge.event.terraingen.TerrainGen.populate(this, this.field_185995_n, this.field_185990_i, p_185931_1_, p_185931_2_, flag, net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType.LAVA)) - { - int i2 = this.field_185990_i.nextInt(16) + 8; - int l2 = this.field_185990_i.nextInt(this.field_185990_i.nextInt(248) + 8); -@@ -424,6 +450,7 @@ - } - - if (this.field_186000_s.field_177837_s) -+ if (net.minecraftforge.event.terraingen.TerrainGen.populate(this, this.field_185995_n, this.field_185990_i, p_185931_1_, p_185931_2_, flag, net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType.DUNGEON)) - { - for (int j2 = 0; j2 < this.field_186000_s.field_177835_t; ++j2) - { -@@ -435,9 +462,12 @@ - } - - biome.func_180624_a(this.field_185995_n, this.field_185990_i, new BlockPos(i, 0, j)); -+ if (net.minecraftforge.event.terraingen.TerrainGen.populate(this, this.field_185995_n, this.field_185990_i, p_185931_1_, p_185931_2_, flag, net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType.ANIMALS)) - WorldEntitySpawner.func_77191_a(this.field_185995_n, biome, i + 8, j + 8, 16, 16, this.field_185990_i); - blockpos = blockpos.func_177982_a(8, 0, 8); - -+ if (net.minecraftforge.event.terraingen.TerrainGen.populate(this, this.field_185995_n, this.field_185990_i, p_185931_1_, p_185931_2_, flag, net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType.ICE)) -+ { - for (int k2 = 0; k2 < 16; ++k2) - { - for (int j3 = 0; j3 < 16; ++j3) -@@ -456,7 +486,10 @@ - } - } - } -+ }//Forge: End ICE - -+ net.minecraftforge.event.ForgeEventFactory.onChunkPopulate(false, this, this.field_185995_n, this.field_185990_i, p_185931_1_, p_185931_2_, flag); -+ - BlockFalling.field_149832_M = false; - } - diff --git a/patches_old/minecraft/net/minecraft/world/gen/layer/GenLayer.java.patch b/patches_old/minecraft/net/minecraft/world/gen/layer/GenLayer.java.patch deleted file mode 100644 index 37db40005..000000000 --- a/patches_old/minecraft/net/minecraft/world/gen/layer/GenLayer.java.patch +++ /dev/null @@ -1,52 +0,0 @@ ---- ../src-base/minecraft/net/minecraft/world/gen/layer/GenLayer.java -+++ ../src-work/minecraft/net/minecraft/world/gen/layer/GenLayer.java -@@ -47,11 +47,11 @@ - i = 6; - } - -+ i = getModdedBiomeSize(p_180781_2_, i); -+ - GenLayer lvt_7_1_ = GenLayerZoom.func_75915_a(1000L, genlayer4, 0); - GenLayer genlayerriverinit = new GenLayerRiverInit(100L, lvt_7_1_); -- GenLayer lvt_8_1_ = new GenLayerBiome(200L, genlayer4, p_180781_2_, p_180781_3_); -- GenLayer genlayer6 = GenLayerZoom.func_75915_a(1000L, lvt_8_1_, 2); -- GenLayer genlayerbiomeedge = new GenLayerBiomeEdge(1000L, genlayer6); -+ GenLayer genlayerbiomeedge = p_180781_2_.getBiomeLayer(p_180781_0_, genlayer4, p_180781_3_); - GenLayer lvt_9_1_ = GenLayerZoom.func_75915_a(1000L, genlayerriverinit, 2); - GenLayer genlayerhills = new GenLayerHills(1000L, genlayerbiomeedge, lvt_9_1_); - GenLayer genlayer5 = GenLayerZoom.func_75915_a(1000L, genlayerriverinit, 2); -@@ -171,10 +171,32 @@ - - protected static boolean func_151618_b(int p_151618_0_) - { -- Biome biome = Biome.func_150568_d(p_151618_0_); -- return biome == Biomes.field_76771_b || biome == Biomes.field_150575_M || biome == Biomes.field_76776_l; -+ return net.minecraftforge.common.BiomeManager.oceanBiomes.contains(Biome.func_150568_d(p_151618_0_)); - } - -+ /* ======================================== FORGE START =====================================*/ -+ protected long nextLong(long par1) -+ { -+ long j = (this.field_75908_c >> 24) % par1; -+ -+ if (j < 0) -+ { -+ j += par1; -+ } -+ -+ this.field_75908_c *= this.field_75908_c * 6364136223846793005L + 1442695040888963407L; -+ this.field_75908_c += this.field_75907_b; -+ 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.getNewSize(); -+ } -+ /* ========================================= FORGE END ======================================*/ -+ - protected int func_151619_a(int... p_151619_1_) - { - return p_151619_1_[this.func_75902_a(p_151619_1_.length)]; diff --git a/patches_old/minecraft/net/minecraft/world/gen/layer/GenLayerBiome.java.patch b/patches_old/minecraft/net/minecraft/world/gen/layer/GenLayerBiome.java.patch deleted file mode 100644 index 18fbcfa5a..000000000 --- a/patches_old/minecraft/net/minecraft/world/gen/layer/GenLayerBiome.java.patch +++ /dev/null @@ -1,93 +0,0 @@ ---- ../src-base/minecraft/net/minecraft/world/gen/layer/GenLayerBiome.java -+++ ../src-work/minecraft/net/minecraft/world/gen/layer/GenLayerBiome.java -@@ -7,10 +7,8 @@ - - public class GenLayerBiome extends GenLayer - { -- private Biome[] field_151623_c = new Biome[] {Biomes.field_76769_d, Biomes.field_76769_d, Biomes.field_76769_d, Biomes.field_150588_X, Biomes.field_150588_X, Biomes.field_76772_c}; -- private final Biome[] field_151621_d = new Biome[] {Biomes.field_76767_f, Biomes.field_150585_R, Biomes.field_76770_e, Biomes.field_76772_c, Biomes.field_150583_P, Biomes.field_76780_h}; -- private final Biome[] field_151622_e = new Biome[] {Biomes.field_76767_f, Biomes.field_76770_e, Biomes.field_76768_g, Biomes.field_76772_c}; -- private final Biome[] field_151620_f = new Biome[] {Biomes.field_76774_n, Biomes.field_76774_n, Biomes.field_76774_n, Biomes.field_150584_S}; -+ @SuppressWarnings("unchecked") -+ private java.util.List[] biomes = new java.util.ArrayList[net.minecraftforge.common.BiomeManager.BiomeType.values().length]; - private final ChunkGeneratorSettings field_175973_g; - - public GenLayerBiome(long p_i45560_1_, GenLayer p_i45560_3_, WorldType p_i45560_4_, ChunkGeneratorSettings p_i45560_5_) -@@ -18,9 +16,30 @@ - super(p_i45560_1_); - this.field_75909_a = 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(Biomes.field_76769_d, 30)); -+ biomes[desertIdx].add(new net.minecraftforge.common.BiomeManager.BiomeEntry(Biomes.field_150588_X, 20)); -+ biomes[desertIdx].add(new net.minecraftforge.common.BiomeManager.BiomeEntry(Biomes.field_76772_c, 10)); -+ - if (p_i45560_4_ == WorldType.field_77136_e) - { -- this.field_151623_c = new Biome[] {Biomes.field_76769_d, Biomes.field_76767_f, Biomes.field_76770_e, Biomes.field_76780_h, Biomes.field_76772_c, Biomes.field_76768_g}; -+ biomes[desertIdx].clear(); -+ biomes[desertIdx].add(new net.minecraftforge.common.BiomeManager.BiomeEntry(Biomes.field_76769_d, 10)); -+ biomes[desertIdx].add(new net.minecraftforge.common.BiomeManager.BiomeEntry(Biomes.field_76767_f, 10)); -+ biomes[desertIdx].add(new net.minecraftforge.common.BiomeManager.BiomeEntry(Biomes.field_76770_e, 10)); -+ biomes[desertIdx].add(new net.minecraftforge.common.BiomeManager.BiomeEntry(Biomes.field_76780_h, 10)); -+ biomes[desertIdx].add(new net.minecraftforge.common.BiomeManager.BiomeEntry(Biomes.field_76772_c, 10)); -+ biomes[desertIdx].add(new net.minecraftforge.common.BiomeManager.BiomeEntry(Biomes.field_76768_g, 10)); - this.field_175973_g = null; - } - else -@@ -70,7 +89,7 @@ - } - else - { -- aint1[j + i * p_75904_3_] = Biome.func_185362_a(this.field_151623_c[this.func_75902_a(this.field_151623_c.length)]); -+ aint1[j + i * p_75904_3_] = Biome.func_185362_a(getWeightedBiomeEntry(net.minecraftforge.common.BiomeManager.BiomeType.DESERT).biome); - } - } - else if (k == 2) -@@ -81,7 +100,7 @@ - } - else - { -- aint1[j + i * p_75904_3_] = Biome.func_185362_a(this.field_151621_d[this.func_75902_a(this.field_151621_d.length)]); -+ aint1[j + i * p_75904_3_] = Biome.func_185362_a(getWeightedBiomeEntry(net.minecraftforge.common.BiomeManager.BiomeType.WARM).biome); - } - } - else if (k == 3) -@@ -92,12 +111,12 @@ - } - else - { -- aint1[j + i * p_75904_3_] = Biome.func_185362_a(this.field_151622_e[this.func_75902_a(this.field_151622_e.length)]); -+ aint1[j + i * p_75904_3_] = Biome.func_185362_a(getWeightedBiomeEntry(net.minecraftforge.common.BiomeManager.BiomeType.COOL).biome); - } - } - else if (k == 4) - { -- aint1[j + i * p_75904_3_] = Biome.func_185362_a(this.field_151620_f[this.func_75902_a(this.field_151620_f.length)]); -+ aint1[j + i * p_75904_3_] = Biome.func_185362_a(getWeightedBiomeEntry(net.minecraftforge.common.BiomeManager.BiomeType.ICY).biome); - } - else - { -@@ -108,4 +127,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.func_76272_a(biomeList); -+ int weight = net.minecraftforge.common.BiomeManager.isTypeListModded(type)?func_75902_a(totalWeight):func_75902_a(totalWeight / 10) * 10; -+ return (net.minecraftforge.common.BiomeManager.BiomeEntry)net.minecraft.util.WeightedRandom.func_180166_a(biomeList, weight); -+ } - } diff --git a/patches_old/minecraft/net/minecraft/world/gen/structure/StructureComponent.java.patch b/patches_old/minecraft/net/minecraft/world/gen/structure/StructureComponent.java.patch deleted file mode 100644 index d46138d51..000000000 --- a/patches_old/minecraft/net/minecraft/world/gen/structure/StructureComponent.java.patch +++ /dev/null @@ -1,13 +0,0 @@ ---- ../src-base/minecraft/net/minecraft/world/gen/structure/StructureComponent.java -+++ ../src-work/minecraft/net/minecraft/world/gen/structure/StructureComponent.java -@@ -41,6 +41,10 @@ - - public final NBTTagCompound func_143010_b() - { -+ if (MapGenStructureIO.func_143036_a(this) == null) // Friendlier error then the Null String error below. -+ { -+ throw new RuntimeException("StructureComponent \"" + this.getClass().getName() + "\" missing ID Mapping, Modder see MapGenStructureIO"); -+ } - NBTTagCompound nbttagcompound = new NBTTagCompound(); - nbttagcompound.func_74778_a("id", MapGenStructureIO.func_143036_a(this)); - nbttagcompound.func_74782_a("BB", this.field_74887_e.func_151535_h()); diff --git a/patches_old/minecraft/net/minecraft/world/gen/structure/StructureStart.java.patch b/patches_old/minecraft/net/minecraft/world/gen/structure/StructureStart.java.patch deleted file mode 100644 index c8db28dbb..000000000 --- a/patches_old/minecraft/net/minecraft/world/gen/structure/StructureStart.java.patch +++ /dev/null @@ -1,23 +0,0 @@ ---- ../src-base/minecraft/net/minecraft/world/gen/structure/StructureStart.java -+++ ../src-work/minecraft/net/minecraft/world/gen/structure/StructureStart.java -@@ -63,6 +63,10 @@ - - public NBTTagCompound func_143021_a(int p_143021_1_, int p_143021_2_) - { -+ if (MapGenStructureIO.func_143033_a(this) == null) // This is just a more friendly error instead of the 'Null String' below -+ { -+ throw new RuntimeException("StructureStart \"" + this.getClass().getName() + "\" missing ID Mapping, Modder see MapGenStructureIO"); -+ } - NBTTagCompound nbttagcompound = new NBTTagCompound(); - nbttagcompound.func_74778_a("id", MapGenStructureIO.func_143033_a(this)); - nbttagcompound.func_74768_a("ChunkX", p_143021_1_); -@@ -98,7 +102,8 @@ - - for (int i = 0; i < nbttaglist.func_74745_c(); ++i) - { -- this.field_75075_a.add(MapGenStructureIO.func_143032_b(nbttaglist.func_150305_b(i), p_143020_1_)); -+ StructureComponent tmp = MapGenStructureIO.func_143032_b(nbttaglist.func_150305_b(i), p_143020_1_); -+ if (tmp != null) this.field_75075_a.add(tmp); //Forge: Prevent NPEs further down the line when a componenet can't be loaded. - } - - this.func_143017_b(p_143020_2_); diff --git a/patches_old/minecraft/net/minecraft/world/gen/structure/StructureVillagePieces.java.patch b/patches_old/minecraft/net/minecraft/world/gen/structure/StructureVillagePieces.java.patch deleted file mode 100644 index b65b5cd04..000000000 --- a/patches_old/minecraft/net/minecraft/world/gen/structure/StructureVillagePieces.java.patch +++ /dev/null @@ -1,93 +0,0 @@ ---- ../src-base/minecraft/net/minecraft/world/gen/structure/StructureVillagePieces.java -+++ ../src-work/minecraft/net/minecraft/world/gen/structure/StructureVillagePieces.java -@@ -68,6 +68,7 @@ - list.add(new StructureVillagePieces.PieceWeight(StructureVillagePieces.Field2.class, 3, MathHelper.func_76136_a(p_75084_0_, 2 + p_75084_1_, 4 + p_75084_1_ * 2))); - list.add(new StructureVillagePieces.PieceWeight(StructureVillagePieces.House2.class, 15, MathHelper.func_76136_a(p_75084_0_, 0, 1 + p_75084_1_))); - list.add(new StructureVillagePieces.PieceWeight(StructureVillagePieces.House3.class, 8, MathHelper.func_76136_a(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()) -@@ -140,6 +141,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; - } -@@ -1539,6 +1544,7 @@ - public List field_74931_h; - public List field_74932_i = Lists.newArrayList(); - public List field_74930_j = Lists.newArrayList(); -+ public Biome biome; - - public Start() - { -@@ -1551,6 +1557,8 @@ - this.field_74931_h = p_i2104_6_; - this.field_74928_c = p_i2104_7_; - Biome biome = p_i2104_1_.func_180300_a(new BlockPos(p_i2104_4_, 0, p_i2104_5_), Biomes.field_180279_ad); -+ this.biome = biome; -+ this.startPiece = this; - - if (biome instanceof BiomeDesert) - { -@@ -1623,6 +1631,7 @@ - private int field_74896_a; - protected int field_189928_h; - protected boolean field_189929_i; -+ protected StructureVillagePieces.Start startPiece; - - public Village() - { -@@ -1636,6 +1645,7 @@ - { - this.field_189928_h = p_i2107_1_.field_189928_h; - this.field_189929_i = p_i2107_1_.field_189929_i; -+ startPiece = p_i2107_1_; - } - } - -@@ -1770,7 +1780,6 @@ - EntityZombieVillager entityzombievillager = new EntityZombieVillager(p_74893_1_); - entityzombievillager.func_70012_b((double)j + 0.5D, (double)k, (double)l + 0.5D, 0.0F, 0.0F); - entityzombievillager.func_180482_a(p_74893_1_.func_175649_E(new BlockPos(entityzombievillager)), (IEntityLivingData)null); -- entityzombievillager.func_190733_a(this.func_180779_c(i, 0)); - entityzombievillager.func_110163_bv(); - p_74893_1_.func_72838_d(entityzombievillager); - } -@@ -1778,7 +1787,7 @@ - { - EntityVillager entityvillager = new EntityVillager(p_74893_1_); - entityvillager.func_70012_b((double)j + 0.5D, (double)k, (double)l + 0.5D, 0.0F, 0.0F); -- entityvillager.func_70938_b(this.func_180779_c(i, p_74893_1_.field_73012_v.nextInt(6))); -+ entityvillager.setProfession(this.chooseForgeProfession(i, entityvillager.getProfessionForge())); - entityvillager.func_190672_a(p_74893_1_.func_175649_E(new BlockPos(entityvillager)), (IEntityLivingData)null, false); - p_74893_1_.func_72838_d(entityvillager); - } -@@ -1786,13 +1795,21 @@ - } - } - -+ @Deprecated // Use Forge version below. - protected int func_180779_c(int p_180779_1_, int p_180779_2_) - { - return p_180779_2_; - } -+ protected net.minecraftforge.fml.common.registry.VillagerRegistry.VillagerProfession chooseForgeProfession(int count, net.minecraftforge.fml.common.registry.VillagerRegistry.VillagerProfession prof) -+ { -+ return net.minecraftforge.fml.common.registry.VillagerRegistry.getById(func_180779_c(count, net.minecraftforge.fml.common.registry.VillagerRegistry.getId(prof))); -+ } - - 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.getReplacement(); - if (this.field_189928_h == 1) - { - if (p_175847_1_.func_177230_c() == Blocks.field_150364_r || p_175847_1_.func_177230_c() == Blocks.field_150363_s) diff --git a/patches_old/minecraft/net/minecraft/world/gen/structure/template/Template.java.patch b/patches_old/minecraft/net/minecraft/world/gen/structure/template/Template.java.patch deleted file mode 100644 index 4ed1f367d..000000000 --- a/patches_old/minecraft/net/minecraft/world/gen/structure/template/Template.java.patch +++ /dev/null @@ -1,19 +0,0 @@ ---- ../src-base/minecraft/net/minecraft/world/gen/structure/template/Template.java -+++ ../src-work/minecraft/net/minecraft/world/gen/structure/template/Template.java -@@ -211,6 +211,8 @@ - for (Template.BlockInfo template$blockinfo : this.field_186270_a) - { - BlockPos blockpos = func_186266_a(p_189960_4_, template$blockinfo.field_186242_a).func_177971_a(p_189960_2_); -+ // Forge: skip processing blocks outside BB to prevent cascading worldgen issues -+ if (structureboundingbox != null && !structureboundingbox.func_175898_b(blockpos)) continue; - Template.BlockInfo template$blockinfo1 = p_189960_3_ != null ? p_189960_3_.func_189943_a(p_189960_1_, blockpos, template$blockinfo) : template$blockinfo; - - if (template$blockinfo1 != null) -@@ -514,6 +516,7 @@ - nbttaglist2.func_74742_a(NBTUtil.func_190009_a(new NBTTagCompound(), iblockstate)); - } - -+ net.minecraftforge.fml.common.FMLCommonHandler.instance().getDataFixer().writeVersionData(p_189552_1_); //Moved up for MC updating reasons. - p_189552_1_.func_74782_a("palette", nbttaglist2); - p_189552_1_.func_74782_a("blocks", nbttaglist); - p_189552_1_.func_74782_a("entities", nbttaglist1); diff --git a/src/main/java/net/minecraftforge/common/extensions/IForgeDimension.java b/src/main/java/net/minecraftforge/common/extensions/IForgeDimension.java index dbdabf1d0..c2c514f09 100644 --- a/src/main/java/net/minecraftforge/common/extensions/IForgeDimension.java +++ b/src/main/java/net/minecraftforge/common/extensions/IForgeDimension.java @@ -28,11 +28,11 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.Vec3d; import net.minecraft.world.World; -import net.minecraft.world.WorldType; import net.minecraft.world.biome.Biome; import net.minecraft.world.chunk.Chunk; import net.minecraft.world.dimension.Dimension; import net.minecraft.world.dimension.NetherDimension; +import net.minecraft.world.dimension.OverworldDimension; import net.minecraft.world.storage.WorldInfo; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @@ -44,6 +44,8 @@ public interface IForgeDimension { return (Dimension) this; } + + World getWorld(); /** * Called from {@link World#initCapabilities()}, to gather capabilities for this @@ -79,6 +81,22 @@ public interface IForgeDimension } return 1.0; } + + /** + * If this method returns true, then chunks received by the client will + * have {@link net.minecraft.world.chunk.Chunk#resetRelightChecks} called + * on them, queuing lighting checks for all air blocks in the chunk (and + * any adjacent light-emitting blocks). + * + * Returning true here is recommended if the chunk generator used also + * does this for newly generated chunks. + * + * @return true if lighting checks should be performed + */ + default boolean shouldClientCheckLighting() + { + return !(this instanceof OverworldDimension); + } /** * Sets the providers current dimension ID, used in default getSaveFolder() @@ -149,15 +167,34 @@ public interface IForgeDimension { return null; } + + /** + * Determines if the player can sleep in this world (or if the bed should explode for example). + * + * @param player The player that is attempting to sleep + * @param pos The location where the player tries to sleep at (the position of the clicked on bed for example) + * @return the result of a player trying to sleep at the given location + */ + default SleepResult canSleepAt(net.minecraft.entity.player.EntityPlayer player, BlockPos pos) + { + return (getDimension().canRespawnHere() && getWorld().getBiome(pos) != net.minecraft.init.Biomes.NETHER) ? SleepResult.ALLOW : SleepResult.BED_EXPLODES; + } + + enum SleepResult + { + ALLOW, + DENY, + BED_EXPLODES; + } default Biome getBiome(BlockPos pos) { - return getDimension().getWorld().getBiomeBody(pos); + return getWorld().getBiomeBody(pos); } default boolean isDaytime() { - return getDimension().getWorld().getSkylightSubtracted() < 4; + return getWorld().getSkylightSubtracted() < 4; } /** @@ -170,7 +207,7 @@ public interface IForgeDimension **/ default float getSunBrightnessFactor(float partialTicks) { - return getDimension().getWorld().getSunBrightnessFactor(partialTicks); + return getWorld().getSunBrightnessFactor(partialTicks); } /** @@ -179,19 +216,19 @@ public interface IForgeDimension @OnlyIn(Dist.CLIENT) default float getSunBrightness(float partialTicks) { - return getDimension().getWorld().getSunBrightnessBody(partialTicks); + return getWorld().getSunBrightnessBody(partialTicks); } @OnlyIn(Dist.CLIENT) default Vec3d getSkyColor(Entity cameraEntity, float partialTicks) { - return getDimension().getWorld().getSkyColorBody(cameraEntity, partialTicks); + return getWorld().getSkyColorBody(cameraEntity, partialTicks); } @OnlyIn(Dist.CLIENT) default Vec3d getCloudColor(float partialTicks) { - return getDimension().getWorld().getCloudColorBody(partialTicks); + return getWorld().getCloudColorBody(partialTicks); } /** @@ -210,7 +247,7 @@ public interface IForgeDimension @OnlyIn(Dist.CLIENT) default float getStarBrightness(float partialTicks) { - float f = getDimension().getWorld().getCelestialAngle(partialTicks); + float f = getWorld().getCelestialAngle(partialTicks); float f1 = 1.0F - (MathHelper.cos(f * ((float)Math.PI * 2F)) * 2.0F + 0.25F); f1 = MathHelper.clamp(f1, 0.0F, 1.0F); return f1 * f1 * 0.5F; @@ -220,48 +257,48 @@ public interface IForgeDimension default void calculateInitialWeather() { - getDimension().getWorld().calculateInitialWeatherBody(); + getWorld().calculateInitialWeatherBody(); } default void updateWeather() { - getDimension().getWorld().updateWeatherBody(); + getWorld().updateWeatherBody(); } default long getSeed() { - return getDimension().getWorld().getWorldInfo().getSeed(); + return getWorld().getWorldInfo().getSeed(); } default long getWorldTime() { - return getDimension().getWorld().getWorldInfo().getDayTime(); + return getWorld().getWorldInfo().getDayTime(); } default void setWorldTime(long time) { - getDimension().getWorld().getWorldInfo().setDayTime(time); + getWorld().getWorldInfo().setDayTime(time); } default BlockPos getSpawnPoint() { - WorldInfo info = getDimension().getWorld().getWorldInfo(); + WorldInfo info = getWorld().getWorldInfo(); return new BlockPos(info.getSpawnX(), info.getSpawnY(), info.getSpawnZ()); } default void setSpawnPoint(BlockPos pos) { - getDimension().getWorld().getWorldInfo().setSpawn(pos); + getWorld().getWorldInfo().setSpawn(pos); } default boolean canMineBlock(EntityPlayer player, BlockPos pos) { - return getDimension().getWorld().canMineBlockBody(player, pos); + return getWorld().canMineBlockBody(player, pos); } default boolean isHighHumidity(BlockPos pos) { - return getDimension().getWorld().getBiome(pos).isHighHumidity(); + return getWorld().getBiome(pos).isHighHumidity(); } default int getHeight() @@ -276,7 +313,7 @@ public interface IForgeDimension default double getHorizon() { - return getDimension().getWorld().getWorldInfo().getTerrainType().getHorizon(getDimension().getWorld()); + return getWorld().getWorldInfo().getTerrainType().getHorizon(getWorld()); } default String getSaveFolder() @@ -297,4 +334,15 @@ public interface IForgeDimension { return getId() < 0; } + + /** + * Determines the dimension the player will be respawned in, typically this brings them back to the overworld. + * + * @param player The player that is respawning + * @return The dimension to respawn the player in + */ + default int getRespawnDimension(net.minecraft.entity.player.EntityPlayerMP player) + { + return player.getSpawnDimension(); + } } diff --git a/src/main/java/net/minecraftforge/common/extensions/IForgeWorldType.java b/src/main/java/net/minecraftforge/common/extensions/IForgeWorldType.java new file mode 100644 index 000000000..6e59bdd2b --- /dev/null +++ b/src/main/java/net/minecraftforge/common/extensions/IForgeWorldType.java @@ -0,0 +1,104 @@ +package net.minecraftforge.common.extensions; + +import java.util.function.LongFunction; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiCreateBuffetWorld; +import net.minecraft.client.gui.GuiCreateFlatWorld; +import net.minecraft.client.gui.GuiCreateWorld; +import net.minecraft.world.World; +import net.minecraft.world.WorldType; +import net.minecraft.world.gen.IChunkGenerator; +import net.minecraft.world.gen.IContextExtended; +import net.minecraft.world.gen.OverworldGenSettings; +import net.minecraft.world.gen.area.IArea; +import net.minecraft.world.gen.area.IAreaFactory; +import net.minecraft.world.gen.layer.GenLayerBiome; +import net.minecraft.world.gen.layer.GenLayerBiomeEdge; +import net.minecraft.world.gen.layer.GenLayerZoom; +import net.minecraft.world.gen.layer.LayerUtil; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; + +public interface IForgeWorldType +{ + default WorldType getWorldType() + { + return (WorldType) this; + } + + /** + * Called when 'Create New World' button is pressed before starting game + */ + default void onGUICreateWorldPress() + { + } + + /** + * Called when the 'Customize' button is pressed on world creation GUI + * + * @param mc The Minecraft instance + * @param gui the createworld GUI + */ + @OnlyIn(Dist.CLIENT) + default void onCustomizeButton(Minecraft mc, GuiCreateWorld gui) + { + if (this == WorldType.FLAT) + mc.displayGuiScreen(new GuiCreateFlatWorld(gui, gui.chunkProviderSettingsJson)); + else if (this == WorldType.CUSTOMIZED) + mc.displayGuiScreen(new GuiCreateBuffetWorld(gui, gui.chunkProviderSettingsJson)); + } + + default boolean handleSlimeSpawnReduction(java.util.Random random, World world) + { + return this == WorldType.FLAT ? random.nextInt(4) != 1 : false; + } + + default double getHorizon(World world) + { + return this == WorldType.FLAT ? 0.0D : 63.0D; + } + + default double voidFadeMagnitude() + { + return this == WorldType.FLAT ? 1.0D : 0.03125D; + } + + /** + * Get the height to render the clouds for this world type + * + * @return The height to render clouds at + */ + default float getCloudHeight() + { + return 128.0F; + } + + @SuppressWarnings("deprecation") + default IChunkGenerator createChunkGenerator(World world) + { + return world.dimension.createChunkGenerator(); + } + + /** + * Creates the GenLayerBiome used for generating the world with the specified + * ChunkProviderSettings JSON String *IF AND ONLY IF* this WorldType == + * WorldType.CUSTOMIZED. + * + * + * @param worldSeed The world seed + * @param parentLayer The parent layer to feed into any layer you return + * @param chunkSettings The ChunkGeneratorSettings constructed from the custom + * JSON + * @return A GenLayer that will return ints representing the Biomes to be + * generated, see GenLayerBiome + */ + default > IAreaFactory getBiomeLayer(IAreaFactory parentLayer, + OverworldGenSettings chunkSettings, LongFunction contextFactory) + { + parentLayer = (new GenLayerBiome(getWorldType(), chunkSettings)).apply((IContextExtended) contextFactory.apply(200L), parentLayer); + parentLayer = LayerUtil.repeat(1000L, GenLayerZoom.NORMAL, parentLayer, 2, contextFactory); + parentLayer = GenLayerBiomeEdge.INSTANCE.apply((IContextExtended) contextFactory.apply(1000L), parentLayer); + return parentLayer; + } +} diff --git a/src/main/java/net/minecraftforge/event/ForgeEventFactory.java b/src/main/java/net/minecraftforge/event/ForgeEventFactory.java index 91b4ca11e..3e88181aa 100644 --- a/src/main/java/net/minecraftforge/event/ForgeEventFactory.java +++ b/src/main/java/net/minecraftforge/event/ForgeEventFactory.java @@ -25,8 +25,10 @@ import java.util.EnumSet; import java.util.List; import java.util.Random; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + import net.minecraft.block.BlockPortal; -import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; import net.minecraft.client.util.ITooltipFlag; import net.minecraft.entity.Entity; @@ -43,11 +45,9 @@ import net.minecraft.entity.projectile.EntityArrow; import net.minecraft.entity.projectile.EntityFireball; import net.minecraft.entity.projectile.EntityThrowable; import net.minecraft.init.Blocks; -import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.ItemUseContext; import net.minecraft.tileentity.MobSpawnerBaseLogic; -import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ActionResult; import net.minecraft.util.DamageSource; import net.minecraft.util.EnumActionResult; @@ -62,15 +62,13 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.RayTraceResult; import net.minecraft.util.text.ChatType; import net.minecraft.util.text.ITextComponent; -import net.minecraft.village.Village; import net.minecraft.world.Explosion; import net.minecraft.world.IWorld; import net.minecraft.world.World; import net.minecraft.world.WorldServer; import net.minecraft.world.WorldSettings; import net.minecraft.world.biome.Biome; -import net.minecraft.world.chunk.Chunk; -import net.minecraft.world.chunk.ChunkPrimer; +import net.minecraft.world.chunk.IChunk; import net.minecraft.world.gen.IChunkGenerator; import net.minecraft.world.storage.IPlayerFileData; import net.minecraft.world.storage.SaveHandler; @@ -119,6 +117,7 @@ import net.minecraftforge.event.entity.player.SleepingLocationCheckEvent; import net.minecraftforge.event.entity.player.SleepingTimeCheckEvent; import net.minecraftforge.event.entity.player.UseHoeEvent; import net.minecraftforge.event.furnace.FurnaceFuelBurnTimeEvent; +import net.minecraftforge.event.terraingen.ChunkGeneratorEvent; import net.minecraftforge.event.world.BlockEvent; import net.minecraftforge.event.world.BlockEvent.CreateFluidSourceEvent; import net.minecraftforge.event.world.BlockEvent.MultiPlaceEvent; @@ -130,10 +129,6 @@ import net.minecraftforge.event.world.SaplingGrowTreeEvent; import net.minecraftforge.event.world.WorldEvent; import net.minecraftforge.eventbus.api.Event; import net.minecraftforge.eventbus.api.Event.Result; -import net.minecraftforge.fml.common.registry.GameRegistry; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; public class ForgeEventFactory { @@ -639,6 +634,13 @@ public class ForgeEventFactory { return MinecraftForge.EVENT_BUS.post(new ProjectileImpactEvent.Throwable(throwable, ray)); } + + public static boolean onReplaceBiomeBlocks(IChunkGenerator gen, IChunk chunk, IWorld world) + { + ChunkGeneratorEvent.ReplaceBiomeBlocks event = new ChunkGeneratorEvent.ReplaceBiomeBlocks(gen, chunk, world); + MinecraftForge.EVENT_BUS.post(event); + return event.getResult() != Event.Result.DENY; + } public static LootTable loadLootTable(ResourceLocation name, LootTable table, LootTableManager lootTableManager) { diff --git a/src/main/java/net/minecraftforge/event/terraingen/BiomeEvent.java b/src/main/java/net/minecraftforge/event/terraingen/BiomeEvent.java new file mode 100644 index 000000000..256034d12 --- /dev/null +++ b/src/main/java/net/minecraftforge/event/terraingen/BiomeEvent.java @@ -0,0 +1,150 @@ +/* + * Minecraft Forge + * Copyright (c) 2016-2018. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation version 2.1 + * of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +package net.minecraftforge.event.terraingen; + +import net.minecraft.block.state.IBlockState; +import net.minecraft.world.biome.Biome; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.eventbus.api.Event; + +/** + * BiomeEvent is fired whenever an event involving biomes occurs.
+ * If a method utilizes this {@link Event} as its parameter, the method will + * receive every child event of this class.
+ *
+ * All children of this event are fired on the {@link MinecraftForge#TERRAIN_GEN_BUS} + * unless stated otherwise in their Javadocs. + **/ +public class BiomeEvent extends Event +{ + private final Biome biome; + + public BiomeEvent(Biome biome) + { + this.biome = biome; + } + + public Biome getBiome() + { + return biome; + } + + /** + * BiomeColor is fired whenever an event involving biome colors occurs.
+ * If a method utilizes this {@link Event} as its parameter, the method will + * receive every child event of this class.
+ *
+ * All children of this event are fired on the {@link MinecraftForge#EVENT_BUS}. + **/ + public static class BiomeColor extends BiomeEvent + { + private final int originalColor; + private int newColor; + + public BiomeColor(Biome biome, int original) + { + super(biome); + originalColor = original; + setNewColor(original); + } + + public int getOriginalColor() + { + return originalColor; + } + + public int getNewColor() + { + return newColor; + } + + public void setNewColor(int newColor) + { + this.newColor = newColor; + } + } + + /** + * This event is fired when the village generator attempts to choose a block ID + * based on the village's biome. + * + * You can cancel the event to override default values + */ + @HasResult + public static class GetVillageBlockID extends BiomeEvent + { + private final IBlockState original; + private IBlockState replacement; + + public GetVillageBlockID(Biome biome, IBlockState original) + { + super(biome); + this.original = original; + } + + public IBlockState getOriginal() + { + return original; + } + + public IBlockState getReplacement() + { + return replacement; + } + + public void setReplacement(IBlockState replacement) + { + this.replacement = replacement; + } + } + + /** + * This event is fired when a biome is queried for its grass color. + */ + public static class GetGrassColor extends BiomeColor + { + public GetGrassColor(Biome biome, int original) + { + super(biome, original); + } + } + + /** + * This event is fired when a biome is queried for its grass color. + */ + public static class GetFoliageColor extends BiomeColor + { + public GetFoliageColor(Biome biome, int original) + { + super(biome, original); + } + } + + /** + * This event is fired when a biome is queried for its water color. + */ + public static class GetWaterColor extends BiomeColor + { + public GetWaterColor(Biome biome, int original) + { + super(biome, original); + } + } +} diff --git a/src/main/java/net/minecraftforge/event/terraingen/ChunkGeneratorEvent.java b/src/main/java/net/minecraftforge/event/terraingen/ChunkGeneratorEvent.java new file mode 100644 index 000000000..7c2c41902 --- /dev/null +++ b/src/main/java/net/minecraftforge/event/terraingen/ChunkGeneratorEvent.java @@ -0,0 +1,104 @@ +/* + * Minecraft Forge + * Copyright (c) 2016-2018. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation version 2.1 + * of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +package net.minecraftforge.event.terraingen; + +import net.minecraft.world.IWorld; +import net.minecraft.world.World; +import net.minecraft.world.chunk.IChunk; +import net.minecraft.world.gen.IChunkGenerator; +import net.minecraftforge.eventbus.api.Event; + +public class ChunkGeneratorEvent extends Event +{ + private final IChunkGenerator gen; + + public ChunkGeneratorEvent(IChunkGenerator gen) + { + this.gen = gen; + } + + public IChunkGenerator getGenerator() { return this.getGen(); } + + public IChunkGenerator getGen() + { + return gen; + } + + /** + * This event is fired when a chunks blocks are replaced by a biomes top and + * filler blocks. + * + * You can set the result to DENY to prevent the default replacement. + */ + @HasResult + public static class ReplaceBiomeBlocks extends ChunkGeneratorEvent + { + private final IChunk chunk; + private final IWorld world; // CAN BE NULL + + public ReplaceBiomeBlocks(IChunkGenerator chunkProvider, IChunk chunk, IWorld world) + { + super(chunkProvider); + this.chunk = chunk; + this.world = world; + } + + public IChunk getChunk() { return chunk; } + public IWorld getWorld() { return world; } + } + + /** + * This event is fired before a chunks terrain noise field is initialized. + * + * You can set the result to DENY to substitute your own noise field. + */ + @HasResult + public static class InitNoiseField extends ChunkGeneratorEvent + { + private double[] noisefield; + private final int posX; + private final int posY; + private final int posZ; + private final int sizeX; + private final int sizeY; + private final int sizeZ; + + public InitNoiseField(IChunkGenerator chunkProvider, double[] noisefield, int posX, int posY, int posZ, int sizeX, int sizeY, int sizeZ) + { + super(chunkProvider); + this.setNoisefield(noisefield); + this.posX = posX; + this.posY = posY; + this.posZ = posZ; + this.sizeX = sizeX; + this.sizeY = sizeY; + this.sizeZ = sizeZ; + } + + public double[] getNoisefield() { return noisefield; } + public void setNoisefield(double[] noisefield) { this.noisefield = noisefield; } + public int getPosX() { return posX; } + public int getPosY() { return posY; } + public int getPosZ() { return posZ; } + public int getSizeX() { return sizeX; } + public int getSizeY() { return sizeY; } + public int getSizeZ() { return sizeZ; } + } +} diff --git a/src/main/java/net/minecraftforge/event/terraingen/InitNoiseGensEvent.java b/src/main/java/net/minecraftforge/event/terraingen/InitNoiseGensEvent.java new file mode 100644 index 000000000..16c26dfaf --- /dev/null +++ b/src/main/java/net/minecraftforge/event/terraingen/InitNoiseGensEvent.java @@ -0,0 +1,126 @@ +/* + * Minecraft Forge + * Copyright (c) 2016-2018. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation version 2.1 + * of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +package net.minecraftforge.event.terraingen; + +import java.util.Random; + +import net.minecraft.world.IWorld; +import net.minecraft.world.gen.NoiseGeneratorOctaves; +import net.minecraft.world.gen.NoiseGeneratorPerlin; +import net.minecraftforge.event.world.WorldEvent; + +public class InitNoiseGensEvent extends WorldEvent +{ + private final Random rand; + private final T original; + private T newValues; + + @SuppressWarnings("unchecked") + public InitNoiseGensEvent(IWorld world, Random rand, T original) + { + super(world); + this.rand = rand; + this.original = original; + this.newValues = (T)original.clone(); + } + public Random getRandom() { return this.rand; } + public T getOriginal() { return this.original; } + public T getNewValues() { return this.newValues; } + + public static class Context + { + private NoiseGeneratorOctaves lperlin1; + private NoiseGeneratorOctaves lperlin2; + private NoiseGeneratorOctaves perlin; + private NoiseGeneratorOctaves scale; + private NoiseGeneratorOctaves depth; + public Context(NoiseGeneratorOctaves lperlin1, NoiseGeneratorOctaves lperlin2, NoiseGeneratorOctaves perlin, + NoiseGeneratorOctaves scale, NoiseGeneratorOctaves depth) + { + this.lperlin1 = lperlin1; + this.lperlin2 = lperlin2; + this.perlin = perlin; + this.scale = scale; + this.depth = depth; + } + public NoiseGeneratorOctaves getLPerlin1() { return lperlin1; } + public NoiseGeneratorOctaves getLPerlin2() { return lperlin2; } + public NoiseGeneratorOctaves getPerlin() { return perlin; } + public NoiseGeneratorOctaves getScale() { return scale; } + public NoiseGeneratorOctaves getDepth() { return depth; } + public void setLPerlin1(NoiseGeneratorOctaves value) { this.lperlin1 = value; } + public void getLPerlin2(NoiseGeneratorOctaves value) { this.lperlin2 = value; } + public void getPerlin (NoiseGeneratorOctaves value) { this.perlin = value; } + public void getScale (NoiseGeneratorOctaves value) { this.scale = value; } + public void getDepth (NoiseGeneratorOctaves value) { this.depth = value; } + + @Override + public Context clone(){ return new Context(lperlin1, lperlin2, perlin, scale, depth); } + } + + public static class ContextOverworld extends Context + { + private NoiseGeneratorPerlin height; + + public ContextOverworld(NoiseGeneratorOctaves lperlin1, NoiseGeneratorOctaves lperlin2, NoiseGeneratorOctaves perlin, + NoiseGeneratorPerlin height, NoiseGeneratorOctaves scale, NoiseGeneratorOctaves depth) + { + super(lperlin1, lperlin2, perlin, scale, depth); + this.height = height; + } + @Override + public ContextOverworld clone() { return new ContextOverworld(getLPerlin1(), getLPerlin2(), getPerlin(), height, getScale(), getDepth()); } + public NoiseGeneratorPerlin getHeight() { return height; } + + public void getHeight (NoiseGeneratorPerlin value) { this.height = value; } + } + + public static class ContextEnd extends Context + { + private NoiseGeneratorPerlin island; + public ContextEnd(NoiseGeneratorOctaves lperlin1, NoiseGeneratorOctaves lperlin2, NoiseGeneratorOctaves perlin, + NoiseGeneratorOctaves scale, NoiseGeneratorOctaves depth, NoiseGeneratorPerlin field_205478_l) + { + super(lperlin1, lperlin2, perlin, scale, depth); + this.island = field_205478_l; + } + @Override + public ContextEnd clone() { return new ContextEnd(getLPerlin1(), getLPerlin2(), getPerlin(), getScale(), getDepth(), island); } + public NoiseGeneratorPerlin getIsland() { return island; } + public void getIsland (NoiseGeneratorPerlin value) { this.island = value; } + } + + + public static class ContextHell extends Context + { + private NoiseGeneratorOctaves perlin2; + + public ContextHell(NoiseGeneratorOctaves lperlin1, NoiseGeneratorOctaves lperlin2, NoiseGeneratorOctaves perlin, + NoiseGeneratorOctaves perlin2, NoiseGeneratorOctaves scale, NoiseGeneratorOctaves depth) + { + super(lperlin1, lperlin2, perlin, scale, depth); + this.perlin2 = perlin2; + } + @Override + public ContextHell clone() { return new ContextHell(getLPerlin1(), getLPerlin2(), getPerlin(), perlin2, getScale(), getDepth()); } + public NoiseGeneratorOctaves getPerlin2() { return perlin2; } + public void getPerlin2 (NoiseGeneratorOctaves value) { this.perlin2 = value; } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraftforge/event/terraingen/TerrainGen.java b/src/main/java/net/minecraftforge/event/terraingen/TerrainGen.java new file mode 100644 index 000000000..8e82eae27 --- /dev/null +++ b/src/main/java/net/minecraftforge/event/terraingen/TerrainGen.java @@ -0,0 +1,35 @@ +/* + * Minecraft Forge + * Copyright (c) 2016-2018. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation version 2.1 + * of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +package net.minecraftforge.event.terraingen; + +import java.util.Random; + +import net.minecraft.world.IWorld; +import net.minecraftforge.common.MinecraftForge; + +public abstract class TerrainGen +{ + public static T getModdedNoiseGenerators(IWorld world, Random rand, T original) + { + InitNoiseGensEvent event = new InitNoiseGensEvent<>(world, rand, original); + MinecraftForge.EVENT_BUS.post(event); + return event.getNewValues(); + } +} diff --git a/src/main/java/net/minecraftforge/event/terraingen/WorldTypeEvent.java b/src/main/java/net/minecraftforge/event/terraingen/WorldTypeEvent.java new file mode 100644 index 000000000..e54b1fc83 --- /dev/null +++ b/src/main/java/net/minecraftforge/event/terraingen/WorldTypeEvent.java @@ -0,0 +1,146 @@ +/* + * Minecraft Forge + * Copyright (c) 2016-2018. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation version 2.1 + * of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +package net.minecraftforge.event.terraingen; + +import net.minecraft.world.WorldType; +import net.minecraft.world.biome.provider.BiomeProvider; +import net.minecraft.world.gen.layer.GenLayer; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.eventbus.api.Cancelable; +import net.minecraftforge.eventbus.api.Event; +import net.minecraftforge.eventbus.api.Event.HasResult; + +/** + * WorldTypeEvent is fired when an event involving the world occurs.
+ * If a method utilizes this {@link Event} as its parameter, the method will + * receive every child event of this class.
+ *
+ * {@link #worldType} contains the WorldType of the world this event is occurring in.
+ *
+ * All children of this event are fired on the {@link MinecraftForge#TERRAIN_GEN_BUS}.
+ **/ +public class WorldTypeEvent extends Event +{ + private final WorldType worldType; + + public WorldTypeEvent(WorldType worldType) + { + this.worldType = worldType; + } + + public WorldType getWorldType() + { + return worldType; + } + + /** + * BiomeSize is fired when vanilla Minecraft attempts to generate biomes.
+ * This event is fired during biome generation in + * {@link GenLayer#initializeAllBiomeGenerators(long, WorldType, ChunkProviderSettings)}.
+ *
+ * {@link #originalSize} the original size of the Biome.
+ * {@link #newSize} the new size of the biome. Initially set to the {@link #originalSize}.
+ * If {@link #newSize} is set to a new value, that value will be used for the Biome size.
+ *
+ * This event is not {@link Cancelable}.
+ *
+ * This event does not have a result. {@link HasResult}
+ *
+ * This event is fired on the {@link MinecraftForge#TERRAIN_GEN_BUS}.
+ **/ + public static class BiomeSize extends WorldTypeEvent + { + private final int originalSize; + private int newSize; + + public BiomeSize(WorldType worldType, int original) + { + super(worldType); + originalSize = original; + setNewSize(original); + } + + public int getOriginalSize() + { + return originalSize; + } + + public int getNewSize() + { + return newSize; + } + + public void setNewSize(int newSize) + { + this.newSize = newSize; + } + } + + /** + * InitBiomeGens is fired when vanilla Minecraft attempts to initialize the biome providers.
+ * This event is fired just during biome provider initialization in + * {@link BiomeProvider#BiomeProvider(long, WorldType, String)}.
+ *
+ * {@link #seed} the seed of the world.
+ * {@link #originalBiomeGens} the array of GenLayers original intended for this Biome generation.
+ * {@link #newBiomeGens} the array of GenLayers that will now be used for this Biome generation.
+ * If {@link #newBiomeGens} is set to a new value, that value will be used for the Biome generator.
+ *
+ * This event is not {@link Cancelable}.
+ *
+ * This event does not have a result. {@link HasResult}
+ *
+ * This event is fired on the {@link MinecraftForge#TERRAIN_GEN_BUS}.
+ **/ + public static class InitBiomeGens extends WorldTypeEvent + { + private final long seed; + private final GenLayer[] originalBiomeGens; + private GenLayer[] newBiomeGens; + + public InitBiomeGens(WorldType worldType, long seed, GenLayer[] original) + { + super(worldType); + this.seed = seed; + originalBiomeGens = original; + setNewBiomeGens(original.clone()); + } + + public long getSeed() + { + return seed; + } + + public GenLayer[] getOriginalBiomeGens() + { + return originalBiomeGens; + } + + public GenLayer[] getNewBiomeGens() + { + return newBiomeGens; + } + + public void setNewBiomeGens(GenLayer[] newBiomeGens) + { + this.newBiomeGens = newBiomeGens; + } + } +} 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 0ca431046..458834197 100644 --- a/src/main/java/net/minecraftforge/fml/common/registry/VillagerRegistry.java +++ b/src/main/java/net/minecraftforge/fml/common/registry/VillagerRegistry.java @@ -23,22 +23,28 @@ import java.util.Collections; import java.util.List; import java.util.Map; import java.util.Random; -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; -import net.minecraft.entity.monster.EntityZombieVillager; -import net.minecraftforge.fml.RegistryObject; -import net.minecraftforge.registries.ForgeRegistryEntry; + +import javax.annotation.Nullable; + import org.apache.commons.lang3.Validate; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; + +import net.minecraft.entity.monster.EntityZombieVillager; import net.minecraft.entity.passive.EntityVillager; import net.minecraft.entity.passive.EntityVillager.ITradeList; import net.minecraft.util.EnumFacing; import net.minecraft.util.ResourceLocation; import net.minecraft.util.registry.RegistryNamespaced; +import net.minecraft.world.gen.feature.structure.StructurePiece; +import net.minecraft.world.gen.feature.structure.VillagePieces; +import net.minecraft.world.gen.feature.structure.VillagePieces.PieceWeight; +import net.minecraft.world.gen.feature.structure.VillagePieces.Village; +import net.minecraftforge.fml.RegistryObject; +import net.minecraftforge.registries.ForgeRegistryEntry; import net.minecraftforge.registries.GameData; -import javax.annotation.Nullable; - /** * Registry for villager trading control */ @@ -47,43 +53,36 @@ public class VillagerRegistry public static final RegistryObject FARMER = RegistryObject.of("minecraft:farmer", ()->VillagerProfession.class); private static final VillagerRegistry INSTANCE = new VillagerRegistry(); -/* TODO village creation private Map, IVillageCreationHandler> villageCreationHandlers = Maps.newHashMap(); -*/ + private VillagerRegistry() { init(); } -/** + /** * Allow access to the {@link net.minecraft.world.gen.structure.StructureVillagePieces} array controlling new village * creation so you can insert your own new village pieces * * @author cpw - *//* - + */ public interface IVillageCreationHandler { - */ -/** + /** * Called when {@link net.minecraft.world.gen.structure.MapGenVillage} is creating a new village * * @param random * @param i - *//* + */ + VillagePieces.PieceWeight getVillagePieceWeight(Random random, int i); - StructureVillagePieces.PieceWeight getVillagePieceWeight(Random random, int i); - - */ -/** + /** * The class of the root structure component to add to the village - *//* - + */ Class getComponentClass(); - */ -/** + /** * Build an instance of the village component {@link net.minecraft.world.gen.structure.StructureVillagePieces} * * @param villagePiece @@ -95,23 +94,21 @@ public class VillagerRegistry * @param p3 * @param facing * @param p5 - *//* - - Village buildComponent(StructureVillagePieces.PieceWeight villagePiece, StructureVillagePieces.Start startPiece, List pieces, Random random, int p1, + */ + Village buildComponent(VillagePieces.PieceWeight villagePiece, VillagePieces.Start startPiece, List pieces, Random random, int p1, int p2, int p3, EnumFacing facing, int p5); } -*/ + public static VillagerRegistry instance() { return INSTANCE; } -/** + /** * Register a new village creation handler * * @param handler - *//* - + */ public void registerVillageCreationHandler(IVillageCreationHandler handler) { villageCreationHandlers.put(handler.getComponentClass(), handler); @@ -119,19 +116,19 @@ public class VillagerRegistry public static void addExtraVillageComponents(List list, Random random, int i) { - List parts = list; + List parts = list; for (IVillageCreationHandler handler : instance().villageCreationHandlers.values()) { parts.add(handler.getVillagePieceWeight(random, i)); } } - public static Village getVillageComponent(StructureVillagePieces.PieceWeight villagePiece, StructureVillagePieces.Start startPiece, List pieces, Random random, + public static Village getVillageComponent(VillagePieces.PieceWeight villagePiece, VillagePieces.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); } -*/ + RegistryNamespaced REGISTRY = GameData.getWrapper(VillagerProfession.class); private void register(VillagerProfession prof, int id) diff --git a/src/main/resources/forge_at.cfg b/src/main/resources/forge_at.cfg index 4db11ee0e..a41a4dd5e 100644 --- a/src/main/resources/forge_at.cfg +++ b/src/main/resources/forge_at.cfg @@ -44,6 +44,8 @@ public net.minecraft.world.biome.Biome$BiomeProperties *() public+f net.minecraft.world.gen.structure.MapGenStronghold field_151546_e # MapGenVillage public-f net.minecraft.world.gen.structure.MapGenVillage field_75055_e #villageSpawnBiomes +# LayerUtil +public net.minecraft.world.gen.layer.LayerUtil func_202829_a(JLnet/minecraft/world/gen/layer/traits/IAreaTransformer1;Lnet/minecraft/world/gen/area/IAreaFactory;ILjava/util/function/LongFunction;)Lnet/minecraft/world/gen/area/IAreaFactory; # repeat # ShapedRecipes public+f net.minecraft.item.crafting.ShapedRecipes field_77574_d #recipeItems public+f net.minecraft.item.crafting.ShapedRecipes field_77576_b #recipeWidth