Added World to ChunkProviderEvent.ReplaceBiomeBlocks, and exposed metadata to End and Nether generation events. Close #1201

This commit is contained in:
Lex Manos 2014-07-07 19:47:50 -07:00
parent 86ccfb1d68
commit f6471c3c08
4 changed files with 88 additions and 40 deletions

View File

@ -26,18 +26,39 @@
}
public void func_147420_a(int p_147420_1_, int p_147420_2_, Block[] p_147420_3_, BiomeGenBase[] p_147420_4_)
@@ -115,6 +127,10 @@
@@ -113,8 +125,17 @@
}
}
+ @Deprecated // Supply metadata to the below function.
public void func_147421_b(int p_147421_1_, int p_147421_2_, Block[] p_147421_3_, BiomeGenBase[] p_147421_4_)
{
+ ChunkProviderEvent.ReplaceBiomeBlocks event = new ChunkProviderEvent.ReplaceBiomeBlocks(this, p_147421_1_, p_147421_2_, p_147421_3_, p_147421_4_);
+ replaceBiomeBlocks(p_147421_1_, p_147421_2_, p_147421_3_, p_147421_4_, new byte[p_147421_3_.length]);
+ }
+ public void replaceBiomeBlocks(int p_147421_1_, int p_147421_2_, Block[] p_147421_3_, BiomeGenBase[] p_147421_4_, byte[] meta)
+ {
+ ChunkProviderEvent.ReplaceBiomeBlocks event = new ChunkProviderEvent.ReplaceBiomeBlocks(this, p_147421_1_, p_147421_2_, p_147421_3_, meta, p_147421_4_, this.field_73200_m);
+ MinecraftForge.EVENT_BUS.post(event);
+ if (event.getResult() == Result.DENY) return;
+
for (int k = 0; k < 16; ++k)
{
for (int l = 0; l < 16; ++l)
@@ -194,6 +210,10 @@
@@ -177,10 +198,11 @@
{
this.field_73204_i.setSeed((long)p_73154_1_ * 341873128712L + (long)p_73154_2_ * 132897987541L);
Block[] ablock = new Block[32768];
+ byte[] meta = new byte[ablock.length];
this.field_73198_o = this.field_73200_m.func_72959_q().func_76933_b(this.field_73198_o, p_73154_1_ * 16, p_73154_2_ * 16, 16, 16);
this.func_147420_a(p_73154_1_, p_73154_2_, ablock, this.field_73198_o);
- this.func_147421_b(p_73154_1_, p_73154_2_, ablock, this.field_73198_o);
- Chunk chunk = new Chunk(this.field_73200_m, ablock, p_73154_1_, p_73154_2_);
+ this.replaceBiomeBlocks(p_73154_1_, p_73154_2_, ablock, this.field_73198_o, meta);
+ Chunk chunk = new Chunk(this.field_73200_m, ablock, meta, p_73154_1_, p_73154_2_);
byte[] abyte = chunk.func_76605_m();
for (int k = 0; k < abyte.length; ++k)
@@ -194,6 +216,10 @@
private double[] func_73187_a(double[] p_73187_1_, int p_73187_2_, int p_73187_3_, int p_73187_4_, int p_73187_5_, int p_73187_6_, int p_73187_7_)
{
@ -48,7 +69,7 @@
if (p_73187_1_ == null)
{
p_73187_1_ = new double[p_73187_5_ * p_73187_6_ * p_73187_7_];
@@ -335,10 +355,16 @@
@@ -335,10 +361,16 @@
public void func_73153_a(IChunkProvider p_73153_1_, int p_73153_2_, int p_73153_3_)
{
BlockFalling.field_149832_M = true;

View File

@ -24,7 +24,7 @@
+ field_73223_w = (MapGenMineshaft) TerrainGen.getModdedMapGen(field_73223_w, MINESHAFT);
+ field_73233_x = (MapGenScatteredFeature) TerrainGen.getModdedMapGen(field_73233_x, SCATTERED_FEATURE);
+ field_73232_y = TerrainGen.getModdedMapGen(field_73232_y, RAVINE);
+ }
+ }
+
public ChunkProviderGenerate(World p_i2006_1_, long p_i2006_2_, boolean p_i2006_4_)
{
@ -50,7 +50,7 @@
public void func_147422_a(int p_147422_1_, int p_147422_2_, Block[] p_147422_3_, byte[] p_147422_4_, BiomeGenBase[] p_147422_5_)
{
+ ChunkProviderEvent.ReplaceBiomeBlocks event = new ChunkProviderEvent.ReplaceBiomeBlocks(this, p_147422_1_, p_147422_2_, p_147422_3_, p_147422_4_, p_147422_5_);
+ ChunkProviderEvent.ReplaceBiomeBlocks event = new ChunkProviderEvent.ReplaceBiomeBlocks(this, p_147422_1_, p_147422_2_, p_147422_3_, p_147422_4_, p_147422_5_, this.field_73230_p);
+ MinecraftForge.EVENT_BUS.post(event);
+ if (event.getResult() == Result.DENY) return;
+

View File

@ -44,18 +44,42 @@
}
public void func_147419_a(int p_147419_1_, int p_147419_2_, Block[] p_147419_3_)
@@ -134,6 +157,10 @@
@@ -132,8 +155,17 @@
}
}
+ @Deprecated //You should provide meatadata and biome data in the below method
public void func_147418_b(int p_147418_1_, int p_147418_2_, Block[] p_147418_3_)
{
+ ChunkProviderEvent.ReplaceBiomeBlocks event = new ChunkProviderEvent.ReplaceBiomeBlocks(this, p_147418_1_, p_147418_2_, p_147418_3_, null);
+ replaceBiomeBlocks(p_147418_1_, p_147418_2_, p_147418_3_, new byte[p_147418_3_.length], null);
+ }
+ public void replaceBiomeBlocks(int p_147418_1_, int p_147418_2_, Block[] p_147418_3_, byte[] meta, BiomeGenBase[] biomes)
+ {
+ ChunkProviderEvent.ReplaceBiomeBlocks event = new ChunkProviderEvent.ReplaceBiomeBlocks(this, p_147418_1_, p_147418_2_, p_147418_3_, meta, biomes, this.field_73175_o);
+ MinecraftForge.EVENT_BUS.post(event);
+ if (event.getResult() == Result.DENY) return;
+
byte b0 = 64;
double d0 = 0.03125D;
this.field_73185_q = this.field_73177_m.func_76304_a(this.field_73185_q, p_147418_1_ * 16, p_147418_2_ * 16, 0, 16, 16, 1, d0, d0, 1.0D);
@@ -253,6 +280,10 @@
@@ -234,12 +266,13 @@
{
this.field_73181_i.setSeed((long)p_73154_1_ * 341873128712L + (long)p_73154_2_ * 132897987541L);
Block[] ablock = new Block[32768];
+ byte[] meta = new byte[ablock.length];
+ BiomeGenBase[] abiomegenbase = this.field_73175_o.func_72959_q().func_76933_b((BiomeGenBase[])null, p_73154_1_ * 16, p_73154_2_ * 16, 16, 16); //Forge Move up to allow for passing to replaceBiomeBlocks
this.func_147419_a(p_73154_1_, p_73154_2_, ablock);
- this.func_147418_b(p_73154_1_, p_73154_2_, ablock);
+ this.replaceBiomeBlocks(p_73154_1_, p_73154_2_, ablock, meta, abiomegenbase);
this.field_73182_t.func_151539_a(this, this.field_73175_o, p_73154_1_, p_73154_2_, ablock);
this.field_73172_c.func_151539_a(this, this.field_73175_o, p_73154_1_, p_73154_2_, ablock);
- Chunk chunk = new Chunk(this.field_73175_o, ablock, p_73154_1_, p_73154_2_);
- BiomeGenBase[] abiomegenbase = this.field_73175_o.func_72959_q().func_76933_b((BiomeGenBase[])null, p_73154_1_ * 16, p_73154_2_ * 16, 16, 16);
+ Chunk chunk = new Chunk(this.field_73175_o, ablock, meta, p_73154_1_, p_73154_2_);
byte[] abyte = chunk.func_76605_m();
for (int k = 0; k < abyte.length; ++k)
@@ -253,6 +286,10 @@
private double[] func_73164_a(double[] p_73164_1_, int p_73164_2_, int p_73164_3_, int p_73164_4_, int p_73164_5_, int p_73164_6_, int p_73164_7_)
{
@ -66,7 +90,7 @@
if (p_73164_1_ == null)
{
p_73164_1_ = new double[p_73164_5_ * p_73164_6_ * p_73164_7_];
@@ -399,6 +430,9 @@
@@ -399,6 +436,9 @@
public void func_73153_a(IChunkProvider p_73153_1_, int p_73153_2_, int p_73153_3_)
{
BlockFalling.field_149832_M = true;
@ -76,7 +100,7 @@
int k = p_73153_2_ * 16;
int l = p_73153_3_ * 16;
this.field_73172_c.func_75051_a(this.field_73175_o, this.field_73181_i, p_73153_2_, p_73153_3_);
@@ -407,7 +441,8 @@
@@ -407,7 +447,8 @@
int k1;
int l1;
@ -86,7 +110,7 @@
{
j1 = k + this.field_73181_i.nextInt(16) + 8;
k1 = this.field_73181_i.nextInt(120) + 4;
@@ -418,7 +453,8 @@
@@ -418,7 +459,8 @@
i1 = this.field_73181_i.nextInt(this.field_73181_i.nextInt(10) + 1) + 1;
int i2;
@ -96,19 +120,17 @@
{
k1 = k + this.field_73181_i.nextInt(16) + 8;
l1 = this.field_73181_i.nextInt(120) + 4;
@@ -427,8 +463,9 @@
}
@@ -428,7 +470,8 @@
i1 = this.field_73181_i.nextInt(this.field_73181_i.nextInt(10) + 1);
-
- for (j1 = 0; j1 < i1; ++j1)
+
+ doGen = TerrainGen.populate(p_73153_1_, field_73175_o, field_73181_i, p_73153_2_, p_73153_3_, false, GLOWSTONE);
+ for (j1 = 0; doGen && j1 < i1; ++j1)
{
k1 = k + this.field_73181_i.nextInt(16) + 8;
l1 = this.field_73181_i.nextInt(120) + 4;
@@ -436,7 +473,7 @@
@@ -436,7 +479,7 @@
(new WorldGenGlowStone1()).func_76484_a(this.field_73175_o, this.field_73181_i, k1, l1, i2);
}
@ -117,7 +139,7 @@
{
k1 = k + this.field_73181_i.nextInt(16) + 8;
l1 = this.field_73181_i.nextInt(128);
@@ -444,7 +481,10 @@
@@ -444,7 +487,10 @@
(new WorldGenGlowStone2()).func_76484_a(this.field_73175_o, this.field_73181_i, k1, l1, i2);
}
@ -129,7 +151,7 @@
{
j1 = k + this.field_73181_i.nextInt(16) + 8;
k1 = this.field_73181_i.nextInt(128);
@@ -452,7 +492,7 @@
@@ -452,7 +498,7 @@
(new WorldGenFlowers(Blocks.field_150338_P)).func_76484_a(this.field_73175_o, this.field_73181_i, j1, k1, l1);
}
@ -138,7 +160,7 @@
{
j1 = k + this.field_73181_i.nextInt(16) + 8;
k1 = this.field_73181_i.nextInt(128);
@@ -463,7 +503,8 @@
@@ -463,7 +509,8 @@
WorldGenMinable worldgenminable = new WorldGenMinable(Blocks.field_150449_bY, 13, Blocks.field_150424_aL);
int j2;
@ -148,7 +170,7 @@
{
l1 = k + this.field_73181_i.nextInt(16);
i2 = this.field_73181_i.nextInt(108) + 10;
@@ -479,6 +520,9 @@
@@ -479,6 +526,9 @@
(new WorldGenHellLava(Blocks.field_150356_k, true)).func_76484_a(this.field_73175_o, this.field_73181_i, l1, i2, j2);
}

View File

@ -2,6 +2,7 @@ package net.minecraftforge.event.terraingen;
import cpw.mods.fml.common.eventhandler.Event;
import net.minecraft.block.Block;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraft.world.chunk.IChunkProvider;
@ -9,38 +10,41 @@ public class ChunkProviderEvent extends Event
{
public final IChunkProvider chunkProvider;
public ChunkProviderEvent(IChunkProvider chunkProvider)
{
this.chunkProvider = chunkProvider;
}
/**
* 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 ChunkProviderEvent
public static class ReplaceBiomeBlocks extends ChunkProviderEvent
{
public final int chunkX;
public final int chunkZ;
public final Block[] blockArray;
public final byte[] metaArray;
public final byte[] metaArray; // CAN BE NULL
public final BiomeGenBase[] biomeArray;
public final World world; // CAN BE NULL
@Deprecated // TODO: Remove in 1.8
public ReplaceBiomeBlocks(IChunkProvider chunkProvider, int chunkX, int chunkZ, Block[] blockArray, BiomeGenBase[] biomeArray)
{
super(chunkProvider);
this.chunkX = chunkX;
this.chunkZ = chunkZ;
this.blockArray = blockArray;
this.biomeArray = biomeArray;
metaArray = new byte[256];
this(chunkProvider, chunkX, chunkZ, blockArray, new byte[256], biomeArray, null);
}
@Deprecated // TODO: Remove in 1.8
public ReplaceBiomeBlocks(IChunkProvider chunkProvider, int chunkX, int chunkZ, Block[] blockArray, byte[] metaArray, BiomeGenBase[] biomeArray)
{
this(chunkProvider, chunkZ, chunkZ, blockArray, metaArray, biomeArray, null);
}
public ReplaceBiomeBlocks(IChunkProvider chunkProvider, int chunkX, int chunkZ, Block[] blockArray, byte[] metaArray, BiomeGenBase[] biomeArray, World world)
{
super(chunkProvider);
this.chunkX = chunkX;
@ -48,17 +52,18 @@ public class ChunkProviderEvent extends Event
this.blockArray = blockArray;
this.biomeArray = biomeArray;
this.metaArray = metaArray;
this.world = 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 ChunkProviderEvent
public static class InitNoiseField extends ChunkProviderEvent
{
public double[] noisefield;
public final int posX;
@ -67,7 +72,7 @@ public class ChunkProviderEvent extends Event
public final int sizeX;
public final int sizeY;
public final int sizeZ;
public InitNoiseField(IChunkProvider chunkProvider, double[] noisefield, int posX, int posY, int posZ, int sizeX, int sizeY, int sizeZ)
{
super(chunkProvider);
@ -79,6 +84,6 @@ public class ChunkProviderEvent extends Event
this.sizeY = sizeY;
this.sizeZ = sizeZ;
}
}
}