From 0ef6a00aa79f022e5bd56b3f77e6861bbecf6d94 Mon Sep 17 00:00:00 2001 From: OnyxDarkKnight Date: Thu, 13 Aug 2015 21:12:11 +0100 Subject: Added a new structure, a new curse, achievements, challenges, curses entry in the guide; reworked liquids to be tile entities, cleaned the structures code, potion code and... you know what? I improved and changed so much stuff that I literally forgot what I did... --- .../jewelrycraft/worldGen/Generation.java | 119 ++- .../jewelrycraft/worldGen/WorldGenStructure.java | 25 + .../jewelrycraft/worldGen/WorldGenStructure1.java | 2 +- .../jewelrycraft/worldGen/WorldGenStructure10.java | 29 - .../jewelrycraft/worldGen/WorldGenStructure11.java | 29 - .../jewelrycraft/worldGen/WorldGenStructure2.java | 20 +- .../jewelrycraft/worldGen/WorldGenStructure3.java | 4 +- .../jewelrycraft/worldGen/WorldGenStructure4.java | 6 +- .../jewelrycraft/worldGen/WorldGenStructure5.java | 29 +- .../jewelrycraft/worldGen/WorldGenStructure6.java | 93 ++- .../jewelrycraft/worldGen/WorldGenStructure7.java | 29 - .../jewelrycraft/worldGen/WorldGenStructure8.java | 29 - .../jewelrycraft/worldGen/WorldGenStructure9.java | 29 - .../worldGen/village/ComponentJewelry.java | 900 ++++++++++----------- .../jewelrycraft/worldGen/village/JCTrades.java | 2 +- .../worldGen/village/VillageHandler.java | 54 +- 16 files changed, 653 insertions(+), 746 deletions(-) create mode 100644 src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure.java delete mode 100644 src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure10.java delete mode 100644 src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure11.java delete mode 100644 src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure7.java delete mode 100644 src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure8.java delete mode 100644 src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure9.java (limited to 'src/main/java/darkknight/jewelrycraft/worldGen') diff --git a/src/main/java/darkknight/jewelrycraft/worldGen/Generation.java b/src/main/java/darkknight/jewelrycraft/worldGen/Generation.java index 3a81cfb..a6c49e8 100644 --- a/src/main/java/darkknight/jewelrycraft/worldGen/Generation.java +++ b/src/main/java/darkknight/jewelrycraft/worldGen/Generation.java @@ -1,28 +1,24 @@ package darkknight.jewelrycraft.worldGen; import java.util.Random; - +import cpw.mods.fml.common.IWorldGenerator; +import darkknight.jewelrycraft.block.BlockList; +import darkknight.jewelrycraft.config.ConfigHandler; +import net.minecraft.client.multiplayer.ChunkProviderClient; import net.minecraft.init.Blocks; import net.minecraft.world.World; import net.minecraft.world.biome.BiomeGenBase; import net.minecraft.world.chunk.IChunkProvider; -import cpw.mods.fml.common.IWorldGenerator; -import darkknight.jewelrycraft.block.BlockList; -import darkknight.jewelrycraft.config.ConfigHandler; +import net.minecraftforge.event.terraingen.ChunkProviderEvent; public class Generation implements IWorldGenerator { - public static WorldGenStructure1 STRUCTURE_1 = new WorldGenStructure1(); - public static WorldGenStructure2 STRUCTURE_2 = new WorldGenStructure2(); - public static WorldGenStructure3 STRUCTURE_3 = new WorldGenStructure3(); - public static WorldGenStructure4 STRUCTURE_4 = new WorldGenStructure4(); - public static WorldGenStructure5 STRUCTURE_5 = new WorldGenStructure5(); + public static WorldGenStructure STRUCTURE_1 = new WorldGenStructure1(); + public static WorldGenStructure STRUCTURE_2 = new WorldGenStructure2(); + public static WorldGenStructure STRUCTURE_3 = new WorldGenStructure3(); + public static WorldGenStructure STRUCTURE_4 = new WorldGenStructure4(); + public static WorldGenStructure STRUCTURE_5 = new WorldGenStructure5(); + public static WorldGenStructure STRUCTURE_6 = new WorldGenStructure6(); - // public static WorldGenerator STRUCTURE_6 = new WorldGenStructure6(); - // public static WorldGenerator STRUCTURE_7 = new WorldGenStructure7(); - // public static WorldGenerator STRUCTURE_8 = new WorldGenStructure8(); - // public static WorldGenerator STRUCTURE_9 = new WorldGenStructure9(); - // public static WorldGenerator STRUCTURE_10 = new WorldGenStructure10(); - // public static WorldGenerator STRUCTURE_11 = new WorldGenStructure11(); @Override public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) { switch (world.provider.dimensionId) { @@ -38,23 +34,22 @@ public class Generation implements IWorldGenerator { } } - private void generateEnd(World world, Random random, int i, int j) { - } + private void generateEnd(World world, Random random, int i, int j) {} private void generateSurface(World world, Random random, int i, int j) { if (ConfigHandler.ENABLE_WORLD_GEN) { - if(ConfigHandler.ORE_GEN) generateShadowOre(world, random, i, j); - if(ConfigHandler.CRYSTAL_GEN) generateCrystals(world, random, i, j); - if(ConfigHandler.STRUCTURE_1_GEN) generateStructure1(world, random, i, j); - if(ConfigHandler.STRUCTURE_2_GEN) generateStructure2(world, random, i, j); - if(ConfigHandler.STRUCTURE_3_GEN) generateStructure3(world, random, i, j); - if(ConfigHandler.STRUCTURE_4_GEN) generateStructure4(world, random, i, j); - if(ConfigHandler.STRUCTURE_5_GEN) generateStructure5(world, random, i, j); + if (ConfigHandler.ORE_GEN) generateShadowOre(world, random, i, j); + if (ConfigHandler.CRYSTAL_GEN) generateCrystals(world, random, i, j); + if (ConfigHandler.STRUCTURES[0]) generateStructureOverground(STRUCTURE_1, world, random, i, j, 1, false, true); + if (ConfigHandler.STRUCTURES[1]) generateStructureUnderground(STRUCTURE_2, world, random, i, j, 3, false, true); + if (ConfigHandler.STRUCTURES[2]) generateStructureUnderground(STRUCTURE_3, world, random, i, j, 3, false, true); + if (ConfigHandler.STRUCTURES[3]) generateStructureOverground(STRUCTURE_4, world, random, i, j, 5, false, true); + if (ConfigHandler.STRUCTURES[4]) generateStructureUnderground(STRUCTURE_5, world, random, i, j, 3, false, true); + if (ConfigHandler.STRUCTURES[5]) generateStructureOverground(STRUCTURE_6, world, random, i, j, 3, false, true); } } - private void generateNether(World world, Random random, int i, int j) { - } + private void generateNether(World world, Random random, int i, int j) {} private void generateShadowOre(World world, Random random, int i, int j) { for (int k = 0; k < 1; k++) { @@ -81,51 +76,47 @@ public class Generation implements IWorldGenerator { } } - private void generateStructure1(World world, Random random, int i, int j) { - BiomeGenBase biomeBase = world.getBiomeGenForCoords(i, j); - int x = i + random.nextInt(16); - int y = random.nextInt(100); - int z = j + random.nextInt(16); - if (world.getBlock(x, y, z) == Blocks.air && (world.getBlock(x, y - 1, z) == Blocks.stone || world.getBlock(x, y - 1, z) == Blocks.sand || world.getBlock(x, y - 1, z) == Blocks.grass)) STRUCTURE_1.generate(world, biomeBase, random, x, y, z); - } - - private void generateStructure2(World world, Random random, int i, int j) { + private void generateStructureUnderground(WorldGenStructure structure, World world, Random random, int i, int j, int maxAttempts, boolean noOfAttempts, boolean chanceOfSpawning) { BiomeGenBase biomeBase = world.getBiomeGenForCoords(i, j); - if (random.nextInt(3) == 0) { - int x = i + random.nextInt(16); - int y = random.nextInt(100); - int z = j + random.nextInt(16); - if (world.getBlock(x, y, z) == Blocks.stone) STRUCTURE_2.generate(world, biomeBase, random, x, y, z); + if (noOfAttempts) { + for (int k = 0; k < maxAttempts; k++) { + int x = i + random.nextInt(16); + int y = random.nextInt(64); + int z = j + random.nextInt(16); + if (world.getBlock(x, y, z) == Blocks.stone) structure.generate(world, biomeBase, random, x, y, z); + } } - } - - private void generateStructure3(World world, Random random, int i, int j) { - BiomeGenBase biomeBase = world.getBiomeGenForCoords(i, j); - if (random.nextInt(3) == 0) { - int x = i + random.nextInt(16); - int y = random.nextInt(100); - int z = j + random.nextInt(16); - if (world.getBlock(x, y, z) == Blocks.stone) STRUCTURE_3.generate(world, biomeBase, random, x, y, z); + else if (chanceOfSpawning) { + if (random.nextInt(maxAttempts) == 0) { + int x = i + random.nextInt(16); + int y = random.nextInt(64); + int z = j + random.nextInt(16); + if (world.getBlock(x, y, z) == Blocks.stone) structure.generate(world, biomeBase, random, x, y, z); + } } } - private void generateStructure4(World world, Random random, int i, int j) { + private void generateStructureOverground(WorldGenStructure structure, World world, Random random, int i, int j, int maxAttempts, boolean noOfAttempts, boolean chanceOfSpawning) { BiomeGenBase biomeBase = world.getBiomeGenForCoords(i, j); - if (random.nextInt(5) == 0) { - int x = i + random.nextInt(16); - int y = random.nextInt(100); - int z = j + random.nextInt(16); - if (world.getBlock(x, y, z) == Blocks.air && (world.getBlock(x, y - 1, z) == Blocks.stone || world.getBlock(x, y - 1, z) == Blocks.sand || world.getBlock(x, y - 1, z) == Blocks.grass)) STRUCTURE_4.generate(world, biomeBase, random, x, y, z); + if (noOfAttempts) { + for (int k = 0; k < maxAttempts; k++) { + int x = i + random.nextInt(16); + int y = (world.getChunkHeightMapMinimum(i, j) > 0 ? world.getChunkHeightMapMinimum(i, j): world.getChunkFromChunkCoords(i, j).heightMapMinimum - 16) + random.nextInt(4); + int z = j + random.nextInt(16); + if (world.getBlock(x, y, z) == Blocks.air && (world.getBlock(x, y - 1, z) == Blocks.stone || world.getBlock(x, y - 1, z) == Blocks.sand || world.getBlock(x, y - 1, z) == Blocks.grass)) structure.generate(world, biomeBase, random, x, y, z); + } } - } - - private void generateStructure5(World world, Random random, int i, int j) { - BiomeGenBase biomeBase = world.getBiomeGenForCoords(i, j); - if (random.nextInt(3) == 0) { - int x = i + random.nextInt(16); - int y = random.nextInt(100); - int z = j + random.nextInt(16); - if (world.getBlock(x, y, z) == Blocks.stone) STRUCTURE_5.generate(world, biomeBase, random, x, y, z); + else if (chanceOfSpawning) { + if (random.nextInt(maxAttempts) == 0) { + int x = i + random.nextInt(16); + int y = (world.getChunkHeightMapMinimum(i, j) > 0 ? world.getChunkHeightMapMinimum(i, j): world.getChunkFromChunkCoords(i, j).heightMapMinimum - 16) + random.nextInt(4); + int z = j + random.nextInt(16); + if (world.getBlock(x, y, z) == Blocks.air && (world.getBlock(x, y - 1, z) == Blocks.stone + || world.getBlock(x, y - 1, z) == Blocks.sand + || world.getBlock(x, y - 1, z) == Blocks.grass)){ structure.generate(world, biomeBase, random, x, y, z); + System.out.println(x + " " + z); + } + } } } } diff --git a/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure.java b/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure.java new file mode 100644 index 0000000..c2c4046 --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure.java @@ -0,0 +1,25 @@ +/** + * + */ +package darkknight.jewelrycraft.worldGen; + +import java.util.Random; +import net.minecraft.world.World; +import net.minecraft.world.biome.BiomeGenBase; +import net.minecraft.world.gen.feature.WorldGenerator; + +/** + * @author Sorin + */ +public class WorldGenStructure extends WorldGenerator +{ + public boolean generate(World world, BiomeGenBase biome, Random rand, int x, int y, int z) + { + return false; + } + + @Override + public boolean generate(World world, Random rand, int x, int y, int z) { + return false; + } +} diff --git a/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure1.java b/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure1.java index 5d9118f..c982e00 100644 --- a/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure1.java +++ b/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure1.java @@ -20,7 +20,7 @@ import darkknight.jewelrycraft.tileentity.TileEntityHandPedestal; /** * @author Sorin */ -public class WorldGenStructure1 extends WorldGenerator +public class WorldGenStructure1 extends WorldGenStructure { public static final WeightedRandomItem[] items = new WeightedRandomItem[]{new WeightedRandomItem(new ItemStack(ItemList.thiefGloves), 10), new WeightedRandomItem(new ItemStack(Items.golden_apple), 8), new WeightedRandomItem(new ItemStack(Items.golden_apple, 1, 1), 1), new WeightedRandomItem(new ItemStack(ItemList.guide), 20), new WeightedRandomItem(new ItemStack(ItemList.shadowIngot), 25), new WeightedRandomItem(new ItemStack(BlockList.shadowEye), 2), new WeightedRandomItem(new ItemStack(Items.nether_star), 1), new WeightedRandomItem(new ItemStack(BlockList.shadowBlock), 2), new WeightedRandomItem(new ItemStack(BlockList.crystal), 16, 20)}; diff --git a/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure10.java b/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure10.java deleted file mode 100644 index b838368..0000000 --- a/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure10.java +++ /dev/null @@ -1,29 +0,0 @@ -/** - * - */ -package darkknight.jewelrycraft.worldGen; - -import java.util.Random; -import net.minecraft.init.Blocks; -import net.minecraft.tileentity.TileEntityMobSpawner; -import net.minecraft.world.World; -import net.minecraft.world.biome.BiomeGenBase; -import net.minecraft.world.gen.feature.WorldGenerator; -import net.minecraftforge.common.DungeonHooks; - -/** - * @author Sorin - */ -public class WorldGenStructure10 extends WorldGenerator -{ - public boolean generate(World world, BiomeGenBase biome, Random rand, int x, int y, int z) - { - return true; - } - - @Override - public boolean generate(World world, Random rand, int x, int y, int z) - { - return generate(world, BiomeGenBase.plains, rand, x, y, z); - } -} diff --git a/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure11.java b/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure11.java deleted file mode 100644 index cfe84fb..0000000 --- a/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure11.java +++ /dev/null @@ -1,29 +0,0 @@ -/** - * - */ -package darkknight.jewelrycraft.worldGen; - -import java.util.Random; -import net.minecraft.init.Blocks; -import net.minecraft.tileentity.TileEntityMobSpawner; -import net.minecraft.world.World; -import net.minecraft.world.biome.BiomeGenBase; -import net.minecraft.world.gen.feature.WorldGenerator; -import net.minecraftforge.common.DungeonHooks; - -/** - * @author Sorin - */ -public class WorldGenStructure11 extends WorldGenerator -{ - public boolean generate(World world, BiomeGenBase biome, Random rand, int x, int y, int z) - { - return true; - } - - @Override - public boolean generate(World world, Random rand, int x, int y, int z) - { - return generate(world, BiomeGenBase.plains, rand, x, y, z); - } -} diff --git a/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure2.java b/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure2.java index fbed30c..c58c0b8 100644 --- a/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure2.java +++ b/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure2.java @@ -1,26 +1,21 @@ package darkknight.jewelrycraft.worldGen; -import java.io.IOException; import java.util.Random; +import darkknight.jewelrycraft.block.BlockList; +import darkknight.jewelrycraft.block.BlockMoltenMetal; +import darkknight.jewelrycraft.item.ItemList; +import darkknight.jewelrycraft.util.JewelryNBT; +import darkknight.jewelrycraft.util.JewelrycraftUtil; import net.minecraft.block.Block; import net.minecraft.init.Blocks; -import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.world.World; import net.minecraft.world.biome.BiomeGenBase; -import net.minecraft.world.gen.feature.WorldGenerator; -import darkknight.jewelrycraft.JewelrycraftMod; -import darkknight.jewelrycraft.block.BlockList; -import darkknight.jewelrycraft.item.ItemList; -import darkknight.jewelrycraft.item.ItemMoltenMetalBucket; -import darkknight.jewelrycraft.network.PacketSendLiquidData; -import darkknight.jewelrycraft.util.JewelryNBT; -import darkknight.jewelrycraft.util.JewelrycraftUtil; /** * @author Sorin */ -public class WorldGenStructure2 extends WorldGenerator { +public class WorldGenStructure2 extends WorldGenStructure { public boolean generate(World world, BiomeGenBase biome, Random rand, int x, int y, int z) { Block block = Blocks.stonebrick; Block stair = Blocks.stone_brick_stairs; @@ -47,9 +42,8 @@ public class WorldGenStructure2 extends WorldGenerator { JewelryNBT.addMetal(stack, JewelrycraftUtil.metal.get(rand.nextInt(JewelrycraftUtil.metal.size()))); if (stack != null && JewelryNBT.ingot(stack) != null) { if (!world.isRemote) world.func_147480_a(x, y, z, true); - JewelrycraftMod.saveData.setString(x + " " + y + " " + z + " " + world.provider.dimensionId, Item.getIdFromItem(JewelryNBT.ingot(stack).getItem()) + ":" + JewelryNBT.ingot(stack).getItemDamage()); - JewelrycraftMod.netWrapper.sendToAll(new PacketSendLiquidData(world.provider.dimensionId, x, y, z, Item.getIdFromItem(JewelryNBT.ingot(stack).getItem()), JewelryNBT.ingot(stack).getItemDamage())); world.setBlock(x, y, z, BlockList.moltenMetal, 0, 3); + if(BlockMoltenMetal.getTileEntity(world, x, y, z) != null) BlockMoltenMetal.getTileEntity(world, x, y, z).setMetal(JewelryNBT.ingot(stack)); } return true; } diff --git a/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure3.java b/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure3.java index 7234aa9..1f6f15c 100644 --- a/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure3.java +++ b/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure3.java @@ -15,7 +15,7 @@ import net.minecraftforge.common.DungeonHooks; /** * @author Sorin */ -public class WorldGenStructure3 extends WorldGenerator +public class WorldGenStructure3 extends WorldGenStructure { public boolean generate(World world, BiomeGenBase biome, Random rand, int x, int y, int z) { @@ -49,7 +49,7 @@ public class WorldGenStructure3 extends WorldGenerator if (biome == BiomeGenBase.desert || biome == BiomeGenBase.desertHills) slabMeta = 1; for(int i = -1; i <= 1; i++) for(int k = -1; k <= 1; k++) - world.setBlock(x + i, y + 2, z + k, slab, slabMeta, 1); + world.setBlock(x + i, y + 2, z + k, slab, slabMeta, 2); world.setBlock(x, y, z, Blocks.mob_spawner); world.setBlock(x, y + 1, z, Blocks.mob_spawner); for(int l = 0; l < 2; l++){ diff --git a/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure4.java b/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure4.java index 4171438..6af8dc2 100644 --- a/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure4.java +++ b/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure4.java @@ -14,7 +14,7 @@ import darkknight.jewelrycraft.block.BlockList; /** * @author Sorin */ -public class WorldGenStructure4 extends WorldGenerator +public class WorldGenStructure4 extends WorldGenStructure { public boolean generate(World world, BiomeGenBase biome, Random rand, int x, int y, int z) { @@ -34,7 +34,7 @@ public class WorldGenStructure4 extends WorldGenerator world.setBlock(x + i, y + j, z + k, Blocks.air); for(int i = -1; i <= 1; i++) for(int k = -1; k <= 1; k++) - world.setBlock(x + i, y, z + k, Blocks.stone_slab, slabMeta, 1); + world.setBlock(x + i, y, z + k, Blocks.stone_slab, slabMeta, 2); world.setBlock(x, y, z, block, metadata, 2); world.setBlock(x, y, z - 1, stair, 3, 1); world.setBlock(x, y, z + 1, stair, 2, 1); @@ -49,7 +49,7 @@ public class WorldGenStructure4 extends WorldGenerator if (biome == BiomeGenBase.desert || biome == BiomeGenBase.desertHills) slabMeta = 1; for(int i = -1; i <= 1; i++) for(int k = -1; k <= 1; k++) - if (i == 0 || k == 0) world.setBlock(x + i, y + 2, z + k, Blocks.stone_slab, slabMeta, 1); + if (i == 0 || k == 0) world.setBlock(x + i, y + 2, z + k, Blocks.stone_slab, slabMeta, 2); world.setBlock(x, y + 2, z, block, metadata, 2); world.setBlock(x, y + 3, z, BlockList.crystal); return true; diff --git a/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure5.java b/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure5.java index 77ce6c1..7ede3ef 100644 --- a/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure5.java +++ b/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure5.java @@ -3,34 +3,22 @@ */ package darkknight.jewelrycraft.worldGen; -import java.io.IOException; import java.util.Random; - -import cpw.mods.fml.relauncher.Side; -import darkknight.jewelrycraft.JewelrycraftMod; import darkknight.jewelrycraft.block.BlockList; +import darkknight.jewelrycraft.block.BlockMoltenMetal; import darkknight.jewelrycraft.item.ItemList; -import darkknight.jewelrycraft.item.ItemMoltenMetalBucket; -import darkknight.jewelrycraft.network.PacketRequestLiquidData; -import darkknight.jewelrycraft.network.PacketSendLiquidData; import darkknight.jewelrycraft.util.JewelryNBT; -import darkknight.jewelrycraft.util.JewelrycraftUtil; import net.minecraft.block.Block; -import net.minecraft.client.Minecraft; import net.minecraft.init.Blocks; import net.minecraft.init.Items; -import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntityMobSpawner; import net.minecraft.world.World; import net.minecraft.world.biome.BiomeGenBase; -import net.minecraft.world.gen.feature.WorldGenerator; -import net.minecraftforge.common.DungeonHooks; /** * @author Sorin */ -public class WorldGenStructure5 extends WorldGenerator { +public class WorldGenStructure5 extends WorldGenStructure { public boolean generate(World world, BiomeGenBase biome, Random rand, int x, int y, int z) { Block slab = Blocks.stone_slab; Block stair = Blocks.stone_brick_stairs; @@ -51,13 +39,13 @@ public class WorldGenStructure5 extends WorldGenerator { world.setBlock(x + i, y, z + k, Blocks.air); for (int i = -2; i <= 2; i++) for (int k = -3; k <= -1; k++) - world.setBlock(x + i, y, z + k, block, metadata, 1); + world.setBlock(x + i, y, z + k, block, metadata, 2); for (int i = 1; i <= 2; i++) for (int k = -3; k <= -1; k++) - world.setBlock(x + i, y + 1, z + k, block, metadata, 1); + world.setBlock(x + i, y + 1, z + k, block, metadata, 2); for (int i = -5; i <= -3; i++) for (int k = -3; k <= 2; k++) - world.setBlock(x + i, y - 1, z + k, block, metadata, 1); + world.setBlock(x + i, y - 1, z + k, block, metadata, 2); for (int i = -5; i <= -3; i++) for (int k = -3; k <= 2; k++) if ((i != -4 || k <= -3 || k >= 2) && !(i == -3 && k == -2)) world.setBlock(x + i, y, z + k, slab, slabMeta, 2); @@ -72,17 +60,16 @@ public class WorldGenStructure5 extends WorldGenerator { world.setBlock(x + 1, y + 2, z - 3, slab, slabMeta, 2); world.setBlock(x + 1, y + 2, z - 1, slab, slabMeta, 2); for (int k = -3; k <= -1; k++) - world.setBlock(x + 2, y + 2, z + k, block, metadata, 1); + world.setBlock(x + 2, y + 2, z + k, block, metadata, 2); if (rand.nextInt(5) == 0) { ItemStack stack = new ItemStack(ItemList.bucket); JewelryNBT.addMetal(stack, new ItemStack(Items.gold_ingot)); if (stack != null && JewelryNBT.ingot(stack) != null) { if (!world.isRemote) world.func_147480_a(x, y, z, true); - JewelrycraftMod.saveData.setString((x + 1) + " " + (y + 2) + " " + (z - 2) + " " + world.provider.dimensionId, Item.getIdFromItem(JewelryNBT.ingot(stack).getItem()) + ":" + JewelryNBT.ingot(stack).getItemDamage()); - JewelrycraftMod.netWrapper.sendToAll(new PacketSendLiquidData(world.provider.dimensionId, x + 1, y + 2, z - 2, Item.getIdFromItem(JewelryNBT.ingot(stack).getItem()), JewelryNBT.ingot(stack).getItemDamage())); world.setBlock(x + 1, y + 2, z - 2, BlockList.moltenMetal, 0, 3); + if(BlockMoltenMetal.getTileEntity(world, x + 1, y + 2, z - 2) != null) BlockMoltenMetal.getTileEntity(world, x + 1, y + 2, z - 2).setMetal(JewelryNBT.ingot(stack)); } - } else if (rand.nextBoolean()) world.setBlock(x + 1, y + 2, z - 2, Blocks.lava, 0, 3); + } else world.setBlock(x + 1, y + 2, z - 2, Blocks.water, 0, 3); return true; } diff --git a/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure6.java b/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure6.java index 1755396..9df172d 100644 --- a/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure6.java +++ b/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure6.java @@ -4,26 +4,91 @@ package darkknight.jewelrycraft.worldGen; import java.util.Random; +import darkknight.jewelrycraft.block.BlockList; +import darkknight.jewelrycraft.item.ItemList; +import darkknight.jewelrycraft.random.WeightedRandomItem; +import darkknight.jewelrycraft.tileentity.TileEntityHandPedestal; +import darkknight.jewelrycraft.tileentity.TileEntityJewelrsCraftingTable; +import darkknight.jewelrycraft.util.JewelryNBT; +import darkknight.jewelrycraft.util.JewelrycraftUtil; +import net.minecraft.block.Block; +import net.minecraft.block.BlockSkull; import net.minecraft.init.Blocks; -import net.minecraft.tileentity.TileEntityMobSpawner; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.tileentity.TileEntitySkull; +import net.minecraft.util.MathHelper; +import net.minecraft.util.WeightedRandom; import net.minecraft.world.World; import net.minecraft.world.biome.BiomeGenBase; -import net.minecraft.world.gen.feature.WorldGenerator; -import net.minecraftforge.common.DungeonHooks; /** * @author Sorin */ -public class WorldGenStructure6 extends WorldGenerator -{ - public boolean generate(World world, BiomeGenBase biome, Random rand, int x, int y, int z) - { - return true; - } +public class WorldGenStructure6 extends WorldGenStructure { + public boolean generate(World world, BiomeGenBase biome, Random rand, int x, int y, int z) { + int randBlock, randBlockMeta; + Block block; + for (int i = -2; i <= 1; i++) + for (int j = -1; j <= 1; j++) + for (int k = -2; k <= 1; k++) + world.setBlock(x + i, y + j, z + k, Blocks.air); + for (int i = -2; i <= 1; i++) + for (int k = -2; k <= 1; k++) { + randBlock = rand.nextInt(4); + switch (randBlock) { + case 0: + block = Blocks.cobblestone; + randBlockMeta = 0; + break; + case 1: + block = Blocks.stonebrick; + randBlockMeta = 2; + break; + case 2: + block = Blocks.stonebrick; + randBlockMeta = 0; + break; + default: + block = Blocks.cobblestone; + randBlockMeta = 0; + break; + } + world.setBlock(x + i, y - 1, z + k, block, randBlockMeta, 2); + } + int crystalCol = rand.nextInt(15); + world.setBlock(x - 2, y, z - 2, BlockList.crystal, 0, 2); + world.setBlock(x - 2, y, z + 1, BlockList.crystal, 1 + crystalCol, 2); + world.setBlock(x + 1, y, z - 2, BlockList.crystal, 1 + crystalCol, 2); + world.setBlock(x + 1, y, z + 1, BlockList.crystal, 0, 2); + world.setBlock(x - 1, y, z - 1, Blocks.skull, 1, 2); + TileEntity tileentity = world.getTileEntity(x - 1, y, z - 1); + if (tileentity != null && tileentity instanceof TileEntitySkull) { + ((TileEntitySkull) tileentity).func_152107_a(rand.nextInt(50) == 0 ? 1 : 0); + ((TileEntitySkull) tileentity).func_145903_a(MathHelper.floor_double((double) (rand.nextInt(361) * 16.0F / 360.0F) + 0.5D) & 15); + ((BlockSkull) Blocks.skull).func_149965_a(world, x - 1, y, z - 1, (TileEntitySkull) tileentity); + } + world.setBlock(x + 1, y, z - 1, BlockList.jewelCraftingTable, 3, 2); + TileEntity jewelersTable = world.getTileEntity(x + 1, y, z - 1); + Item[] jewelry = new Item[] { ItemList.ring, ItemList.necklace, ItemList.bracelet, ItemList.earrings }; + if (jewelersTable != null && jewelersTable instanceof TileEntityJewelrsCraftingTable) { + if (rand.nextBoolean()) ((TileEntityJewelrsCraftingTable) jewelersTable).setGemItemStack(JewelrycraftUtil.gem.get(rand.nextInt(JewelrycraftUtil.gem.size()))); + else if (rand.nextBoolean()) { + ItemStack result = new ItemStack(jewelry[rand.nextInt(4)], 1, 0); + if (JewelrycraftUtil.metal.size() > 0) JewelryNBT.addMetal(result, JewelrycraftUtil.metal.get(rand.nextInt(JewelrycraftUtil.metal.size()))); + ((TileEntityJewelrsCraftingTable) jewelersTable).setJewelryItemStack(result); + } + } + world.setBlock(x - 1, y, z + 1, BlockList.handPedestal, 0, 2); + TileEntity pedestal = world.getTileEntity(x - 1, y, z + 1); + if (pedestal != null && pedestal instanceof TileEntityHandPedestal) ((TileEntityHandPedestal) pedestal).setHeldItemStack(((WeightedRandomItem) WeightedRandom.getRandomItem(rand, WorldGenStructure1.items)).getItem(rand)); + world.setBlock(x - 1, y + 1, z + 1, BlockList.shadowEye, 0, 2); + return true; + } - @Override - public boolean generate(World world, Random rand, int x, int y, int z) - { - return generate(world, BiomeGenBase.plains, rand, x, y, z); - } + @Override + public boolean generate(World world, Random rand, int x, int y, int z) { + return generate(world, BiomeGenBase.plains, rand, x, y, z); + } } diff --git a/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure7.java b/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure7.java deleted file mode 100644 index 964e8e6..0000000 --- a/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure7.java +++ /dev/null @@ -1,29 +0,0 @@ -/** - * - */ -package darkknight.jewelrycraft.worldGen; - -import java.util.Random; -import net.minecraft.init.Blocks; -import net.minecraft.tileentity.TileEntityMobSpawner; -import net.minecraft.world.World; -import net.minecraft.world.biome.BiomeGenBase; -import net.minecraft.world.gen.feature.WorldGenerator; -import net.minecraftforge.common.DungeonHooks; - -/** - * @author Sorin - */ -public class WorldGenStructure7 extends WorldGenerator -{ - public boolean generate(World world, BiomeGenBase biome, Random rand, int x, int y, int z) - { - return true; - } - - @Override - public boolean generate(World world, Random rand, int x, int y, int z) - { - return generate(world, BiomeGenBase.plains, rand, x, y, z); - } -} diff --git a/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure8.java b/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure8.java deleted file mode 100644 index 868b623..0000000 --- a/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure8.java +++ /dev/null @@ -1,29 +0,0 @@ -/** - * - */ -package darkknight.jewelrycraft.worldGen; - -import java.util.Random; -import net.minecraft.init.Blocks; -import net.minecraft.tileentity.TileEntityMobSpawner; -import net.minecraft.world.World; -import net.minecraft.world.biome.BiomeGenBase; -import net.minecraft.world.gen.feature.WorldGenerator; -import net.minecraftforge.common.DungeonHooks; - -/** - * @author Sorin - */ -public class WorldGenStructure8 extends WorldGenerator -{ - public boolean generate(World world, BiomeGenBase biome, Random rand, int x, int y, int z) - { - return true; - } - - @Override - public boolean generate(World world, Random rand, int x, int y, int z) - { - return generate(world, BiomeGenBase.plains, rand, x, y, z); - } -} diff --git a/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure9.java b/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure9.java deleted file mode 100644 index e349ac6..0000000 --- a/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure9.java +++ /dev/null @@ -1,29 +0,0 @@ -/** - * - */ -package darkknight.jewelrycraft.worldGen; - -import java.util.Random; -import net.minecraft.init.Blocks; -import net.minecraft.tileentity.TileEntityMobSpawner; -import net.minecraft.world.World; -import net.minecraft.world.biome.BiomeGenBase; -import net.minecraft.world.gen.feature.WorldGenerator; -import net.minecraftforge.common.DungeonHooks; - -/** - * @author Sorin - */ -public class WorldGenStructure9 extends WorldGenerator -{ - public boolean generate(World world, BiomeGenBase biome, Random rand, int x, int y, int z) - { - return true; - } - - @Override - public boolean generate(World world, Random rand, int x, int y, int z) - { - return generate(world, BiomeGenBase.plains, rand, x, y, z); - } -} diff --git a/src/main/java/darkknight/jewelrycraft/worldGen/village/ComponentJewelry.java b/src/main/java/darkknight/jewelrycraft/worldGen/village/ComponentJewelry.java index dfcdaba..bc676b7 100644 --- a/src/main/java/darkknight/jewelrycraft/worldGen/village/ComponentJewelry.java +++ b/src/main/java/darkknight/jewelrycraft/worldGen/village/ComponentJewelry.java @@ -1,456 +1,446 @@ -package darkknight.jewelrycraft.worldGen.village; - -import java.util.List; -import java.util.Random; -import net.minecraft.block.Block; -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntityChest; -import net.minecraft.tileentity.TileEntityFurnace; -import net.minecraft.util.StatCollector; -import net.minecraft.world.World; -import net.minecraft.world.gen.structure.StructureBoundingBox; -import net.minecraft.world.gen.structure.StructureComponent; -import net.minecraft.world.gen.structure.StructureVillagePieces; -import net.minecraft.world.gen.structure.StructureVillagePieces.Start; -import darkknight.jewelrycraft.block.BlockList; -import darkknight.jewelrycraft.config.ConfigHandler; -import darkknight.jewelrycraft.item.ItemList; -import darkknight.jewelrycraft.item.ItemMolds; -import darkknight.jewelrycraft.tileentity.TileEntityDisplayer; -import darkknight.jewelrycraft.tileentity.TileEntityMolder; -import darkknight.jewelrycraft.tileentity.TileEntitySmelter; -import darkknight.jewelrycraft.util.JewelryNBT; -import darkknight.jewelrycraft.util.JewelrycraftUtil; -import darkknight.jewelrycraft.util.Variables; - -public class ComponentJewelry extends StructureVillagePieces.House1 -{ - private int averageGroundLevel = -1; - - /** - * - */ - public ComponentJewelry() - {} - - /** - * @param par1ComponentVillageStartPiece - * @param par2 - * @param par3Random - * @param par4StructureBoundingBox - * @param par5 - */ - public ComponentJewelry(Start par1ComponentVillageStartPiece, int par2, Random par3Random, StructureBoundingBox par4StructureBoundingBox, int par5) - { - super(); - coordBaseMode = par5; - boundingBox = par4StructureBoundingBox; - } - - /** - * @param villagePiece - * @param pieces - * @param random - * @param p1 - * @param p2 - * @param p3 - * @param p4 - * @param p5 - * @return - */ - @SuppressWarnings ("rawtypes") - public static ComponentJewelry buildComponent(Start villagePiece, List pieces, Random random, int p1, int p2, int p3, int p4, int p5) - { - StructureBoundingBox structureboundingbox = StructureBoundingBox.getComponentToAddBoundingBox(p1, p2, p3, 0, 0, 0, 11, 5, 12, p4); - return canVillageGoDeeper(structureboundingbox) && StructureComponent.findIntersecting(pieces, structureboundingbox) == null ? new ComponentJewelry(villagePiece, p5, random, structureboundingbox, p4) : null; - } - - /** - * second Part of Structure generating, this for example places Spiderwebs, Mob Spawners, it closes Mineshafts at the end, it adds Fences... - * - * @param world - * @param random - * @param sbb - * @return - */ - @Override - public boolean addComponentParts(World world, Random random, StructureBoundingBox sbb) - { - if (averageGroundLevel < 0){ - averageGroundLevel = getAverageGroundLevel(world, sbb); - if (averageGroundLevel < 0) return true; - boundingBox.offset(0, averageGroundLevel - boundingBox.maxY + 3, 0); - } - /** - * arguments: (World worldObj, StructureBoundingBox structBB, int minX, int minY, int minZ, int maxX, int maxY, int maxZ, int placeBlockId, int replaceBlockId, boolean alwaysreplace) - */ - fillWithBlocks(world, sbb, 0, 0, 6, 10, 5, 11, Block.getBlockById(0), Block.getBlockById(0), false); - fillWithBlocks(world, sbb, 2, 0, 0, 8, 5, 5, Block.getBlockById(0), Block.getBlockById(0), false); - // Pillars - fillWithBlocks(world, sbb, 2, 0, 0, 2, 3, 0, Blocks.log, Blocks.log, false); - fillWithBlocks(world, sbb, 2, 0, 3, 2, 3, 3, Blocks.log, Blocks.log, false); - fillWithBlocks(world, sbb, 8, 0, 0, 8, 3, 0, Blocks.log, Blocks.log, false); - fillWithBlocks(world, sbb, 8, 0, 3, 8, 3, 3, Blocks.log, Blocks.log, false); - // Walls - fillWithBlocks(world, sbb, 2, 0, 1, 2, 3, 2, Blocks.planks, Blocks.planks, false); - fillWithBlocks(world, sbb, 2, 0, 4, 2, 3, 5, Blocks.planks, Blocks.planks, false); - fillWithBlocks(world, sbb, 8, 0, 1, 8, 3, 2, Blocks.planks, Blocks.planks, false); - fillWithBlocks(world, sbb, 8, 0, 4, 8, 3, 5, Blocks.planks, Blocks.planks, false); - fillWithBlocks(world, sbb, 3, 0, 0, 7, 3, 0, Blocks.planks, Blocks.planks, false); - fillWithBlocks(world, sbb, 0, 0, 6, 10, 3, 6, Blocks.cobblestone, Blocks.cobblestone, false); - fillWithBlocks(world, sbb, 0, 0, 11, 10, 3, 11, Blocks.cobblestone, Blocks.cobblestone, false); - fillWithBlocks(world, sbb, 0, 0, 6, 0, 3, 11, Blocks.cobblestone, Blocks.cobblestone, false); - fillWithBlocks(world, sbb, 10, 0, 6, 10, 3, 11, Blocks.cobblestone, Blocks.cobblestone, false); - // Roof - for(int i = 3; i <= 7; i++) - for(int j = 1; j <= 5; j++) - placeBlockAtCurrentPosition(world, Blocks.wooden_slab, 2, i, 4, j, sbb); - for(int i = 3; i <= 7; i++) - for(int j = 6; j <= 6; j++) - placeBlockAtCurrentPosition(world, Blocks.stone_slab, 0, i, 4, j, sbb); - for(int i = 1; i <= 9; i++) - for(int j = 7; j <= 10; j++) - placeBlockAtCurrentPosition(world, Blocks.stone_slab, 3, i, 4, j, sbb); - for(int i = 2; i <= 8; i++) - placeBlockAtCurrentPosition(world, Blocks.double_wooden_slab, 2, i, 4, 0, sbb); - for(int i = 1; i <= 5; i++){ - placeBlockAtCurrentPosition(world, Blocks.double_wooden_slab, 2, 2, 4, i, sbb); - placeBlockAtCurrentPosition(world, Blocks.double_wooden_slab, 2, 8, 4, i, sbb); - } - for(int i = 0; i <= 2; i++){ - placeBlockAtCurrentPosition(world, Blocks.double_stone_slab, 0, i, 4, 6, sbb); - placeBlockAtCurrentPosition(world, Blocks.double_stone_slab, 0, i + 8, 4, 6, sbb); - } - for(int i = 7; i <= 11; i++){ - placeBlockAtCurrentPosition(world, Blocks.double_stone_slab, 0, 0, 4, i, sbb); - placeBlockAtCurrentPosition(world, Blocks.double_stone_slab, 0, 10, 4, i, sbb); - } - for(int i = 0; i <= 10; i++) - placeBlockAtCurrentPosition(world, Blocks.double_stone_slab, 0, i, 4, 11, sbb); - // Base - for(int i = 2; i <= 8; i++) - for(int j = 0; j <= 5; j++) - placeBlockAtCurrentPosition(world, Blocks.planks, 1, i, 0, j, sbb); - fillWithBlocks(world, sbb, 0, 0, 6, 10, 0, 11, Blocks.stonebrick, Blocks.stonebrick, false); - for(int i = 6; i <= 10; i++) - placeBlockAtCurrentPosition(world, Blocks.double_stone_slab, 0, 5, 0, i, sbb); - for(int i = 7; i <= 10; i++){ - placeBlockAtCurrentPosition(world, Blocks.stonebrick, 3, 1, 0, i, sbb); - placeBlockAtCurrentPosition(world, Blocks.stonebrick, 3, 9, 0, i, sbb); - } - // Decorations - placeDoorAtCurrentPosition(world, sbb, random, 6, 1, 0, getMetadataWithOffset(Blocks.wooden_door, 1)); - placeDoorAtCurrentPosition(world, sbb, random, 5, 1, 6, getMetadataWithOffset(Blocks.wooden_door, 1)); - placeBlockAtCurrentPosition(world, Blocks.glass_pane, 0, 3, 2, 0, sbb); - placeBlockAtCurrentPosition(world, Blocks.glass_pane, 0, 4, 2, 0, sbb); - placeBlockAtCurrentPosition(world, Blocks.glass_pane, 0, 2, 2, 1, sbb); - placeBlockAtCurrentPosition(world, Blocks.glass_pane, 0, 2, 2, 2, sbb); - placeBlockAtCurrentPosition(world, Blocks.glass_pane, 0, 2, 2, 4, sbb); - placeBlockAtCurrentPosition(world, Blocks.glass_pane, 0, 2, 2, 5, sbb); - placeBlockAtCurrentPosition(world, Blocks.glass_pane, 0, 8, 2, 1, sbb); - placeBlockAtCurrentPosition(world, Blocks.glass_pane, 0, 8, 2, 2, sbb); - placeBlockAtCurrentPosition(world, Blocks.glass_pane, 0, 8, 2, 4, sbb); - placeBlockAtCurrentPosition(world, Blocks.glass_pane, 0, 8, 2, 5, sbb); - placeBlockAtCurrentPosition(world, Blocks.torch, 0, 6, 3, 1, sbb); - placeBlockAtCurrentPosition(world, Blocks.torch, 0, 3, 3, 3, sbb); - placeBlockAtCurrentPosition(world, Blocks.torch, 0, 7, 3, 3, sbb); - placeBlockAtCurrentPosition(world, Blocks.torch, 0, 5, 3, 5, sbb); - placeBlockAtCurrentPosition(world, Blocks.torch, 0, 5, 3, 7, sbb); - placeBlockAtCurrentPosition(world, Blocks.torch, 0, 5, 3, 10, sbb); - placeBlockAtCurrentPosition(world, Blocks.torch, 0, 1, 3, 8, sbb); - placeBlockAtCurrentPosition(world, Blocks.torch, 0, 1, 3, 9, sbb); - placeBlockAtCurrentPosition(world, Blocks.torch, 0, 9, 3, 8, sbb); - placeBlockAtCurrentPosition(world, Blocks.torch, 0, 9, 3, 9, sbb); - int bgCarpetColor = random.nextInt(16); - for(int i = 4; i <= 7; i++) - for(int j = 1; j <= 5; j++) - placeBlockAtCurrentPosition(world, Blocks.carpet, bgCarpetColor, i, 1, j, sbb); - generateChest(world, 3, 1, 1, 0, random, sbb, ConfigHandler.GEM_CHEST_MIN, ConfigHandler.GEM_CHEST_MAX); - generateDisplayer(world, 3, 1, 2, coordBaseMode == 0 || coordBaseMode == 2 ? 1 : 2, random, sbb); - placeBlockAtCurrentPosition(world, BlockList.jewelCraftingTable, coordBaseMode == 0 || coordBaseMode == 2 ? 1 : 2, 3, 1, 3, sbb); - generateDisplayer(world, 3, 1, 4, coordBaseMode == 0 || coordBaseMode == 2 ? 1 : 2, random, sbb); - generateChest(world, 3, 1, 5, 0, random, sbb, ConfigHandler.GEM_CHEST_MIN, ConfigHandler.GEM_CHEST_MAX); - generateFurnace(world, 1, 1, 7, 0, random, sbb, ConfigHandler.FURNACE_MIN_INGOT_STACK, ConfigHandler.FURNACE_MAX_INGOT_STACK, ConfigHandler.CAN_FURNACE_GENERATE_INGOTS); - generateFurnace(world, 1, 2, 7, 0, random, sbb, ConfigHandler.FURNACE_MIN_INGOT_STACK, ConfigHandler.FURNACE_MAX_INGOT_STACK, ConfigHandler.CAN_FURNACE_GENERATE_INGOTS); - generateFurnace(world, 1, 3, 7, 0, random, sbb, ConfigHandler.FURNACE_MIN_INGOT_STACK, ConfigHandler.FURNACE_MAX_INGOT_STACK, ConfigHandler.CAN_FURNACE_GENERATE_INGOTS); - generateFurnace(world, 1, 1, 10, 0, random, sbb, ConfigHandler.FURNACE_MIN_INGOT_STACK, ConfigHandler.FURNACE_MAX_INGOT_STACK, ConfigHandler.CAN_FURNACE_GENERATE_INGOTS); - generateFurnace(world, 1, 2, 10, 0, random, sbb, ConfigHandler.FURNACE_MIN_INGOT_STACK, ConfigHandler.FURNACE_MAX_INGOT_STACK, ConfigHandler.CAN_FURNACE_GENERATE_INGOTS); - generateFurnace(world, 1, 3, 10, 0, random, sbb, ConfigHandler.FURNACE_MIN_INGOT_STACK, ConfigHandler.FURNACE_MAX_INGOT_STACK, ConfigHandler.CAN_FURNACE_GENERATE_INGOTS); - generateSmelter(world, 1, 1, 8, coordBaseMode == 0 || coordBaseMode == 2 ? 1 : 2, random, sbb, random.nextBoolean()); - generateSmelter(world, 1, 1, 9, coordBaseMode == 0 || coordBaseMode == 2 ? 1 : 2, random, sbb, random.nextBoolean()); - generateMolder(world, 2, 1, 8, coordBaseMode == 0 || coordBaseMode == 2 ? 1 : 2, random, sbb, random.nextBoolean(), random.nextBoolean()); - generateMolder(world, 2, 1, 9, coordBaseMode == 0 || coordBaseMode == 2 ? 1 : 2, random, sbb, random.nextBoolean(), random.nextBoolean()); - if (random.nextBoolean()) generateIngotChest(world, 9, 1, 7, 0, random, sbb, ConfigHandler.INGOT_CHEST_MIN, ConfigHandler.INGOT_CHEST_MAX, Blocks.chest, ConfigHandler.INGOT_CHEST_MAX_STACK); - else generateOresChest(world, 9, 1, 7, 0, random, sbb, ConfigHandler.INGOT_CHEST_MIN, ConfigHandler.INGOT_CHEST_MAX, Blocks.chest, ConfigHandler.INGOT_CHEST_MAX_STACK); - if (random.nextBoolean()) generateIngotChest(world, 9, 1, 8, 0, random, sbb, ConfigHandler.INGOT_CHEST_MIN, ConfigHandler.INGOT_CHEST_MAX, Blocks.chest, ConfigHandler.INGOT_CHEST_MAX_STACK); - else generateOresChest(world, 9, 1, 8, 0, random, sbb, ConfigHandler.INGOT_CHEST_MIN, ConfigHandler.INGOT_CHEST_MAX, Blocks.chest, ConfigHandler.INGOT_CHEST_MAX_STACK); - if (random.nextBoolean()) generateIngotChest(world, 9, 1, 9, 0, random, sbb, ConfigHandler.INGOT_CHEST_MIN, ConfigHandler.INGOT_CHEST_MAX, Blocks.trapped_chest, ConfigHandler.INGOT_CHEST_MAX_STACK); - else generateOresChest(world, 9, 1, 9, 0, random, sbb, ConfigHandler.INGOT_CHEST_MIN, ConfigHandler.INGOT_CHEST_MAX, Blocks.trapped_chest, ConfigHandler.INGOT_CHEST_MAX_STACK); - if (random.nextBoolean()) generateIngotChest(world, 9, 1, 10, 0, random, sbb, ConfigHandler.INGOT_CHEST_MIN, ConfigHandler.INGOT_CHEST_MAX, Blocks.trapped_chest, ConfigHandler.INGOT_CHEST_MAX_STACK); - else generateOresChest(world, 9, 1, 10, 0, random, sbb, ConfigHandler.INGOT_CHEST_MIN, ConfigHandler.INGOT_CHEST_MAX, Blocks.trapped_chest, ConfigHandler.INGOT_CHEST_MAX_STACK); - for(int l = 0; l < 6; ++l) - for(int i1 = 2; i1 < 9; ++i1){ - clearCurrentPositionBlocksUpwards(world, i1, 9, l, sbb); - func_151554_b(world, Blocks.cobblestone, 0, i1, -1, l, sbb); - } - for(int l = 6; l < 12; ++l) - for(int i1 = 0; i1 < 11; ++i1){ - clearCurrentPositionBlocksUpwards(world, i1, 9, l, sbb); - func_151554_b(world, Blocks.cobblestone, 0, i1, -1, l, sbb); - } - spawnVillagers(world, sbb, 3, 1, 3, 1); - return true; - } - - /** - * @param world - * @param i - * @param j - * @param k - * @param metadata - * @param random - * @param sbb - * @param min - * @param max - */ - public void generateChest(World world, int i, int j, int k, int metadata, Random random, StructureBoundingBox sbb, int min, int max) - { - int i1 = getXWithOffset(i, k); - int j1 = getYWithOffset(j); - int k1 = getZWithOffset(i, k); - int t = random.nextInt(max - min + 1) + min; - placeBlockAtCurrentPosition(world, Blocks.chest, metadata, i, j, k, sbb); - TileEntityChest chest = (TileEntityChest)world.getTileEntity(i1, j1, k1); - while (chest != null && t > 0 && JewelrycraftUtil.gem.size() > 0){ - ItemStack jewels = JewelrycraftUtil.gem.get(random.nextInt(JewelrycraftUtil.gem.size())); - chest.func_145976_a(StatCollector.translateToLocal("jeweler." + Variables.MODID + ".jewelerchest")); - if (jewels.getItem() == Items.nether_star && ConfigHandler.GENERATE_VILLAGE_NETHERSTAR) chest.setInventorySlotContents(random.nextInt(chest.getSizeInventory()), jewels); - else if (random.nextBoolean() && jewels.getItem() != Items.nether_star) chest.setInventorySlotContents(random.nextInt(chest.getSizeInventory()), jewels); - t--; - } - } - - /** - * @param world - * @param i - * @param j - * @param k - * @param metadata - * @param random - * @param sbb - * @param min - * @param max - * @param chestB - * @param randomAmount - */ - public void generateIngotChest(World world, int i, int j, int k, int metadata, Random random, StructureBoundingBox sbb, int min, int max, Block chestB, int randomAmount) - { - int i1 = getXWithOffset(i, k); - int j1 = getYWithOffset(j); - int k1 = getZWithOffset(i, k); - int t = random.nextInt(max - min + 1) + min; - placeBlockAtCurrentPosition(world, chestB, metadata, i, j, k, sbb); - TileEntityChest chest = (TileEntityChest)world.getTileEntity(i1, j1, k1); - while (chest != null && t > 0 && JewelrycraftUtil.metal.size() > 0){ - chest.func_145976_a(StatCollector.translateToLocal("jeweler." + Variables.MODID + ".ingotchest")); - int metalID = random.nextInt(JewelrycraftUtil.metal.size()); - ItemStack metal = JewelrycraftUtil.metal.get(metalID).copy(); - metal.stackSize = 2 + random.nextInt(randomAmount); - if (random.nextBoolean()) chest.setInventorySlotContents(random.nextInt(chest.getSizeInventory()), metal); - t--; - } - } - - /** - * @param world - * @param i - * @param j - * @param k - * @param metadata - * @param random - * @param sbb - * @param min - * @param max - * @param chestB - * @param randomAmount - */ - public void generateOresChest(World world, int i, int j, int k, int metadata, Random random, StructureBoundingBox sbb, int min, int max, Block chestB, int randomAmount) - { - int i1 = getXWithOffset(i, k); - int j1 = getYWithOffset(j); - int k1 = getZWithOffset(i, k); - int t = random.nextInt(max - min + 1) + min; - placeBlockAtCurrentPosition(world, chestB, metadata, i, j, k, sbb); - TileEntityChest chest = (TileEntityChest)world.getTileEntity(i1, j1, k1); - while (chest != null && t > 0 && JewelrycraftUtil.ores.size() > 0){ - chest.func_145976_a(StatCollector.translateToLocal("jeweler." + Variables.MODID + ".orechest")); - int oreID = random.nextInt(JewelrycraftUtil.ores.size()); - ItemStack ores = JewelrycraftUtil.ores.get(oreID).copy(); - ores.stackSize = 2 + random.nextInt(randomAmount); - if (random.nextBoolean()) chest.setInventorySlotContents(random.nextInt(chest.getSizeInventory()), ores); - t--; - } - } - - /** - * @param world - * @param i - * @param j - * @param k - * @param metadata - * @param random - * @param sbb - */ - public void generateDisplayer(World world, int i, int j, int k, int metadata, Random random, StructureBoundingBox sbb) - { - int i1 = getXWithOffset(i, k); - int j1 = getYWithOffset(j); - int k1 = getZWithOffset(i, k); - placeBlockAtCurrentPosition(world, BlockList.displayer, metadata, i, j, k, sbb); - TileEntityDisplayer displayer = (TileEntityDisplayer)world.getTileEntity(i1, j1, k1); - if (displayer != null){ - Item[] jewels = {ItemList.ring, ItemList.necklace}; - ItemStack jewel = new ItemStack(jewels[random.nextInt(jewels.length)]); - if (JewelrycraftUtil.metal.size() > 0) JewelryNBT.addMetal(jewel, JewelrycraftUtil.metal.get(random.nextInt(JewelrycraftUtil.metal.size()))); - if (JewelrycraftUtil.objects.size() > 0) JewelryNBT.addModifiers(jewel, JewelrycraftUtil.addRandomModifiers(random.nextInt(4))); - if (JewelrycraftUtil.gem.size() > 0) JewelryNBT.addGem(jewel, JewelrycraftUtil.gem.get(random.nextInt(JewelrycraftUtil.gem.size()))); - displayer.object = jewel; - displayer.quantity = 1; - displayer.hasObject = true; - } - } - - /** - * @param world - * @param i - * @param j - * @param k - * @param metadata - * @param random - * @param sbb - * @param isEmpty - */ - public void generateSmelter(World world, int i, int j, int k, int metadata, Random random, StructureBoundingBox sbb, boolean isEmpty) - { - int i1 = getXWithOffset(i, k); - int j1 = getYWithOffset(j); - int k1 = getZWithOffset(i, k); - placeBlockAtCurrentPosition(world, BlockList.smelter, metadata, i, j, k, sbb); - TileEntitySmelter smelter = (TileEntitySmelter)world.getTileEntity(i1, j1, k1); - if (smelter != null && !isEmpty && JewelrycraftUtil.metal.size() > 0){ - int metal = random.nextInt(JewelrycraftUtil.metal.size()); - smelter.moltenMetal = JewelrycraftUtil.metal.get(metal).copy(); - smelter.hasMoltenMetal = true; - int quantity = random.nextInt(9); - switch(quantity) - { - case 0: - smelter.quantity = 0.1f; - case 1: - smelter.quantity = 0.2f; - case 2: - smelter.quantity = 0.3f; - case 3: - smelter.quantity = 0.4f; - case 4: - smelter.quantity = 0.5f; - case 5: - smelter.quantity = 0.6f; - case 6: - smelter.quantity = 0.7f; - case 7: - smelter.quantity = 0.8f; - case 8: - smelter.quantity = 0.9f; - default: - smelter.quantity = 0.1f; - } - } - } - - /** - * @param world - * @param i - * @param j - * @param k - * @param metadata - * @param random - * @param sbb - * @param hasMold - * @param hasStuff - */ - public void generateMolder(World world, int i, int j, int k, int metadata, Random random, StructureBoundingBox sbb, boolean hasMold, boolean hasStuff) - { - int i1 = getXWithOffset(i, k); - int j1 = getYWithOffset(j); - int k1 = getZWithOffset(i, k); - placeBlockAtCurrentPosition(world, BlockList.molder, metadata, i, j, k, sbb); - TileEntityMolder molder = (TileEntityMolder)world.getTileEntity(i1, j1, k1); - if (molder != null && !molder.hasMold) if (hasMold){ - int meta = random.nextInt(ItemMolds.moldsItemNames.length); - molder.mold = new ItemStack(ItemList.molds, 1, meta); - molder.hasMold = true; - if (hasStuff && JewelrycraftUtil.metal.size() > 0){ - ItemStack ring = new ItemStack(ItemList.ring); - JewelryNBT.addMetal(ring, JewelrycraftUtil.metal.get(random.nextInt(JewelrycraftUtil.metal.size())).copy()); - ItemStack necklace = new ItemStack(ItemList.necklace); - JewelryNBT.addMetal(necklace, JewelrycraftUtil.metal.get(random.nextInt(JewelrycraftUtil.metal.size())).copy()); - ItemStack bracelet = new ItemStack(ItemList.bracelet); - JewelryNBT.addMetal(bracelet, JewelrycraftUtil.metal.get(random.nextInt(JewelrycraftUtil.metal.size())).copy()); - ItemStack earrings = new ItemStack(ItemList.earrings); - JewelryNBT.addMetal(earrings, JewelrycraftUtil.metal.get(random.nextInt(JewelrycraftUtil.metal.size())).copy()); - if (meta == 0) molder.jewelBase = JewelrycraftUtil.metal.get(random.nextInt(JewelrycraftUtil.metal.size())); - else if (meta == 1) molder.jewelBase = ring; - else if (meta == 2) molder.jewelBase = necklace; - else if (meta == 3) molder.jewelBase = bracelet; - else if (meta == 4) molder.jewelBase = earrings; - molder.hasJewelBase = true; - } - } - } - - /** - * @param world - * @param i - * @param j - * @param k - * @param metadata - * @param random - * @param sbb - * @param min - * @param max - * @param hasMetal - */ - public void generateFurnace(World world, int i, int j, int k, int metadata, Random random, StructureBoundingBox sbb, int min, int max, boolean hasMetal) - { - int i1 = getXWithOffset(i, k); - int j1 = getYWithOffset(j); - int k1 = getZWithOffset(i, k); - placeBlockAtCurrentPosition(world, Blocks.furnace, metadata, i, j, k, sbb); - TileEntityFurnace furnace = (TileEntityFurnace)world.getTileEntity(i1, j1, k1); - if (furnace != null){ - if (random.nextBoolean()) furnace.setInventorySlotContents(1, new ItemStack(Items.coal, 1 + random.nextInt(16))); - if (hasMetal && JewelrycraftUtil.metal.size() > 0){ - int metalID = random.nextInt(JewelrycraftUtil.metal.size()); - ItemStack metal = JewelrycraftUtil.metal.get(metalID).copy(); - metal.stackSize = random.nextInt(max - min + 1) + min; - furnace.setInventorySlotContents(2, metal); - } - } - } - - /** - * Returns the villager type to spawn in this component, based on the number of villagers already spawned. - * - * @param par1 - * @return - */ - @Override - protected int getVillagerType(int par1) - { - return 3000; - } +package darkknight.jewelrycraft.worldGen.village; + +import java.util.List; +import java.util.Random; +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntityChest; +import net.minecraft.tileentity.TileEntityFurnace; +import net.minecraft.util.StatCollector; +import net.minecraft.world.World; +import net.minecraft.world.gen.structure.StructureBoundingBox; +import net.minecraft.world.gen.structure.StructureComponent; +import net.minecraft.world.gen.structure.StructureVillagePieces; +import net.minecraft.world.gen.structure.StructureVillagePieces.Start; +import darkknight.jewelrycraft.block.BlockList; +import darkknight.jewelrycraft.config.ConfigHandler; +import darkknight.jewelrycraft.item.ItemList; +import darkknight.jewelrycraft.item.ItemMolds; +import darkknight.jewelrycraft.tileentity.TileEntityDisplayer; +import darkknight.jewelrycraft.tileentity.TileEntityMolder; +import darkknight.jewelrycraft.tileentity.TileEntitySmelter; +import darkknight.jewelrycraft.util.JewelryNBT; +import darkknight.jewelrycraft.util.JewelrycraftUtil; +import darkknight.jewelrycraft.util.Variables; + +public class ComponentJewelry extends StructureVillagePieces.House1 { + private int averageGroundLevel = -1; + + /** + * + */ + public ComponentJewelry() { + } + + /** + * @param par1ComponentVillageStartPiece + * @param par2 + * @param par3Random + * @param par4StructureBoundingBox + * @param par5 + */ + public ComponentJewelry(Start par1ComponentVillageStartPiece, int par2, Random par3Random, StructureBoundingBox par4StructureBoundingBox, int par5) { + super(); + coordBaseMode = par5; + boundingBox = par4StructureBoundingBox; + } + + /** + * @param villagePiece + * @param pieces + * @param random + * @param p1 + * @param p2 + * @param p3 + * @param p4 + * @param p5 + * @return + */ + @SuppressWarnings("rawtypes") + public static ComponentJewelry buildComponent(Start villagePiece, List pieces, Random random, int p1, int p2, int p3, int p4, int p5) { + StructureBoundingBox structureboundingbox = StructureBoundingBox.getComponentToAddBoundingBox(p1, p2, p3, 0, 0, 0, 11, 5, 12, p4); + return canVillageGoDeeper(structureboundingbox) && StructureComponent.findIntersecting(pieces, structureboundingbox) == null ? new ComponentJewelry(villagePiece, p5, random, structureboundingbox, p4) : null; + } + + /** + * second Part of Structure generating, this for example places Spiderwebs, + * Mob Spawners, it closes Mineshafts at the end, it adds Fences... + * + * @param world + * @param random + * @param sbb + * @return + */ + @Override + public boolean addComponentParts(World world, Random random, StructureBoundingBox sbb) { + if (averageGroundLevel < 0) { + averageGroundLevel = getAverageGroundLevel(world, sbb); + if (averageGroundLevel < 0) return true; + boundingBox.offset(0, averageGroundLevel - boundingBox.maxY + 3, 0); + } + /** + * arguments: (World worldObj, StructureBoundingBox structBB, int minX, + * int minY, int minZ, int maxX, int maxY, int maxZ, int placeBlockId, + * int replaceBlockId, boolean alwaysreplace) + */ + fillWithBlocks(world, sbb, 0, 0, 6, 10, 5, 11, Block.getBlockById(0), Block.getBlockById(0), false); + fillWithBlocks(world, sbb, 2, 0, 0, 8, 5, 5, Block.getBlockById(0), Block.getBlockById(0), false); + // Pillars + fillWithBlocks(world, sbb, 2, 0, 0, 2, 3, 0, Blocks.log, Blocks.log, false); + fillWithBlocks(world, sbb, 2, 0, 3, 2, 3, 3, Blocks.log, Blocks.log, false); + fillWithBlocks(world, sbb, 8, 0, 0, 8, 3, 0, Blocks.log, Blocks.log, false); + fillWithBlocks(world, sbb, 8, 0, 3, 8, 3, 3, Blocks.log, Blocks.log, false); + // Walls + fillWithBlocks(world, sbb, 2, 0, 1, 2, 3, 2, Blocks.planks, Blocks.planks, false); + fillWithBlocks(world, sbb, 2, 0, 4, 2, 3, 5, Blocks.planks, Blocks.planks, false); + fillWithBlocks(world, sbb, 8, 0, 1, 8, 3, 2, Blocks.planks, Blocks.planks, false); + fillWithBlocks(world, sbb, 8, 0, 4, 8, 3, 5, Blocks.planks, Blocks.planks, false); + fillWithBlocks(world, sbb, 3, 0, 0, 7, 3, 0, Blocks.planks, Blocks.planks, false); + fillWithBlocks(world, sbb, 0, 0, 6, 10, 3, 6, Blocks.cobblestone, Blocks.cobblestone, false); + fillWithBlocks(world, sbb, 0, 0, 11, 10, 3, 11, Blocks.cobblestone, Blocks.cobblestone, false); + fillWithBlocks(world, sbb, 0, 0, 6, 0, 3, 11, Blocks.cobblestone, Blocks.cobblestone, false); + fillWithBlocks(world, sbb, 10, 0, 6, 10, 3, 11, Blocks.cobblestone, Blocks.cobblestone, false); + // Roof + for (int i = 3; i <= 7; i++) + for (int j = 1; j <= 5; j++) + placeBlockAtCurrentPosition(world, Blocks.wooden_slab, 2, i, 4, j, sbb); + for (int i = 3; i <= 7; i++) + for (int j = 6; j <= 6; j++) + placeBlockAtCurrentPosition(world, Blocks.stone_slab, 0, i, 4, j, sbb); + for (int i = 1; i <= 9; i++) + for (int j = 7; j <= 10; j++) + placeBlockAtCurrentPosition(world, Blocks.stone_slab, 3, i, 4, j, sbb); + for (int i = 2; i <= 8; i++) + placeBlockAtCurrentPosition(world, Blocks.double_wooden_slab, 2, i, 4, 0, sbb); + for (int i = 1; i <= 5; i++) { + placeBlockAtCurrentPosition(world, Blocks.double_wooden_slab, 2, 2, 4, i, sbb); + placeBlockAtCurrentPosition(world, Blocks.double_wooden_slab, 2, 8, 4, i, sbb); + } + for (int i = 0; i <= 2; i++) { + placeBlockAtCurrentPosition(world, Blocks.double_stone_slab, 0, i, 4, 6, sbb); + placeBlockAtCurrentPosition(world, Blocks.double_stone_slab, 0, i + 8, 4, 6, sbb); + } + for (int i = 7; i <= 11; i++) { + placeBlockAtCurrentPosition(world, Blocks.double_stone_slab, 0, 0, 4, i, sbb); + placeBlockAtCurrentPosition(world, Blocks.double_stone_slab, 0, 10, 4, i, sbb); + } + for (int i = 0; i <= 10; i++) + placeBlockAtCurrentPosition(world, Blocks.double_stone_slab, 0, i, 4, 11, sbb); + // Base + for (int i = 2; i <= 8; i++) + for (int j = 0; j <= 5; j++) + placeBlockAtCurrentPosition(world, Blocks.planks, 1, i, 0, j, sbb); + fillWithBlocks(world, sbb, 0, 0, 6, 10, 0, 11, Blocks.stonebrick, Blocks.stonebrick, false); + for (int i = 6; i <= 10; i++) + placeBlockAtCurrentPosition(world, Blocks.double_stone_slab, 0, 5, 0, i, sbb); + for (int i = 7; i <= 10; i++) { + placeBlockAtCurrentPosition(world, Blocks.stonebrick, 3, 1, 0, i, sbb); + placeBlockAtCurrentPosition(world, Blocks.stonebrick, 3, 9, 0, i, sbb); + } + // Decorations + placeDoorAtCurrentPosition(world, sbb, random, 6, 1, 0, getMetadataWithOffset(Blocks.wooden_door, 1)); + placeDoorAtCurrentPosition(world, sbb, random, 5, 1, 6, getMetadataWithOffset(Blocks.wooden_door, 1)); + placeBlockAtCurrentPosition(world, Blocks.glass_pane, 0, 3, 2, 0, sbb); + placeBlockAtCurrentPosition(world, Blocks.glass_pane, 0, 4, 2, 0, sbb); + placeBlockAtCurrentPosition(world, Blocks.glass_pane, 0, 2, 2, 1, sbb); + placeBlockAtCurrentPosition(world, Blocks.glass_pane, 0, 2, 2, 2, sbb); + placeBlockAtCurrentPosition(world, Blocks.glass_pane, 0, 2, 2, 4, sbb); + placeBlockAtCurrentPosition(world, Blocks.glass_pane, 0, 2, 2, 5, sbb); + placeBlockAtCurrentPosition(world, Blocks.glass_pane, 0, 8, 2, 1, sbb); + placeBlockAtCurrentPosition(world, Blocks.glass_pane, 0, 8, 2, 2, sbb); + placeBlockAtCurrentPosition(world, Blocks.glass_pane, 0, 8, 2, 4, sbb); + placeBlockAtCurrentPosition(world, Blocks.glass_pane, 0, 8, 2, 5, sbb); + placeBlockAtCurrentPosition(world, Blocks.torch, 0, 6, 3, 1, sbb); + placeBlockAtCurrentPosition(world, Blocks.torch, 0, 3, 3, 3, sbb); + placeBlockAtCurrentPosition(world, Blocks.torch, 0, 7, 3, 3, sbb); + placeBlockAtCurrentPosition(world, Blocks.torch, 0, 5, 3, 5, sbb); + placeBlockAtCurrentPosition(world, Blocks.torch, 0, 5, 3, 7, sbb); + placeBlockAtCurrentPosition(world, Blocks.torch, 0, 5, 3, 10, sbb); + placeBlockAtCurrentPosition(world, Blocks.torch, 0, 1, 3, 8, sbb); + placeBlockAtCurrentPosition(world, Blocks.torch, 0, 1, 3, 9, sbb); + placeBlockAtCurrentPosition(world, Blocks.torch, 0, 9, 3, 8, sbb); + placeBlockAtCurrentPosition(world, Blocks.torch, 0, 9, 3, 9, sbb); + int bgCarpetColor = random.nextInt(16); + for (int i = 4; i <= 7; i++) + for (int j = 1; j <= 5; j++) + placeBlockAtCurrentPosition(world, Blocks.carpet, bgCarpetColor, i, 1, j, sbb); + generateChest(world, 3, 1, 1, 0, random, sbb, ConfigHandler.GEM_CHEST_MIN, ConfigHandler.GEM_CHEST_MAX); + generateDisplayer(world, 3, 1, 2, coordBaseMode == 0 || coordBaseMode == 2 ? 1 : 2, random, sbb); + placeBlockAtCurrentPosition(world, BlockList.jewelCraftingTable, coordBaseMode == 0 || coordBaseMode == 2 ? 1 : 2, 3, 1, 3, sbb); + generateDisplayer(world, 3, 1, 4, coordBaseMode == 0 || coordBaseMode == 2 ? 1 : 2, random, sbb); + generateChest(world, 3, 1, 5, 0, random, sbb, ConfigHandler.GEM_CHEST_MIN, ConfigHandler.GEM_CHEST_MAX); + generateFurnace(world, 1, 1, 7, 0, random, sbb, ConfigHandler.FURNACE_MIN_INGOT_STACK, ConfigHandler.FURNACE_MAX_INGOT_STACK, ConfigHandler.CAN_FURNACE_GENERATE_INGOTS); + generateFurnace(world, 1, 2, 7, 0, random, sbb, ConfigHandler.FURNACE_MIN_INGOT_STACK, ConfigHandler.FURNACE_MAX_INGOT_STACK, ConfigHandler.CAN_FURNACE_GENERATE_INGOTS); + generateFurnace(world, 1, 3, 7, 0, random, sbb, ConfigHandler.FURNACE_MIN_INGOT_STACK, ConfigHandler.FURNACE_MAX_INGOT_STACK, ConfigHandler.CAN_FURNACE_GENERATE_INGOTS); + generateFurnace(world, 1, 1, 10, 0, random, sbb, ConfigHandler.FURNACE_MIN_INGOT_STACK, ConfigHandler.FURNACE_MAX_INGOT_STACK, ConfigHandler.CAN_FURNACE_GENERATE_INGOTS); + generateFurnace(world, 1, 2, 10, 0, random, sbb, ConfigHandler.FURNACE_MIN_INGOT_STACK, ConfigHandler.FURNACE_MAX_INGOT_STACK, ConfigHandler.CAN_FURNACE_GENERATE_INGOTS); + generateFurnace(world, 1, 3, 10, 0, random, sbb, ConfigHandler.FURNACE_MIN_INGOT_STACK, ConfigHandler.FURNACE_MAX_INGOT_STACK, ConfigHandler.CAN_FURNACE_GENERATE_INGOTS); + generateSmelter(world, 1, 1, 8, coordBaseMode == 0 || coordBaseMode == 2 ? 1 : 2, random, sbb, random.nextBoolean()); + generateSmelter(world, 1, 1, 9, coordBaseMode == 0 || coordBaseMode == 2 ? 1 : 2, random, sbb, random.nextBoolean()); + generateMolder(world, 2, 1, 8, coordBaseMode == 0 || coordBaseMode == 2 ? 1 : 2, random, sbb, random.nextBoolean(), random.nextBoolean()); + generateMolder(world, 2, 1, 9, coordBaseMode == 0 || coordBaseMode == 2 ? 1 : 2, random, sbb, random.nextBoolean(), random.nextBoolean()); + if (random.nextBoolean()) generateIngotChest(world, 9, 1, 7, 0, random, sbb, ConfigHandler.INGOT_CHEST_MIN, ConfigHandler.INGOT_CHEST_MAX, Blocks.chest, ConfigHandler.INGOT_CHEST_MAX_STACK); + else generateOresChest(world, 9, 1, 7, 0, random, sbb, ConfigHandler.INGOT_CHEST_MIN, ConfigHandler.INGOT_CHEST_MAX, Blocks.chest, ConfigHandler.INGOT_CHEST_MAX_STACK); + if (random.nextBoolean()) generateIngotChest(world, 9, 1, 8, 0, random, sbb, ConfigHandler.INGOT_CHEST_MIN, ConfigHandler.INGOT_CHEST_MAX, Blocks.chest, ConfigHandler.INGOT_CHEST_MAX_STACK); + else generateOresChest(world, 9, 1, 8, 0, random, sbb, ConfigHandler.INGOT_CHEST_MIN, ConfigHandler.INGOT_CHEST_MAX, Blocks.chest, ConfigHandler.INGOT_CHEST_MAX_STACK); + if (random.nextBoolean()) generateIngotChest(world, 9, 1, 9, 0, random, sbb, ConfigHandler.INGOT_CHEST_MIN, ConfigHandler.INGOT_CHEST_MAX, Blocks.trapped_chest, ConfigHandler.INGOT_CHEST_MAX_STACK); + else generateOresChest(world, 9, 1, 9, 0, random, sbb, ConfigHandler.INGOT_CHEST_MIN, ConfigHandler.INGOT_CHEST_MAX, Blocks.trapped_chest, ConfigHandler.INGOT_CHEST_MAX_STACK); + if (random.nextBoolean()) generateIngotChest(world, 9, 1, 10, 0, random, sbb, ConfigHandler.INGOT_CHEST_MIN, ConfigHandler.INGOT_CHEST_MAX, Blocks.trapped_chest, ConfigHandler.INGOT_CHEST_MAX_STACK); + else generateOresChest(world, 9, 1, 10, 0, random, sbb, ConfigHandler.INGOT_CHEST_MIN, ConfigHandler.INGOT_CHEST_MAX, Blocks.trapped_chest, ConfigHandler.INGOT_CHEST_MAX_STACK); + for (int l = 0; l < 6; ++l) + for (int i1 = 2; i1 < 9; ++i1) { + clearCurrentPositionBlocksUpwards(world, i1, 9, l, sbb); + func_151554_b(world, Blocks.cobblestone, 0, i1, -1, l, sbb); + } + for (int l = 6; l < 12; ++l) + for (int i1 = 0; i1 < 11; ++i1) { + clearCurrentPositionBlocksUpwards(world, i1, 9, l, sbb); + func_151554_b(world, Blocks.cobblestone, 0, i1, -1, l, sbb); + } + spawnVillagers(world, sbb, 3, 1, 3, 1); + return true; + } + + /** + * @param world + * @param i + * @param j + * @param k + * @param metadata + * @param random + * @param sbb + * @param min + * @param max + */ + public void generateChest(World world, int i, int j, int k, int metadata, Random random, StructureBoundingBox sbb, int min, int max) { + int i1 = getXWithOffset(i, k); + int j1 = getYWithOffset(j); + int k1 = getZWithOffset(i, k); + if (max >= min) { + int t = random.nextInt(max - min + 1) + min; + placeBlockAtCurrentPosition(world, Blocks.chest, metadata, i, j, k, sbb); + if (world.getTileEntity(i1, j1, k1) != null) { + TileEntityChest chest = (TileEntityChest) world.getTileEntity(i1, j1, k1); + while (chest != null && t > 0 && JewelrycraftUtil.gem.size() > 0) { + ItemStack jewels = JewelrycraftUtil.gem.get(random.nextInt(JewelrycraftUtil.gem.size())); + chest.func_145976_a(StatCollector.translateToLocal("jeweler." + Variables.MODID + ".jewelerchest")); + if (jewels.getItem() == Items.nether_star && ConfigHandler.GENERATE_VILLAGE_NETHERSTAR) chest.setInventorySlotContents(random.nextInt(chest.getSizeInventory()), jewels); + else if (random.nextBoolean() && jewels.getItem() != Items.nether_star) chest.setInventorySlotContents(random.nextInt(chest.getSizeInventory()), jewels); + t--; + } + } + } + } + + /** + * @param world + * @param i + * @param j + * @param k + * @param metadata + * @param random + * @param sbb + * @param min + * @param max + * @param chestB + * @param randomAmount + */ + public void generateIngotChest(World world, int i, int j, int k, int metadata, Random random, StructureBoundingBox sbb, int min, int max, Block chestB, int randomAmount) { + int i1 = getXWithOffset(i, k); + int j1 = getYWithOffset(j); + int k1 = getZWithOffset(i, k); + if (max >= min) { + int t = random.nextInt(max - min + 1) + min; + placeBlockAtCurrentPosition(world, chestB, metadata, i, j, k, sbb); + if (world.getTileEntity(i1, j1, k1) != null) { + TileEntityChest chest = (TileEntityChest) world.getTileEntity(i1, j1, k1); + while (chest != null && t > 0 && JewelrycraftUtil.metal.size() > 0) { + chest.func_145976_a(StatCollector.translateToLocal("jeweler." + Variables.MODID + ".ingotchest")); + int metalID = random.nextInt(JewelrycraftUtil.metal.size()); + ItemStack metal = JewelrycraftUtil.metal.get(metalID).copy(); + metal.stackSize = 2 + random.nextInt(randomAmount); + if (random.nextBoolean()) chest.setInventorySlotContents(random.nextInt(chest.getSizeInventory()), metal); + t--; + } + } + } + } + + /** + * @param world + * @param i + * @param j + * @param k + * @param metadata + * @param random + * @param sbb + * @param min + * @param max + * @param chestB + * @param randomAmount + */ + public void generateOresChest(World world, int i, int j, int k, int metadata, Random random, StructureBoundingBox sbb, int min, int max, Block chestB, int randomAmount) { + int i1 = getXWithOffset(i, k); + int j1 = getYWithOffset(j); + int k1 = getZWithOffset(i, k); + if (max >= min) { + int t = random.nextInt(max - min + 1) + min; + placeBlockAtCurrentPosition(world, chestB, metadata, i, j, k, sbb); + if (world.getTileEntity(i1, j1, k1) != null) { + TileEntityChest chest = (TileEntityChest) world.getTileEntity(i1, j1, k1); + while (chest != null && t > 0 && JewelrycraftUtil.ores.size() > 0) { + chest.func_145976_a(StatCollector.translateToLocal("jeweler." + Variables.MODID + ".orechest")); + int oreID = random.nextInt(JewelrycraftUtil.ores.size()); + ItemStack ores = JewelrycraftUtil.ores.get(oreID).copy(); + ores.stackSize = 2 + random.nextInt(randomAmount); + if (random.nextBoolean()) chest.setInventorySlotContents(random.nextInt(chest.getSizeInventory()), ores); + t--; + } + } + } + } + + /** + * @param world + * @param i + * @param j + * @param k + * @param metadata + * @param random + * @param sbb + */ + public void generateDisplayer(World world, int i, int j, int k, int metadata, Random random, StructureBoundingBox sbb) { + int i1 = getXWithOffset(i, k); + int j1 = getYWithOffset(j); + int k1 = getZWithOffset(i, k); + placeBlockAtCurrentPosition(world, BlockList.displayer, metadata, i, j, k, sbb); + if (world.getTileEntity(i1, j1, k1) != null) { + TileEntityDisplayer displayer = (TileEntityDisplayer) world.getTileEntity(i1, j1, k1); + if (displayer != null) { + Item[] jewels = { ItemList.ring, ItemList.necklace }; + ItemStack jewel = new ItemStack(jewels[random.nextInt(jewels.length)]); + if (JewelrycraftUtil.metal.size() > 0) JewelryNBT.addMetal(jewel, JewelrycraftUtil.metal.get(random.nextInt(JewelrycraftUtil.metal.size()))); + if (JewelrycraftUtil.objects.size() > 0) JewelryNBT.addModifiers(jewel, JewelrycraftUtil.addRandomModifiers(random.nextInt(4))); + if (JewelrycraftUtil.gem.size() > 0) JewelryNBT.addGem(jewel, JewelrycraftUtil.gem.get(random.nextInt(JewelrycraftUtil.gem.size()))); + displayer.object = jewel; + displayer.quantity = 1; + displayer.hasObject = true; + } + } + } + + /** + * @param world + * @param i + * @param j + * @param k + * @param metadata + * @param random + * @param sbb + * @param isEmpty + */ + public void generateSmelter(World world, int i, int j, int k, int metadata, Random random, StructureBoundingBox sbb, boolean isEmpty) { + int i1 = getXWithOffset(i, k); + int j1 = getYWithOffset(j); + int k1 = getZWithOffset(i, k); + placeBlockAtCurrentPosition(world, BlockList.smelter, metadata, i, j, k, sbb); + if (world.getTileEntity(i1, j1, k1) != null) { + TileEntitySmelter smelter = (TileEntitySmelter) world.getTileEntity(i1, j1, k1); + if (smelter != null && !isEmpty && JewelrycraftUtil.metal.size() > 0) { + int metal = random.nextInt(JewelrycraftUtil.metal.size()); + smelter.moltenMetal = JewelrycraftUtil.metal.get(metal).copy(); + smelter.hasMoltenMetal = random.nextBoolean(); + float quantity = random.nextFloat(); + if (smelter.hasMoltenMetal) smelter.quantity = quantity < 0.9F ? 0.1F + Math.round(quantity * 10) / 10 : Math.round(quantity * 10) / 10; + } + } + } + + /** + * @param world + * @param i + * @param j + * @param k + * @param metadata + * @param random + * @param sbb + * @param hasMold + * @param hasStuff + */ + public void generateMolder(World world, int i, int j, int k, int metadata, Random random, StructureBoundingBox sbb, boolean hasMold, boolean hasStuff) { + int i1 = getXWithOffset(i, k); + int j1 = getYWithOffset(j); + int k1 = getZWithOffset(i, k); + placeBlockAtCurrentPosition(world, BlockList.molder, metadata, i, j, k, sbb); + if (world.getTileEntity(i1, j1, k1) != null) { + TileEntityMolder molder = (TileEntityMolder) world.getTileEntity(i1, j1, k1); + if (molder != null && !molder.hasMold) if (hasMold) { + int meta = random.nextInt(ItemMolds.moldsItemNames.length); + molder.mold = new ItemStack(ItemList.molds, 1, meta); + molder.hasMold = true; + if (hasStuff && JewelrycraftUtil.metal.size() > 0) { + ItemStack ring = new ItemStack(ItemList.ring); + JewelryNBT.addMetal(ring, JewelrycraftUtil.metal.get(random.nextInt(JewelrycraftUtil.metal.size())).copy()); + ItemStack necklace = new ItemStack(ItemList.necklace); + JewelryNBT.addMetal(necklace, JewelrycraftUtil.metal.get(random.nextInt(JewelrycraftUtil.metal.size())).copy()); + ItemStack bracelet = new ItemStack(ItemList.bracelet); + JewelryNBT.addMetal(bracelet, JewelrycraftUtil.metal.get(random.nextInt(JewelrycraftUtil.metal.size())).copy()); + ItemStack earrings = new ItemStack(ItemList.earrings); + JewelryNBT.addMetal(earrings, JewelrycraftUtil.metal.get(random.nextInt(JewelrycraftUtil.metal.size())).copy()); + if (meta == 0) molder.jewelBase = JewelrycraftUtil.metal.get(random.nextInt(JewelrycraftUtil.metal.size())); + else if (meta == 1) molder.jewelBase = ring; + else if (meta == 2) molder.jewelBase = necklace; + else if (meta == 3) molder.jewelBase = bracelet; + else if (meta == 4) molder.jewelBase = earrings; + molder.hasJewelBase = true; + } + } + } + } + + /** + * @param world + * @param i + * @param j + * @param k + * @param metadata + * @param random + * @param sbb + * @param min + * @param max + * @param hasMetal + */ + public void generateFurnace(World world, int i, int j, int k, int metadata, Random random, StructureBoundingBox sbb, int min, int max, boolean hasMetal) { + int i1 = getXWithOffset(i, k); + int j1 = getYWithOffset(j); + int k1 = getZWithOffset(i, k); + placeBlockAtCurrentPosition(world, Blocks.furnace, metadata, i, j, k, sbb); + if (world.getTileEntity(i1, j1, k1) != null) { + TileEntityFurnace furnace = (TileEntityFurnace) world.getTileEntity(i1, j1, k1); + if (furnace != null) { + if (random.nextBoolean()) furnace.setInventorySlotContents(1, new ItemStack(Items.coal, 1 + random.nextInt(16))); + if (hasMetal && JewelrycraftUtil.metal.size() > 0) { + int metalID = random.nextInt(JewelrycraftUtil.metal.size()); + ItemStack metal = JewelrycraftUtil.metal.get(metalID).copy(); + metal.stackSize = random.nextInt(max - min + 1) + min; + furnace.setInventorySlotContents(2, metal); + } + } + } + } + + /** + * Returns the villager type to spawn in this component, based on the number + * of villagers already spawned. + * + * @param par1 + * @return + */ + @Override + protected int getVillagerType(int par1) { + return 3000; + } } \ No newline at end of file diff --git a/src/main/java/darkknight/jewelrycraft/worldGen/village/JCTrades.java b/src/main/java/darkknight/jewelrycraft/worldGen/village/JCTrades.java index a1b508b..3a31a8f 100644 --- a/src/main/java/darkknight/jewelrycraft/worldGen/village/JCTrades.java +++ b/src/main/java/darkknight/jewelrycraft/worldGen/village/JCTrades.java @@ -87,7 +87,7 @@ public class JCTrades implements IVillageTradeHandler result = JewelrycraftUtil.gem.get(end); result.stackSize = 1 + random.nextInt(JewelrycraftUtil.gem.size() - end); if (JewelrycraftUtil.gem.size() - 1 - end >= 1){ - int value = end; + int value = 1 + end; if (value > 64) value = 64; ingredient = new ItemStack(Items.emerald, 2 + random.nextInt(value)); if (random.nextBoolean()) ingredient2 = new ItemStack(Items.emerald, 2 + random.nextInt(value)); diff --git a/src/main/java/darkknight/jewelrycraft/worldGen/village/VillageHandler.java b/src/main/java/darkknight/jewelrycraft/worldGen/village/VillageHandler.java index 95d20ee..5ef855e 100644 --- a/src/main/java/darkknight/jewelrycraft/worldGen/village/VillageHandler.java +++ b/src/main/java/darkknight/jewelrycraft/worldGen/village/VillageHandler.java @@ -1,27 +1,27 @@ -/** - * - */ -package darkknight.jewelrycraft.worldGen.village; - -import java.io.IOException; -import net.minecraft.world.gen.structure.MapGenStructureIO; -import cpw.mods.fml.common.event.FMLPreInitializationEvent; -import cpw.mods.fml.common.registry.VillagerRegistry; -import darkknight.jewelrycraft.JewelrycraftMod; -import darkknight.jewelrycraft.util.Variables; - -public class VillageHandler -{ - public static void preInit(FMLPreInitializationEvent e) throws IOException - { - VillagerRegistry.instance().registerVillagerId(3000); - VillagerRegistry.instance().registerVillageTradeHandler(3000, new JCTrades()); - VillagerRegistry.instance().registerVillageCreationHandler(new VillageJewelryHandler()); - try{ - MapGenStructureIO.func_143031_a(ComponentJewelry.class, Variables.MODID + ":Jewelry"); - } - catch(Throwable e2){ - JewelrycraftMod.logger.severe("Error registering Jewelrycraft Structures with Vanilla Minecraft: this is expected in versions earlier than 1.7.10"); - } - } -} +/** + * + */ +package darkknight.jewelrycraft.worldGen.village; + +import java.io.IOException; +import net.minecraft.world.gen.structure.MapGenStructureIO; +import cpw.mods.fml.common.event.FMLPreInitializationEvent; +import cpw.mods.fml.common.registry.VillagerRegistry; +import darkknight.jewelrycraft.JewelrycraftMod; +import darkknight.jewelrycraft.util.Variables; + +public class VillageHandler +{ + public static void preInit(FMLPreInitializationEvent e) throws IOException + { + VillagerRegistry.instance().registerVillagerId(3000); + VillagerRegistry.instance().registerVillageTradeHandler(3000, new JCTrades()); + VillagerRegistry.instance().registerVillageCreationHandler(new VillageJewelryHandler()); + try{ + MapGenStructureIO.func_143031_a(ComponentJewelry.class, Variables.MODID + ":Jewelry"); + } + catch(Throwable e2){ + JewelrycraftMod.logger.error("Error registering Jewelrycraft Structures with Vanilla Minecraft: this is expected in versions earlier than 1.7.10"); + } + } +} -- cgit v1.2.3