Add EMERALD and SILVERFISH to GenerateMinable event. Closes #1158

This commit is contained in:
LexManos 2015-12-10 02:16:58 -08:00
parent b9d1d92654
commit 2302963a9f
2 changed files with 59 additions and 8 deletions

View file

@ -1,11 +1,62 @@
--- ../src-base/minecraft/net/minecraft/world/biome/BiomeGenHills.java
+++ ../src-work/minecraft/net/minecraft/world/biome/BiomeGenHills.java
@@ -49,7 +49,7 @@
int i1 = p_180624_2_.nextInt(16);
BlockPos blockpos = p_180624_3_.func_177982_a(k, l, i1);
@@ -40,28 +40,20 @@
public void func_180624_a(World p_180624_1_, Random p_180624_2_, BlockPos p_180624_3_)
{
super.func_180624_a(p_180624_1_, p_180624_2_, p_180624_3_);
- int i = 3 + p_180624_2_.nextInt(6);
+ net.minecraftforge.common.MinecraftForge.ORE_GEN_BUS.post(new net.minecraftforge.event.terraingen.OreGenEvent.Pre(p_180624_1_, p_180624_2_, p_180624_3_));
+ WorldGenerator emeralds = new EmeraldGenerator();
+ if (net.minecraftforge.event.terraingen.TerrainGen.generateOre(p_180624_1_, p_180624_2_, emeralds, p_180624_3_, net.minecraftforge.event.terraingen.OreGenEvent.GenerateMinable.EventType.LAPIS))
+ emeralds.func_180709_b(p_180624_1_, p_180624_2_, p_180624_3_);
- for (int j = 0; j < i; ++j)
+ for (int i = 0; i < 7; ++i)
{
- int k = p_180624_2_.nextInt(16);
- int l = p_180624_2_.nextInt(28) + 4;
- int i1 = p_180624_2_.nextInt(16);
- BlockPos blockpos = p_180624_3_.func_177982_a(k, l, i1);
-
- if (p_180624_1_.func_180495_p(blockpos).func_177230_c() == Blocks.field_150348_b)
+ if (p_180624_1_.func_180495_p(blockpos).func_177230_c().isReplaceableOreGen(p_180624_1_, blockpos, net.minecraft.block.state.pattern.BlockHelper.func_177642_a(Blocks.field_150348_b)))
{
p_180624_1_.func_180501_a(blockpos, Blocks.field_150412_bA.func_176223_P(), 2);
}
- {
- p_180624_1_.func_180501_a(blockpos, Blocks.field_150412_bA.func_176223_P(), 2);
- }
- }
-
- for (i = 0; i < 7; ++i)
- {
int j1 = p_180624_2_.nextInt(16);
int k1 = p_180624_2_.nextInt(64);
int l1 = p_180624_2_.nextInt(16);
+ if (net.minecraftforge.event.terraingen.TerrainGen.generateOre(p_180624_1_, p_180624_2_, field_82915_S, p_180624_3_.func_177982_a(j1, k1, l1), net.minecraftforge.event.terraingen.OreGenEvent.GenerateMinable.EventType.SILVERFISH))
this.field_82915_S.func_180709_b(p_180624_1_, p_180624_2_, p_180624_3_.func_177982_a(j1, k1, l1));
}
+ net.minecraftforge.common.MinecraftForge.ORE_GEN_BUS.post(new net.minecraftforge.event.terraingen.OreGenEvent.Post(p_180624_1_, p_180624_2_, p_180624_3_));
}
public void func_180622_a(World p_180622_1_, Random p_180622_2_, ChunkPrimer p_180622_3_, int p_180622_4_, int p_180622_5_, double p_180622_6_)
@@ -97,4 +89,23 @@
{
return (new BiomeGenHills(p_180277_1_, false)).func_150633_b(this);
}
+
+ private static class EmeraldGenerator extends WorldGenerator
+ {
+ @Override
+ public boolean func_180709_b(World worldIn, Random rand, BlockPos pos)
+ {
+ int count = 3 + rand.nextInt(6);
+ for (int i = 0; i < count; i++)
+ {
+ BlockPos blockpos = pos.func_177982_a(rand.nextInt(16), rand.nextInt(28) + 4, rand.nextInt(16));
+
+ if (worldIn.func_180495_p(blockpos).func_177230_c().isReplaceableOreGen(worldIn, blockpos, net.minecraft.block.state.pattern.BlockHelper.func_177642_a(Blocks.field_150348_b)))
+ {
+ worldIn.func_180501_a(blockpos, Blocks.field_150412_bA.func_176223_P(), 2);
+ }
+ }
+ return true;
+ }
+ }
}

View file

@ -87,7 +87,7 @@ public class OreGenEvent extends Event
@HasResult
public static class GenerateMinable extends OreGenEvent
{
public static enum EventType { COAL, DIAMOND, DIRT, GOLD, GRAVEL, IRON, LAPIS, REDSTONE, QUARTZ, DIORITE, GRANITE, ANDESITE, CUSTOM }
public static enum EventType { COAL, DIAMOND, DIRT, GOLD, GRAVEL, IRON, LAPIS, REDSTONE, QUARTZ, DIORITE, GRANITE, ANDESITE, EMERALD, SILVERFISH, CUSTOM }
public final EventType type;
public final WorldGenerator generator;