From a6a3bfa6f313adba5afe6eb4a0da049a8d641cfc Mon Sep 17 00:00:00 2001 From: OnyxDarkKnight Date: Fri, 5 Jun 2015 01:53:14 +0100 Subject: Stuff! --- .../jewelrycraft/worldGen/ChestGeneration.java | 103 +++++++++ .../jewelrycraft/worldGen/Generation.java | 199 +++++++++++----- .../jewelrycraft/worldGen/WeightedRandomItem.java | 67 ------ .../jewelrycraft/worldGen/WorldGenStructure1.java | 121 +++++----- .../jewelrycraft/worldGen/WorldGenStructure10.java | 29 +++ .../jewelrycraft/worldGen/WorldGenStructure11.java | 29 +++ .../jewelrycraft/worldGen/WorldGenStructure2.java | 70 ++++++ .../jewelrycraft/worldGen/WorldGenStructure3.java | 68 ++++++ .../jewelrycraft/worldGen/WorldGenStructure4.java | 63 ++++++ .../jewelrycraft/worldGen/WorldGenStructure5.java | 99 ++++++++ .../jewelrycraft/worldGen/WorldGenStructure6.java | 29 +++ .../jewelrycraft/worldGen/WorldGenStructure7.java | 29 +++ .../jewelrycraft/worldGen/WorldGenStructure8.java | 29 +++ .../jewelrycraft/worldGen/WorldGenStructure9.java | 29 +++ .../jewelrycraft/worldGen/village/JCTrades.java | 250 ++++++++++----------- 15 files changed, 900 insertions(+), 314 deletions(-) create mode 100644 src/main/java/darkknight/jewelrycraft/worldGen/ChestGeneration.java delete mode 100644 src/main/java/darkknight/jewelrycraft/worldGen/WeightedRandomItem.java create mode 100644 src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure10.java create mode 100644 src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure11.java create mode 100644 src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure2.java create mode 100644 src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure3.java create mode 100644 src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure4.java create mode 100644 src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure5.java create mode 100644 src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure6.java create mode 100644 src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure7.java create mode 100644 src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure8.java create 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/ChestGeneration.java b/src/main/java/darkknight/jewelrycraft/worldGen/ChestGeneration.java new file mode 100644 index 0000000..f8eb9d5 --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/worldGen/ChestGeneration.java @@ -0,0 +1,103 @@ +package darkknight.jewelrycraft.worldGen; + +import java.util.Random; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.WeightedRandomChestContent; +import net.minecraftforge.common.ChestGenHooks; +import cpw.mods.fml.common.event.FMLPreInitializationEvent; +import darkknight.jewelrycraft.block.BlockList; +import darkknight.jewelrycraft.item.ItemList; +import darkknight.jewelrycraft.util.JewelryNBT; +import darkknight.jewelrycraft.util.JewelrycraftUtil; + +/** + * @author Sorin + * + */ +public class ChestGeneration +{ + static Item[] jewelry = new Item[]{ItemList.ring, ItemList.necklace, ItemList.bracelet, ItemList.earrings}; + static Random random = new Random(); + public static void preInit(FMLPreInitializationEvent e) + { + addItemToDifferentPlaces(new WeightedRandomChestContent(new ItemStack(ItemList.thiefGloves), 1, 1, 2), true, true, false, false, true); + addItemToDifferentPlaces(new WeightedRandomChestContent(new ItemStack(ItemList.guide), 1, 1, 7), true, true, true, true, true, false, true, true); + addVillageBlacksmithLoot(new WeightedRandomChestContent(new ItemStack(ItemList.shadowIngot), 1, 4, 5)); + for(int i = 0; i < 16; i++) addItemToDifferentPlaces(new WeightedRandomChestContent(new ItemStack(BlockList.crystal, 1, i), 1, 4, 4), true, true, true, true); + + ItemStack special = new ItemStack(jewelry[random.nextInt(4)]); + int randValue = random.nextInt(4); + if(JewelrycraftUtil.metal.size() > 0) JewelryNBT.addMetal(special, JewelrycraftUtil.metal.get(random.nextInt(JewelrycraftUtil.metal.size()))); + if(JewelrycraftUtil.objects.size() > 0) JewelryNBT.addModifiers(special, JewelrycraftUtil.addRandomModifiers(randValue)); + if(JewelrycraftUtil.gem.size() > 0) JewelryNBT.addGem(special, JewelrycraftUtil.gem.get(random.nextInt(JewelrycraftUtil.gem.size()))); + addItemToDifferentPlaces(new WeightedRandomChestContent(special, 1, 1, 1), true, true, true, true); + } + + /** + * The booleans determine in which places should the items be added. The order is like so: + *

+ */ + public static void addItemToDifferentPlaces(WeightedRandomChestContent item, Boolean ... options) + { + if(options.length > 0 && options[0]) addDungeonLoot(item); + if(options.length > 1 && options[1]) addStrongholdLoot(item); + if(options.length > 2 && options[2]) addPyramidLoot(item); + if(options.length > 3 && options[3]) addMineshaftLoot(item); + if(options.length > 4 && options[4]) addVillageBlacksmithLoot(item); + if(options.length > 5 && options[5]) addDispenserLoot(item); + if(options.length > 6 && options[6]) addBonusChestLoot(item); + if(options.length > 7 && options[7]) addStrongholdLibraryLoot(item); + } + + public static void addDungeonLoot(WeightedRandomChestContent item) + { + ChestGenHooks.addItem(ChestGenHooks.DUNGEON_CHEST, item); + } + + public static void addStrongholdLoot(WeightedRandomChestContent item) + { + ChestGenHooks.addItem(ChestGenHooks.STRONGHOLD_CORRIDOR, item); + ChestGenHooks.addItem(ChestGenHooks.STRONGHOLD_CROSSING, item); + } + + public static void addPyramidLoot(WeightedRandomChestContent item) + { + ChestGenHooks.addItem(ChestGenHooks.PYRAMID_DESERT_CHEST, item); + ChestGenHooks.addItem(ChestGenHooks.PYRAMID_JUNGLE_CHEST, item); + } + + public static void addMineshaftLoot(WeightedRandomChestContent item) + { + ChestGenHooks.addItem(ChestGenHooks.MINESHAFT_CORRIDOR, item); + } + + public static void addVillageBlacksmithLoot(WeightedRandomChestContent item) + { + ChestGenHooks.addItem(ChestGenHooks.VILLAGE_BLACKSMITH, item); + } + + public static void addDispenserLoot(WeightedRandomChestContent item) + { + ChestGenHooks.addItem(ChestGenHooks.PYRAMID_JUNGLE_DISPENSER, item); + } + + public static void addBonusChestLoot(WeightedRandomChestContent item) + { + ChestGenHooks.addItem(ChestGenHooks.BONUS_CHEST, item); + } + + public static void addStrongholdLibraryLoot(WeightedRandomChestContent item) + { + ChestGenHooks.addItem(ChestGenHooks.STRONGHOLD_LIBRARY, item); + } +} diff --git a/src/main/java/darkknight/jewelrycraft/worldGen/Generation.java b/src/main/java/darkknight/jewelrycraft/worldGen/Generation.java index d71b44c..d3bd3e5 100644 --- a/src/main/java/darkknight/jewelrycraft/worldGen/Generation.java +++ b/src/main/java/darkknight/jewelrycraft/worldGen/Generation.java @@ -1,60 +1,139 @@ -package darkknight.jewelrycraft.worldGen; - -import java.util.Random; -import net.minecraft.init.Blocks; -import net.minecraft.world.World; -import net.minecraft.world.chunk.IChunkProvider; -import cpw.mods.fml.common.IWorldGenerator; -import darkknight.jewelrycraft.block.BlockList; - -public class Generation implements IWorldGenerator -{ - WorldGenStructure1 STRUCTURE_1 = new WorldGenStructure1(); - - @Override - public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) - { - switch(world.provider.dimensionId) - { - case -1: - generateNether(world, random, chunkX << 4, chunkZ << 4); - break; - case 0: - generateSurface(world, random, chunkX << 4, chunkZ << 4); - break; - case 1: - generateEnd(world, random, chunkX << 4, chunkZ << 4); - break; - } - } - - private void generateEnd(World world, Random random, int i, int j) - {} - - private void generateSurface(World world, Random random, int i, int j) - { - for(int k = 0; k < 1; k++){ - int x = i + random.nextInt(16); - int y = 5 + random.nextInt(4); - int z = j + random.nextInt(16); - if (world.getBlock(x, y, z) == Blocks.stone) world.setBlock(x, y, z, BlockList.shadowOre); - int randX = random.nextInt(2), randY = random.nextInt(1), randZ = random.nextInt(2); - if (random.nextInt(3) == 0 && world.getBlock(x + randX, y + randY, z + randZ) == Blocks.stone) world.setBlock(x + randX, y + randY, z + randZ, BlockList.shadowOre); - } - for(int k = 0; k < 16; k++){ - int x = i + random.nextInt(12); - int y = 5 + random.nextInt(64); - int z = j + random.nextInt(12); - for(int r = 0; r < 12; r++){ - int randX = random.nextInt(4); - int randY = random.nextInt(2); - int randZ = random.nextInt(4); - if (world.getBlock(x + randX, y + randY - 1, z + randZ) == Blocks.stone && world.getBlock(x + randX, y + randY, z + randZ) == Blocks.air) - world.setBlock(x + randX, y + randY, z + randZ, BlockList.crystal, random.nextInt(16), 2); - } - } - } - - private void generateNether(World world, Random random, int i, int j) - {} -} +package darkknight.jewelrycraft.worldGen; + +import java.util.Random; +import net.minecraft.init.Blocks; +import net.minecraft.world.World; +import net.minecraft.world.biome.BiomeGenBase; +import net.minecraft.world.chunk.IChunkProvider; +import net.minecraft.world.gen.feature.WorldGenerator; +import cpw.mods.fml.common.IWorldGenerator; +import darkknight.jewelrycraft.block.BlockList; + +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 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) + { + case -1: + generateNether(world, random, chunkX << 4, chunkZ << 4); + break; + case 0: + generateSurface(world, random, chunkX << 4, chunkZ << 4); + break; + case 1: + generateEnd(world, random, chunkX << 4, chunkZ << 4); + break; + } + } + + private void generateEnd(World world, Random random, int i, int j) + {} + + private void generateSurface(World world, Random random, int i, int j) + { + generateShadowOre(world, random, i, j); + generateCrystals(world, random, i, j); + generateStructure1(world, random, i, j); + generateStructure2(world, random, i, j); + generateStructure3(world, random, i, j); + generateStructure4(world, random, i, j); + generateStructure5(world, random, i, 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++){ + int x = i + random.nextInt(16); + int y = 5 + random.nextInt(4); + int z = j + random.nextInt(16); + if (world.getBlock(x, y, z) == Blocks.stone) world.setBlock(x, y, z, BlockList.shadowOre); + int randX = random.nextInt(2), randY = random.nextInt(1), randZ = random.nextInt(2); + if (random.nextInt(3) == 0 && world.getBlock(x + randX, y + randY, z + randZ) == Blocks.stone) world.setBlock(x + randX, y + randY, z + randZ, BlockList.shadowOre); + } + } + + private void generateCrystals(World world, Random random, int i, int j) + { + for(int k = 0; k < 16; k++){ + int x = i + random.nextInt(12); + int y = 5 + random.nextInt(64); + int z = j + random.nextInt(12); + for(int r = 0; r < 12; r++){ + int randX = random.nextInt(4); + int randY = random.nextInt(2); + int randZ = random.nextInt(4); + if (world.getBlock(x + randX, y + randY - 1, z + randZ) == Blocks.stone && world.getBlock(x + randX, y + randY, z + randZ) == Blocks.air) world.setBlock(x + randX, y + randY, z + randZ, BlockList.crystal, random.nextInt(16), 2); + } + } + } + + 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) + { + 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); + } + } + + 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); + } + } + + private void generateStructure4(World world, Random random, int i, int j) + { + 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); + } + } + + 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); + } + } +} diff --git a/src/main/java/darkknight/jewelrycraft/worldGen/WeightedRandomItem.java b/src/main/java/darkknight/jewelrycraft/worldGen/WeightedRandomItem.java deleted file mode 100644 index 0528b66..0000000 --- a/src/main/java/darkknight/jewelrycraft/worldGen/WeightedRandomItem.java +++ /dev/null @@ -1,67 +0,0 @@ -package darkknight.jewelrycraft.worldGen; - -import java.util.Random; -import net.minecraft.enchantment.EnchantmentHelper; -import net.minecraft.item.ItemStack; -import net.minecraft.util.WeightedRandom; - -public class WeightedRandomItem extends WeightedRandom.Item -{ - private final ItemStack item; - private int maxMeta, minMeta, minItem, maxItem; - - public WeightedRandomItem(ItemStack item, int weight) - { - super(weight); - this.item = item; - this.minItem = 1; - this.maxItem = 1; - this.maxMeta = 0; - this.minMeta = 0; - } - - public WeightedRandomItem(ItemStack item, int maxMetadata, int weight) - { - this(item, weight); - this.maxMeta = maxMetadata; - } - - public WeightedRandomItem(ItemStack item, int weight, int minItem, int maxItem) - { - this(item, weight); - this.minItem = minItem; - this.maxItem = maxItem; - } - - public WeightedRandomItem setMaxMetadata(int meta) - { - this.maxMeta = meta; - return this; - } - - public WeightedRandomItem setMinMetadata(int meta) - { - this.minMeta = meta; - return this; - } - - public WeightedRandomItem setMinItem(int min) - { - this.minItem = min; - return this; - } - - public WeightedRandomItem setMaxItem(int max) - { - this.maxItem = max; - return this; - } - - public ItemStack getItem(Random random) - { - ItemStack itemstack = this.item.copy(); - if(maxMeta > 0) itemstack.setItemDamage(minMeta + random.nextInt(maxMeta - minMeta)); - if(maxItem > 1) itemstack.stackSize = this.minItem + random.nextInt(this.maxItem - this.minItem + 1); - return itemstack; - } -} \ No newline at end of file diff --git a/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure1.java b/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure1.java index 2d11cb5..5d9118f 100644 --- a/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure1.java +++ b/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure1.java @@ -1,61 +1,60 @@ -/** - * - */ -package darkknight.jewelrycraft.worldGen; - -import java.util.Arrays; -import java.util.List; -import java.util.Random; -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; -import net.minecraft.item.ItemStack; -import net.minecraft.util.WeightedRandom; -import net.minecraft.world.World; -import net.minecraft.world.gen.feature.WorldGenerator; -import darkknight.jewelrycraft.block.BlockList; -import darkknight.jewelrycraft.item.ItemList; -import darkknight.jewelrycraft.tileentity.TileEntityHandPedestal; -import darkknight.jewelrycraft.util.JewelrycraftUtil; - -/** - * @author Sorin - */ -public class WorldGenStructure1 extends WorldGenerator -{ - public static final WeightedRandomItem[] items = new WeightedRandomItem[] { - new WeightedRandomItem(new ItemStack(ItemList.thiefGloves), 7), - new WeightedRandomItem(new ItemStack(Items.golden_apple), 5), - new WeightedRandomItem(new ItemStack(Items.golden_apple, 1, 1), 1), - new WeightedRandomItem(new ItemStack(ItemList.guide), 10), - new WeightedRandomItem(new ItemStack(ItemList.shadowIngot), 15), - 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, 10) - }; - - @Override - public boolean generate(World world, Random rand, int x, int y, int z) - { - for(int i = -2; i <= 2; i++) - for(int j = -1; j <= 4; j++) - for(int k = -2; k <= 2; k++) - world.setBlock(x + i, y + j, z + k, Blocks.air); - - for(int i = -2; i <= 2; i++) - for(int k = -2; k <= 2; k++){ - world.setBlock(x + i, y - 1, z + k, Blocks.stonebrick); - if (i % 2 == 0 && k % 2 == 0 && i != 0 && k != 0) world.setBlock(x + i, y, z + k, BlockList.crystal); - } - for(int i = -1; i <= 1; i++) - for(int k = -1; k <= 1; k++) - world.setBlock(x + i, y, z + k, Blocks.stone_slab, 5, 2); - - world.setBlock(x, y, z, Blocks.stonebrick); - world.setBlock(x, y+1, z, BlockList.handPedestal, 6, 2); - TileEntityHandPedestal pedestal = (TileEntityHandPedestal)world.getTileEntity(x, y+1, z); - pedestal.setHeldItemStack(((WeightedRandomItem)WeightedRandom.getRandomItem(rand, items)).getItem(rand)); - - return true; - } -} +/** + * + */ +package darkknight.jewelrycraft.worldGen; + +import java.util.Random; +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.util.WeightedRandom; +import net.minecraft.world.World; +import net.minecraft.world.biome.BiomeGenBase; +import net.minecraft.world.gen.feature.WorldGenerator; +import darkknight.jewelrycraft.block.BlockList; +import darkknight.jewelrycraft.item.ItemList; +import darkknight.jewelrycraft.random.WeightedRandomItem; +import darkknight.jewelrycraft.tileentity.TileEntityHandPedestal; + +/** + * @author Sorin + */ +public class WorldGenStructure1 extends WorldGenerator +{ + 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)}; + + public boolean generate(World world, BiomeGenBase biome, Random rand, int x, int y, int z) + { + Block block = Blocks.stonebrick; + int metadata = 0, slabMeta = 5; + if (biome == BiomeGenBase.desert || biome == BiomeGenBase.desertHills){ + block = Blocks.sandstone; + metadata = 2; + slabMeta = 1; + } + for(int i = -2; i <= 2; i++) + for(int j = -1; j <= 4; j++) + for(int k = -2; k <= 2; k++) + world.setBlock(x + i, y + j, z + k, Blocks.air); + for(int i = -2; i <= 2; i++) + for(int k = -2; k <= 2; k++){ + world.setBlock(x + i, y - 1, z + k, block, metadata, 2); + if (i % 2 == 0 && k % 2 == 0 && i != 0 && k != 0) world.setBlock(x + i, y, z + k, BlockList.crystal); + } + 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, 2); + world.setBlock(x, y, z, block, metadata, 2); + world.setBlock(x, y + 1, z, BlockList.handPedestal, 6, 2); + TileEntityHandPedestal pedestal = (TileEntityHandPedestal)world.getTileEntity(x, y + 1, z); + pedestal.setHeldItemStack(((WeightedRandomItem)WeightedRandom.getRandomItem(rand, items)).getItem(rand)); + 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/WorldGenStructure10.java b/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure10.java new file mode 100644 index 0000000..b838368 --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure10.java @@ -0,0 +1,29 @@ +/** + * + */ +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 new file mode 100644 index 0000000..cfe84fb --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure11.java @@ -0,0 +1,29 @@ +/** + * + */ +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 new file mode 100644 index 0000000..f8b3094 --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure2.java @@ -0,0 +1,70 @@ +package darkknight.jewelrycraft.worldGen; + +import java.io.IOException; +import java.util.Random; +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 boolean generate(World world, BiomeGenBase biome, Random rand, int x, int y, int z) + { + Block block = Blocks.stonebrick; + Block stair = Blocks.stone_brick_stairs; + int metadata = 0, slabMeta = 5; + if (biome == BiomeGenBase.desert || biome == BiomeGenBase.desertHills){ + block = Blocks.sandstone; + stair = Blocks.sandstone_stairs; + metadata = 2; + } + for(int i = -1; i <= 1; i++) + for(int k = -1; k <= 1; k++) + world.setBlock(x + i, y, z + k, Blocks.air); + for(int i = -1; i <= 1; i++) + for(int k = -1; k <= 1; k++) + world.setBlock(x + i, y - 1, z + k, block, metadata, 2); + for(int i = -1; i <= 1; i++) + for(int k = -1; k <= 1; k++) + world.setBlock(x + i, y, z + k, stair); + for(int i = -1; i <= 1; i++) + for(int k = -1; k <= 1; k++) + world.setBlockMetadataWithNotify(x + i, y, z + k, (k == -1) ? 3 : (k == 0) ? (i == 1) ? 0 : 1 : 2, 2); + world.setBlock(x, y, z, Blocks.air); + ItemStack stack = new ItemStack(ItemList.bucket); + JewelryNBT.addMetal(stack, JewelrycraftUtil.metal.get(rand.nextInt(JewelrycraftUtil.metal.size()))); + try{ + if (stack != null && JewelryNBT.ingot(stack) != null){ + if (!world.isRemote) world.func_147480_a(x, y, z, true); + int color = ItemMoltenMetalBucket.color(stack, 1); + JewelrycraftMod.saveData.setString(x + " " + y + " " + z + " " + world.provider.dimensionId, Item.getIdFromItem(JewelryNBT.ingot(stack).getItem()) + ":" + JewelryNBT.ingot(stack).getItemDamage() + ":" + color); + JewelrycraftMod.netWrapper.sendToAll(new PacketSendLiquidData(world.provider.dimensionId, x, y, z, Item.getIdFromItem(JewelryNBT.ingot(stack).getItem()), JewelryNBT.ingot(stack).getItemDamage(), color)); + world.setBlock(x, y, z, BlockList.moltenMetal, 0, 3); + } + } + catch(IOException e){ + e.printStackTrace(); + } + 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/WorldGenStructure3.java b/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure3.java new file mode 100644 index 0000000..7234aa9 --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure3.java @@ -0,0 +1,68 @@ +/** + * + */ +package darkknight.jewelrycraft.worldGen; + +import java.util.Random; +import net.minecraft.block.Block; +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 WorldGenStructure3 extends WorldGenerator +{ + 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; + int slabMeta = 13; + if (biome == BiomeGenBase.desert || biome == BiomeGenBase.desertHills){ + stair = Blocks.sandstone_stairs; + slabMeta = 9; + } + for(int i = -1; i <= 1; i++) + for(int j = -1; j <= 2; j++) + for(int k = -1; k <= 1; k++) + 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 - 1, z + k, slab, slabMeta, 1); + for(int i = -1; i <= 1; i++) + for(int k = -1; k <= 1; k++) + world.setBlock(x + i, y, z + k, stair); + for(int i = -1; i <= 1; i++) + for(int k = -1; k <= 1; k++) + world.setBlockMetadataWithNotify(x + i, y, z + k, (k == -1) ? 3 : (k == 0) ? (i == 1) ? 0 : 1 : 2, 2); + for(int i = -1; i <= 1; i++) + for(int k = -1; k <= 1; k++) + world.setBlock(x + i, y + 1, z + k, stair); + for(int i = -1; i <= 1; i++) + for(int k = -1; k <= 1; k++) + world.setBlockMetadataWithNotify(x + i, y + 1, z + k, (k == -1) ? 7 : (k == 0) ? (i == 1) ? 4 : 5 : 6, 2); + slabMeta = 5; + 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, y, z, Blocks.mob_spawner); + world.setBlock(x, y + 1, z, Blocks.mob_spawner); + for(int l = 0; l < 2; l++){ + TileEntityMobSpawner tileentitymobspawner = (TileEntityMobSpawner)world.getTileEntity(x, y + l, z); + if (tileentitymobspawner != null) tileentitymobspawner.func_145881_a().setEntityName(DungeonHooks.getRandomDungeonMob(rand)); + else System.err.println("Failed to fetch mob spawner entity at (" + x + ", " + (y + l) + ", " + 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/WorldGenStructure4.java b/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure4.java new file mode 100644 index 0000000..4171438 --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure4.java @@ -0,0 +1,63 @@ +/** + * + */ +package darkknight.jewelrycraft.worldGen; + +import java.util.Random; +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.world.World; +import net.minecraft.world.biome.BiomeGenBase; +import net.minecraft.world.gen.feature.WorldGenerator; +import darkknight.jewelrycraft.block.BlockList; + +/** + * @author Sorin + */ +public class WorldGenStructure4 extends WorldGenerator +{ + 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; + Block block = Blocks.stonebrick; + int metadata = 0, slabMeta = 5; + if (biome == BiomeGenBase.desert || biome == BiomeGenBase.desertHills){ + stair = Blocks.sandstone_stairs; + block = Blocks.sandstone; + metadata = 2; + slabMeta = 1; + } + for(int i = -1; i <= 1; i++) + for(int j = 0; j <= 3; j++) + for(int k = -1; k <= 1; k++) + 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, y, z, block, metadata, 2); + world.setBlock(x, y, z - 1, stair, 3, 1); + world.setBlock(x, y, z + 1, stair, 2, 1); + world.setBlock(x - 1, y, z, stair, 1, 1); + world.setBlock(x + 1, y, z, stair, 0, 1); + world.setBlock(x, y + 1, z - 1, stair, 7, 1); + world.setBlock(x, y + 1, z + 1, stair, 6, 1); + world.setBlock(x - 1, y + 1, z, stair, 5, 1); + world.setBlock(x + 1, y + 1, z, stair, 4, 1); + world.setBlock(x, y + 1, z, BlockList.shadowBlock); + slabMeta = 5; + 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); + world.setBlock(x, y + 2, z, block, metadata, 2); + world.setBlock(x, y + 3, z, BlockList.crystal); + 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/WorldGenStructure5.java b/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure5.java new file mode 100644 index 0000000..0533a1b --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure5.java @@ -0,0 +1,99 @@ +/** + * + */ +package darkknight.jewelrycraft.worldGen; + +import java.io.IOException; +import java.util.Random; +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; +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.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 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; + Block block = Blocks.stonebrick; + int metadata = 0, slabMeta = 5; + if (biome == BiomeGenBase.desert || biome == BiomeGenBase.desertHills){ + stair = Blocks.sandstone_stairs; + block = Blocks.sandstone; + metadata = 2; + slabMeta = 1; + } + for(int i = -2; i <= 2; i++) + for(int j = 0; j <= 3; j++) + for(int k = -3; k <= -1; k++) + world.setBlock(x + i, y + j, z + k, Blocks.air); + for(int i = -5; i <= -3; i++) + for(int k = -3; k <= 2; k++) + 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); + 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); + 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); + 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); + world.setBlock(x - 3, y, z - 1, stair, 0, 2); + world.setBlock(x - 3, y, z - 3, stair, 0, 2); + world.setBlock(x - 2, y + 1, z - 3, slab, slabMeta, 2); + world.setBlock(x - 2, y + 1, z - 1, slab, slabMeta, 2); + world.setBlock(x - 1, y + 1, z - 3, slab, slabMeta, 2); + world.setBlock(x - 1, y + 1, z - 1, slab, slabMeta, 2); + world.setBlock(x, y + 1, z - 1, stair, 0, 2); + world.setBlock(x, y + 1, z - 3, stair, 0, 2); + 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); + if (rand.nextInt(5) == 0){ + ItemStack stack = new ItemStack(ItemList.bucket); + JewelryNBT.addMetal(stack, new ItemStack(Items.gold_ingot)); + try{ + if (stack != null && JewelryNBT.ingot(stack) != null){ + if (!world.isRemote) world.func_147480_a(x, y, z, true); + int color = ItemMoltenMetalBucket.color(stack, 1); + JewelrycraftMod.saveData.setString((x + 1) + " " + (y + 2) + " " + (z - 2) + " " + world.provider.dimensionId, Item.getIdFromItem(JewelryNBT.ingot(stack).getItem()) + ":" + JewelryNBT.ingot(stack).getItemDamage() + ":" + color); + JewelrycraftMod.netWrapper.sendToAll(new PacketSendLiquidData(world.provider.dimensionId, x + 1, y + 2, z - 2, Item.getIdFromItem(JewelryNBT.ingot(stack).getItem()), JewelryNBT.ingot(stack).getItemDamage(), color)); + world.setBlock(x + 1, y + 2, z - 2, BlockList.moltenMetal, 0, 3); + } + } + catch(IOException e){ + e.printStackTrace(); + } + }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; + } + + @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/WorldGenStructure6.java b/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure6.java new file mode 100644 index 0000000..1755396 --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure6.java @@ -0,0 +1,29 @@ +/** + * + */ +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 WorldGenStructure6 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/WorldGenStructure7.java b/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure7.java new file mode 100644 index 0000000..964e8e6 --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure7.java @@ -0,0 +1,29 @@ +/** + * + */ +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 new file mode 100644 index 0000000..868b623 --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure8.java @@ -0,0 +1,29 @@ +/** + * + */ +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 new file mode 100644 index 0000000..e349ac6 --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/worldGen/WorldGenStructure9.java @@ -0,0 +1,29 @@ +/** + * + */ +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/JCTrades.java b/src/main/java/darkknight/jewelrycraft/worldGen/village/JCTrades.java index 015e939..a1b508b 100644 --- a/src/main/java/darkknight/jewelrycraft/worldGen/village/JCTrades.java +++ b/src/main/java/darkknight/jewelrycraft/worldGen/village/JCTrades.java @@ -1,127 +1,125 @@ -package darkknight.jewelrycraft.worldGen.village; - -import java.util.Random; -import net.minecraft.entity.passive.EntityVillager; -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; -import net.minecraft.item.ItemStack; -import net.minecraft.village.MerchantRecipe; -import net.minecraft.village.MerchantRecipeList; -import cpw.mods.fml.common.registry.VillagerRegistry.IVillageTradeHandler; -import darkknight.jewelrycraft.block.BlockList; -import darkknight.jewelrycraft.item.ItemList; -import darkknight.jewelrycraft.item.ItemMolds; -import darkknight.jewelrycraft.util.JewelryNBT; -import darkknight.jewelrycraft.util.JewelrycraftUtil; - -public class JCTrades implements IVillageTradeHandler -{ - - /** - * - */ - public JCTrades() - { - super(); - } - - /** - * @param villager - * @param recipeList - * @param random - */ - @Override - public void manipulateTradesForVillager(EntityVillager villager, MerchantRecipeList recipeList, Random random) - { - if (villager.getProfession() == 3000){ - ItemStack ingredient = null; - ItemStack ingredient2 = null; - ItemStack result; - 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 (random.nextBoolean()) 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); - if (random.nextBoolean()) ingredient2 = new ItemStack(Items.emerald, 1 + random.nextInt(2)); - break; - } - case 2:{ - int number = random.nextInt(3); - 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)); - break; - } - case 3:{ - 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)); - break; - } - case 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)); - break; - } - case 5:{ - result = new ItemStack(BlockList.molder, 5 + random.nextInt(5)); - ingredient = new ItemStack(Items.emerald, 1); - if (random.nextBoolean()) ingredient2 = new ItemStack(Items.emerald, 1); - break; - } - case 6:{ - 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)); - 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){ - int value = 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)); - }else{ - 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 (random.nextBoolean()) ingredient2 = new ItemStack(Items.emerald, 2 + random.nextInt(6)); - break; - } - case 9:{ - result = new ItemStack(ItemList.guide, 1); - ingredient = new ItemStack(Items.emerald, 1); - break; - } - default:{ - result = new ItemStack(ItemList.ring, 1, 0); - int randValue = random.nextInt(4); - 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) 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, 2 + randValue); - } - } - recipeList.addToListWithCheck(new MerchantRecipe(ingredient, ingredient2, result)); - } - } +package darkknight.jewelrycraft.worldGen.village; + +import java.util.Random; +import net.minecraft.entity.passive.EntityVillager; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.village.MerchantRecipe; +import net.minecraft.village.MerchantRecipeList; +import cpw.mods.fml.common.registry.VillagerRegistry.IVillageTradeHandler; +import darkknight.jewelrycraft.block.BlockList; +import darkknight.jewelrycraft.item.ItemList; +import darkknight.jewelrycraft.item.ItemMolds; +import darkknight.jewelrycraft.util.JewelryNBT; +import darkknight.jewelrycraft.util.JewelrycraftUtil; + +public class JCTrades implements IVillageTradeHandler +{ + Item[] jewelry = new Item[]{ItemList.ring, ItemList.necklace, ItemList.bracelet, ItemList.earrings}; + public JCTrades() + { + super(); + } + + /** + * @param villager + * @param recipeList + * @param random + */ + @Override + public void manipulateTradesForVillager(EntityVillager villager, MerchantRecipeList recipeList, Random random) + { + if (villager.getProfession() == 3000){ + ItemStack ingredient = null; + ItemStack ingredient2 = null; + ItemStack result; + 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 (random.nextBoolean()) 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); + if (random.nextBoolean()) ingredient2 = new ItemStack(Items.emerald, 1 + random.nextInt(2)); + break; + } + case 2:{ + int number = random.nextInt(3); + 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)); + break; + } + case 3:{ + 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)); + break; + } + case 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)); + break; + } + case 5:{ + result = new ItemStack(BlockList.molder, 5 + random.nextInt(5)); + ingredient = new ItemStack(Items.emerald, 1); + if (random.nextBoolean()) ingredient2 = new ItemStack(Items.emerald, 1); + break; + } + case 6:{ + 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)); + 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){ + int value = 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)); + }else{ + 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 (random.nextBoolean()) ingredient2 = new ItemStack(Items.emerald, 2 + random.nextInt(6)); + break; + } + case 9:{ + result = new ItemStack(ItemList.guide, 1); + ingredient = new ItemStack(Items.emerald, 1); + break; + } + default:{ + result = new ItemStack(jewelry[random.nextInt(4)], 1, 0); + int randValue = random.nextInt(4); + 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) 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, 2 + randValue); + } + } + recipeList.addToListWithCheck(new MerchantRecipe(ingredient, ingredient2, result)); + } + } } \ No newline at end of file -- cgit v1.2.3