From 9a4d1e95ea7784f0f98ea2913701a3a3c28aefaa Mon Sep 17 00:00:00 2001 From: bculkin2442 Date: Thu, 24 May 2018 16:03:42 -0400 Subject: Formatting pass --- .../worldGen/village/ComponentJewelry.java | 613 +++++++++++++-------- .../jewelrycraft/worldGen/village/JCTrades.java | 249 ++++++--- .../worldGen/village/VillageHandler.java | 7 +- .../worldGen/village/VillageJewelryHandler.java | 8 +- 4 files changed, 549 insertions(+), 328 deletions(-) (limited to 'src/main/java/darkknight/jewelrycraft/worldGen/village') diff --git a/src/main/java/darkknight/jewelrycraft/worldGen/village/ComponentJewelry.java b/src/main/java/darkknight/jewelrycraft/worldGen/village/ComponentJewelry.java index 00e074c..c5d0cc2 100755 --- a/src/main/java/darkknight/jewelrycraft/worldGen/village/ComponentJewelry.java +++ b/src/main/java/darkknight/jewelrycraft/worldGen/village/ComponentJewelry.java @@ -33,9 +33,10 @@ public class ComponentJewelry extends StructureVillagePieces.House1 { public ComponentJewelry() { } - public ComponentJewelry(Start par1ComponentVillageStartPiece, int par2, - Random par3Random, - StructureBoundingBox par4StructureBoundingBox, int par5) { + public ComponentJewelry(Start par1ComponentVillageStartPiece, + int par2, Random par3Random, + StructureBoundingBox par4StructureBoundingBox, + int par5) { super(); coordBaseMode = par5; boundingBox = par4StructureBoundingBox; @@ -43,16 +44,21 @@ public class ComponentJewelry extends StructureVillagePieces.House1 { @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); + 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, + && StructureComponent.findIntersecting( + pieces, structureboundingbox) == null - ? new ComponentJewelry(villagePiece, p5, - random, structureboundingbox, p4) + ? new ComponentJewelry( + villagePiece, + p5, + random, + structureboundingbox, + p4) : null; } @@ -60,15 +66,18 @@ public class ComponentJewelry extends StructureVillagePieces.House1 { public boolean addComponentParts(World world, Random random, StructureBoundingBox sbb) { if (averageGroundLevel < 0) { - averageGroundLevel = getAverageGroundLevel(world, sbb); + averageGroundLevel = getAverageGroundLevel(world, + sbb); if (averageGroundLevel < 0) return true; - boundingBox.offset(0, - averageGroundLevel - boundingBox.maxY + 3, 0); + boundingBox.offset(0, averageGroundLevel + - boundingBox.maxY + 3, 0); } 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), + 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, @@ -90,120 +99,163 @@ public class ComponentJewelry extends StructureVillagePieces.House1 { 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); + 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); + 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); + 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); + 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); + 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); + 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); + 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); + 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); + 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); + 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, + 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)); + 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); + 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); + 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); + 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); + 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); + coordBaseMode == 0 || coordBaseMode == 2 + ? 1 + : 2, + random, sbb); generateChest(world, 3, 1, 5, 0, random, sbb, - ConfigHandler.GEM_CHEST_MIN, ConfigHandler.GEM_CHEST_MAX); + 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, @@ -229,102 +281,128 @@ public class ComponentJewelry extends StructureVillagePieces.House1 { 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()); + 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()); + 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()); + 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()); + 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, + 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, + 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, + 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, + 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, + 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, + 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, + 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, + 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); + 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); + 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; } public void generateChest(World world, int i, int j, int k, - int metadata, Random random, StructureBoundingBox sbb, int min, - int max) { + 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); + placeBlockAtCurrentPosition(world, Blocks.chest, + metadata, i, j, k, sbb); if (world.getTileEntity(i1, j1, k1) != null) { - TileEntityChest chest = - (TileEntityChest) world.getTileEntity(i1, j1, k1); + 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")); + && 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()), + random.nextInt(chest + .getSizeInventory()), jewels); else if (random.nextBoolean() && jewels.getItem() != Items.nether_star) chest.setInventorySlotContents( - random.nextInt(chest.getSizeInventory()), + random.nextInt(chest + .getSizeInventory()), jewels); t--; } @@ -333,30 +411,38 @@ public class ComponentJewelry extends StructureVillagePieces.House1 { } 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 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); + placeBlockAtCurrentPosition(world, chestB, + metadata, i, j, k, sbb); if (world.getTileEntity(i1, j1, k1) != null) { - TileEntityChest chest = - (TileEntityChest) world.getTileEntity(i1, j1, k1); + 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); + && 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()), + random.nextInt(chest + .getSizeInventory()), metal); t--; } @@ -365,30 +451,37 @@ public class ComponentJewelry extends StructureVillagePieces.House1 { } 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 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); + placeBlockAtCurrentPosition(world, chestB, + metadata, i, j, k, sbb); if (world.getTileEntity(i1, j1, k1) != null) { - TileEntityChest chest = - (TileEntityChest) world.getTileEntity(i1, j1, k1); + 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); + && 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()), + random.nextInt(chest + .getSizeInventory()), ores); t--; } @@ -397,29 +490,40 @@ public class ComponentJewelry extends StructureVillagePieces.House1 { } public void generateDisplayer(World world, int i, int j, int k, - int metadata, Random random, StructureBoundingBox sbb) { + 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); + placeBlockAtCurrentPosition(world, BlockList.displayer, + metadata, i, j, k, sbb); if (world.getTileEntity(i1, j1, k1) != null) { - TileEntityDisplayer displayer = - (TileEntityDisplayer) world.getTileEntity(i1, j1, k1); + TileEntityDisplayer displayer = (TileEntityDisplayer) world + .getTileEntity(i1, j1, k1); if (displayer != null) { - Item[] jewels = { ItemList.ring, ItemList.necklace }; + Item[] jewels = { + ItemList.ring, + ItemList.necklace + }; ItemStack jewel = new ItemStack( - jewels[random.nextInt(jewels.length)]); + jewels[random.nextInt( + jewels.length)]); if (JewelrycraftUtil.metal.size() > 0) JewelryNBT.addMetal(jewel, - JewelrycraftUtil.metal.get(random.nextInt( - JewelrycraftUtil.metal.size()))); + JewelrycraftUtil.metal + .get(random.nextInt( + JewelrycraftUtil.metal + .size()))); if (JewelrycraftUtil.objects.size() > 0) - JewelryNBT.addModifiers(jewel, JewelrycraftUtil - .addRandomModifiers(random.nextInt(4))); + JewelryNBT.addModifiers(jewel, + JewelrycraftUtil.addRandomModifiers( + random.nextInt(4))); if (JewelrycraftUtil.gem.size() > 0) - JewelryNBT.addGem(jewel, JewelrycraftUtil.gem.get( - random.nextInt(JewelrycraftUtil.gem.size()))); + JewelryNBT.addGem(jewel, + JewelrycraftUtil.gem + .get(random.nextInt( + JewelrycraftUtil.gem + .size()))); displayer.object = jewel; displayer.quantity = 1; displayer.hasObject = true; @@ -428,76 +532,102 @@ public class ComponentJewelry extends StructureVillagePieces.House1 { } public void generateSmelter(World world, int i, int j, int k, - int metadata, Random random, StructureBoundingBox sbb, - boolean isEmpty) { + 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); + placeBlockAtCurrentPosition(world, BlockList.smelter, + metadata, i, j, k, sbb); if (world.getTileEntity(i1, j1, k1) != null) { - TileEntitySmelter smelter = - (TileEntitySmelter) world.getTileEntity(i1, j1, k1); + 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(); + && 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; + ? 0.1F + Math.round( + quantity * 10) + / 10 + : Math.round(quantity + * 10) + / 10; } } } public void generateMolder(World world, int i, int j, int k, - int metadata, Random random, StructureBoundingBox sbb, - boolean hasMold, boolean hasStuff) { + 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); + placeBlockAtCurrentPosition(world, BlockList.molder, + metadata, i, j, k, sbb); if (world.getTileEntity(i1, j1, k1) != null) { - TileEntityMolder molder = - (TileEntityMolder) world.getTileEntity(i1, j1, k1); + TileEntityMolder molder = (TileEntityMolder) world + .getTileEntity(i1, j1, k1); if (molder != null && !molder.hasMold) if (hasMold) { - int meta = random - .nextInt(ItemMolds.moldsItemNames.length - 1); - molder.mold = new ItemStack(ItemList.molds, 1, meta + 1); + int meta = random.nextInt( + ItemMolds.moldsItemNames.length + - 1); + molder.mold = new ItemStack( + ItemList.molds, 1, + meta + 1); molder.hasMold = true; - if (hasStuff && JewelrycraftUtil.metal.size() > 0) { - ItemStack ring = new ItemStack(ItemList.ring); + if (hasStuff && JewelrycraftUtil.metal + .size() > 0) { + ItemStack ring = new ItemStack( + ItemList.ring); JewelryNBT.addMetal(ring, - JewelrycraftUtil.metal.get(random.nextInt( - JewelrycraftUtil.metal.size())) + 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())) + 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())) + 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())) + 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())); + molder.jewelBase = JewelrycraftUtil.metal + .get(random.nextInt( + JewelrycraftUtil.metal + .size())); else if (meta == 1) molder.jewelBase = ring; else if (meta == 2) @@ -513,27 +643,36 @@ public class ComponentJewelry extends StructureVillagePieces.House1 { } public void generateFurnace(World world, int i, int j, int k, - int metadata, Random random, StructureBoundingBox sbb, int min, - int max, boolean hasMetal) { + 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); + placeBlockAtCurrentPosition(world, Blocks.furnace, + metadata, i, j, k, sbb); if (world.getTileEntity(i1, j1, k1) != null) { - TileEntityFurnace furnace = - (TileEntityFurnace) world.getTileEntity(i1, j1, k1); + 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); + 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); } } } diff --git a/src/main/java/darkknight/jewelrycraft/worldGen/village/JCTrades.java b/src/main/java/darkknight/jewelrycraft/worldGen/village/JCTrades.java index 68e0651..d905948 100755 --- a/src/main/java/darkknight/jewelrycraft/worldGen/village/JCTrades.java +++ b/src/main/java/darkknight/jewelrycraft/worldGen/village/JCTrades.java @@ -17,8 +17,10 @@ import net.minecraft.village.MerchantRecipe; import net.minecraft.village.MerchantRecipeList; public class JCTrades implements IVillageTradeHandler { - Item[] jewelry = new Item[] { ItemList.ring, ItemList.necklace, - ItemList.bracelet, ItemList.earrings }; + Item[] jewelry = new Item[] { + ItemList.ring, ItemList.necklace, + ItemList.bracelet, ItemList.earrings + }; public JCTrades() { super(); @@ -39,139 +41,218 @@ public class JCTrades implements IVillageTradeHandler { int type = random.nextInt(12); switch (type) { case 0: - if (JewelrycraftUtil.metal.size() > 0) { - result = JewelrycraftUtil.metal.get(random - .nextInt(JewelrycraftUtil.metal.size())); - result.stackSize = 5 + random.nextInt(5); - ingredient = new ItemStack(Items.emerald, - 2 + random.nextInt(7)); + if (JewelrycraftUtil.metal + .size() > 0) { + result = JewelrycraftUtil.metal + .get(random.nextInt( + JewelrycraftUtil.metal + .size())); + result.stackSize = 5 + + random.nextInt( + 5); + ingredient = new ItemStack( + Items.emerald, + 2 + random.nextInt( + 7)); if (random.nextBoolean()) - ingredient2 = new ItemStack(Items.emerald, - 2 + random.nextInt(2)); + ingredient2 = new ItemStack( + Items.emerald, + 2 + random.nextInt( + 2)); break; } case 1: { - result = new ItemStack(ItemList.molds, - 5 + random.nextInt(7), random.nextInt( - ItemMolds.moldsItemNames.length)); - ingredient = new ItemStack(Items.emerald, 1); + result = new ItemStack( + ItemList.molds, + 5 + random.nextInt( + 7), + random.nextInt(ItemMolds.moldsItemNames.length)); + ingredient = new ItemStack( + Items.emerald, 1); if (random.nextBoolean()) - ingredient2 = new ItemStack(Items.emerald, - 1 + random.nextInt(2)); + ingredient2 = new ItemStack( + Items.emerald, + 1 + random.nextInt( + 2)); break; } case 2: { int number = random.nextInt(3); - result = new ItemStack(BlockList.displayer, + result = new ItemStack( + BlockList.displayer, 1 + number); - ingredient = new ItemStack(Blocks.emerald_block, - 2 + number * 3 + random.nextInt(2)); - ingredient2 = new ItemStack(Items.emerald, - 3 + number + random.nextInt(8)); + ingredient = new ItemStack( + Blocks.emerald_block, + 2 + number * 3 + random + .nextInt(2)); + ingredient2 = new ItemStack( + Items.emerald, + 3 + number + random + .nextInt(8)); break; } case 3: { - result = new ItemStack(BlockList.jewelCraftingTable); - ingredient = new ItemStack(Items.emerald, - 1 + random.nextInt(2)); + result = new ItemStack( + BlockList.jewelCraftingTable); + ingredient = new ItemStack( + Items.emerald, + 1 + random.nextInt( + 2)); if (random.nextBoolean()) - ingredient2 = new ItemStack(Items.emerald, - 1 + random.nextInt(2)); + ingredient2 = new ItemStack( + Items.emerald, + 1 + random.nextInt( + 2)); break; } case 4: { - result = new ItemStack(BlockList.shadowOre, - 1 + random.nextInt(6)); - ingredient = new ItemStack(Items.emerald, - 3 + random.nextInt(4)); + result = new ItemStack( + BlockList.shadowOre, + 1 + random.nextInt( + 6)); + ingredient = new ItemStack( + Items.emerald, + 3 + random.nextInt( + 4)); if (random.nextBoolean()) - ingredient2 = new ItemStack(Items.emerald, - 3 + random.nextInt(4)); + ingredient2 = new ItemStack( + Items.emerald, + 3 + random.nextInt( + 4)); break; } case 5: { - result = new ItemStack(BlockList.molder, - 5 + random.nextInt(5)); - ingredient = new ItemStack(Items.emerald, 1); + result = new ItemStack( + BlockList.molder, + 5 + random.nextInt( + 5)); + ingredient = new ItemStack( + Items.emerald, 1); if (random.nextBoolean()) - ingredient2 = new ItemStack(Items.emerald, 1); + ingredient2 = new ItemStack( + Items.emerald, + 1); break; } case 6: { - result = new ItemStack(BlockList.smelter); - ingredient = new ItemStack(Items.emerald, - 1 + random.nextInt(2)); + result = new ItemStack( + BlockList.smelter); + ingredient = new ItemStack( + Items.emerald, + 1 + random.nextInt( + 2)); if (random.nextBoolean()) - ingredient2 = new ItemStack(Items.emerald, - 1 + random.nextInt(2)); + ingredient2 = new ItemStack( + Items.emerald, + 1 + random.nextInt( + 2)); break; } case 7: - if (JewelrycraftUtil.gem.size() > 0) { - int end = random - .nextInt(JewelrycraftUtil.gem.size()); - result = JewelrycraftUtil.gem.get(end); - result.stackSize = 1 + random.nextInt( - JewelrycraftUtil.gem.size() - end); - if (JewelrycraftUtil.gem.size() - 1 - end >= 1) { + if (JewelrycraftUtil.gem + .size() > 0) { + int end = random.nextInt( + JewelrycraftUtil.gem + .size()); + result = JewelrycraftUtil.gem + .get(end); + result.stackSize = 1 + + random.nextInt( + JewelrycraftUtil.gem + .size() + - end); + if (JewelrycraftUtil.gem + .size() - 1 + - end >= 1) { int value = 1 + end; if (value > 64) value = 64; - ingredient = new ItemStack(Items.emerald, - 2 + random.nextInt(value)); + ingredient = new ItemStack( + Items.emerald, + 2 + random.nextInt( + value)); if (random.nextBoolean()) - ingredient2 = new ItemStack(Items.emerald, - 2 + random.nextInt(value)); + ingredient2 = new ItemStack( + Items.emerald, + 2 + random.nextInt( + value)); } else { - ingredient = - new ItemStack(Blocks.emerald_block, - 16 + random.nextInt(32)); - ingredient2 = - new ItemStack(Blocks.emerald_block, - 8 + random.nextInt(48)); + ingredient = new ItemStack( + Blocks.emerald_block, + 16 + random.nextInt( + 32)); + ingredient2 = new ItemStack( + Blocks.emerald_block, + 8 + random.nextInt( + 48)); } break; } case 8: - if (JewelrycraftUtil.ores.size() > 0) { - result = JewelrycraftUtil.ores.get(random - .nextInt(JewelrycraftUtil.ores.size())); - result.stackSize = 3 + random.nextInt(3); - ingredient = new ItemStack(Items.emerald, - 2 + random.nextInt(5)); + if (JewelrycraftUtil.ores + .size() > 0) { + result = JewelrycraftUtil.ores + .get(random.nextInt( + JewelrycraftUtil.ores + .size())); + result.stackSize = 3 + + random.nextInt( + 3); + ingredient = new ItemStack( + Items.emerald, + 2 + random.nextInt( + 5)); if (random.nextBoolean()) - ingredient2 = new ItemStack(Items.emerald, - 2 + random.nextInt(6)); + ingredient2 = new ItemStack( + Items.emerald, + 2 + random.nextInt( + 6)); break; } case 9: { - result = new ItemStack(ItemList.guide, 1); - ingredient = new ItemStack(Items.emerald, 1); + result = new ItemStack( + ItemList.guide, 1); + ingredient = new ItemStack( + Items.emerald, 1); break; } default: { - result = new ItemStack(jewelry[random.nextInt(4)], 1, - 0); + result = new ItemStack( + jewelry[random.nextInt( + 4)], + 1, 0); int randValue = random.nextInt(4); - if (JewelrycraftUtil.metal.size() > 0) + if (JewelrycraftUtil.metal + .size() > 0) JewelryNBT.addMetal(result, - JewelrycraftUtil.metal.get(random.nextInt( - JewelrycraftUtil.metal.size()))); - if (JewelrycraftUtil.objects.size() > 0) - JewelryNBT.addModifiers(result, JewelrycraftUtil - .addRandomModifiers(randValue)); - if (JewelrycraftUtil.gem.size() > 0) + JewelrycraftUtil.metal + .get(random.nextInt( + JewelrycraftUtil.metal + .size()))); + if (JewelrycraftUtil.objects + .size() > 0) + JewelryNBT.addModifiers( + result, + JewelrycraftUtil.addRandomModifiers( + randValue)); + if (JewelrycraftUtil.gem + .size() > 0) JewelryNBT.addGem(result, - JewelrycraftUtil.gem.get(random.nextInt( - JewelrycraftUtil.gem.size()))); - ingredient = new ItemStack(Items.emerald, - 16 + random.nextInt(20)); - ingredient2 = new ItemStack(Blocks.emerald_block, + JewelrycraftUtil.gem + .get(random.nextInt( + JewelrycraftUtil.gem + .size()))); + ingredient = new ItemStack( + Items.emerald, + 16 + random.nextInt( + 20)); + ingredient2 = new ItemStack( + Blocks.emerald_block, 2 + randValue); } } - recipeList.addToListWithCheck( - new MerchantRecipe(ingredient, ingredient2, result)); + recipeList.addToListWithCheck(new MerchantRecipe( + ingredient, ingredient2, result)); } } } \ No newline at end of file diff --git a/src/main/java/darkknight/jewelrycraft/worldGen/village/VillageHandler.java b/src/main/java/darkknight/jewelrycraft/worldGen/village/VillageHandler.java index 757f9e3..0a4b832 100755 --- a/src/main/java/darkknight/jewelrycraft/worldGen/village/VillageHandler.java +++ b/src/main/java/darkknight/jewelrycraft/worldGen/village/VillageHandler.java @@ -12,12 +12,13 @@ import net.minecraft.world.gen.structure.MapGenStructureIO; public class VillageHandler { public static void preInit(FMLPreInitializationEvent e) { VillagerRegistry.instance().registerVillagerId(3000); - VillagerRegistry.instance().registerVillageTradeHandler(3000, - new JCTrades()); + VillagerRegistry.instance().registerVillageTradeHandler( + 3000, new JCTrades()); VillagerRegistry.instance().registerVillageCreationHandler( new VillageJewelryHandler()); try { - MapGenStructureIO.func_143031_a(ComponentJewelry.class, + MapGenStructureIO.func_143031_a( + ComponentJewelry.class, Variables.MODID + ":Jewelry"); } catch (Throwable thrw) { JewelrycraftMod.logger.error( diff --git a/src/main/java/darkknight/jewelrycraft/worldGen/village/VillageJewelryHandler.java b/src/main/java/darkknight/jewelrycraft/worldGen/village/VillageJewelryHandler.java index 3bd72a0..3b9c274 100755 --- a/src/main/java/darkknight/jewelrycraft/worldGen/village/VillageJewelryHandler.java +++ b/src/main/java/darkknight/jewelrycraft/worldGen/village/VillageJewelryHandler.java @@ -44,9 +44,9 @@ public class VillageJewelryHandler implements IVillageCreationHandler { */ @Override public Object buildComponent(PieceWeight villagePiece, - Start startPiece, List pieces, Random random, int p1, int p2, - int p3, int p4, int p5) { - return ComponentJewelry.buildComponent(startPiece, pieces, random, - p1, p2, p3, p4, p5); + Start startPiece, List pieces, Random random, + int p1, int p2, int p3, int p4, int p5) { + return ComponentJewelry.buildComponent(startPiece, pieces, + random, p1, p2, p3, p4, p5); } } \ No newline at end of file -- cgit v1.2.3