summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorOnyxDarkKnight <sor1n.iliutza16@gmail.com>2014-01-04 19:59:46 +0200
committerOnyxDarkKnight <sor1n.iliutza16@gmail.com>2014-01-04 19:59:46 +0200
commitef7fe109a0a58023725d87d4618ace6cfc4326d4 (patch)
treef3b2eb4f17e890a73979b0d8e17437541b07058f /common
parent1e8ab612f40161e7a4ec3cd6c96b1c481c21e6c2 (diff)
Added a stinking villager and his derp house!
Diffstat (limited to 'common')
-rw-r--r--common/darkknight/jewelrycraft/JewelrycraftMod.java24
-rw-r--r--common/darkknight/jewelrycraft/item/ItemRing.java2
-rw-r--r--common/darkknight/jewelrycraft/renders/TileEntityDisplayerRender.java2
-rw-r--r--common/darkknight/jewelrycraft/util/JewelrycraftUtil.java32
-rw-r--r--common/darkknight/jewelrycraft/worldGen/village/ComponentJewelry.java334
-rw-r--r--common/darkknight/jewelrycraft/worldGen/village/JCTrades.java142
-rw-r--r--common/darkknight/jewelrycraft/worldGen/village/VillageJewelryHandler.java29
7 files changed, 556 insertions, 9 deletions
diff --git a/common/darkknight/jewelrycraft/JewelrycraftMod.java b/common/darkknight/jewelrycraft/JewelrycraftMod.java
index 68d26ec..2997907 100644
--- a/common/darkknight/jewelrycraft/JewelrycraftMod.java
+++ b/common/darkknight/jewelrycraft/JewelrycraftMod.java
@@ -1,5 +1,7 @@
package darkknight.jewelrycraft;
+import java.util.logging.Logger;
+
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.ItemStack;
import net.minecraft.network.INetworkManager;
@@ -7,6 +9,8 @@ import net.minecraft.network.NetLoginHandler;
import net.minecraft.network.packet.NetHandler;
import net.minecraft.network.packet.Packet1Login;
import net.minecraft.server.MinecraftServer;
+import net.minecraft.util.ResourceLocation;
+import net.minecraft.world.gen.structure.MapGenStructureIO;
import net.minecraftforge.oredict.OreDictionary;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
@@ -22,6 +26,7 @@ import cpw.mods.fml.common.network.NetworkMod;
import cpw.mods.fml.common.network.NetworkMod.SidedPacketHandler;
import cpw.mods.fml.common.network.Player;
import cpw.mods.fml.common.registry.GameRegistry;
+import cpw.mods.fml.common.registry.VillagerRegistry;
import darkknight.jewelrycraft.block.BlockList;
import darkknight.jewelrycraft.client.JewelryCraftClient;
import darkknight.jewelrycraft.config.ConfigHandler;
@@ -32,6 +37,9 @@ import darkknight.jewelrycraft.recipes.CraftingRecipes;
import darkknight.jewelrycraft.server.JewelryCraftServer;
import darkknight.jewelrycraft.util.JewelrycraftUtil;
import darkknight.jewelrycraft.worldGen.Generation;
+import darkknight.jewelrycraft.worldGen.village.ComponentJewelry;
+import darkknight.jewelrycraft.worldGen.village.JCTrades;
+import darkknight.jewelrycraft.worldGen.village.VillageJewelryHandler;
@Mod(modid = Reference.MODID, name = Reference.MODNAME, version = Reference.VERSION)
@NetworkMod(clientSideRequired = false, serverSideRequired = false,
@@ -48,6 +56,8 @@ public class JewelrycraftMod implements IConnectionHandler
@SidedProxy(clientSide = "darkknight.jewelrycraft.client.ClientProxy", serverSide = "darkknight.jewelrycraft.CommonProxy")
public static CommonProxy proxy;
+
+ public static final Logger logger = Logger.getLogger("Jewelrycraft");
public static CreativeTabs jewelrycraft = new CreativeTabs("JewelryCraft")
{
@@ -65,6 +75,20 @@ public class JewelrycraftMod implements IConnectionHandler
ItemList.preInit(e);
BlockList.preInit(e);
CraftingRecipes.preInit(e);
+ JewelrycraftUtil.addMetals();
+
+ VillagerRegistry.instance().registerVillagerId(3000);
+ VillagerRegistry.instance().registerVillageTradeHandler(3000, new JCTrades());
+ VillagerRegistry.instance().registerVillagerSkin(3000, new ResourceLocation("jewelrycraft", "textures/entities/jeweler.png"));
+ VillagerRegistry.instance().registerVillageCreationHandler(new VillageJewelryHandler());
+ try
+ {
+ MapGenStructureIO.func_143031_a(ComponentJewelry.class, "Jewelrycraft:Jewelry");
+ }
+ catch (Throwable e2)
+ {
+ logger.severe("Error registering Jewelrycraft Structures with Vanilla Minecraft: this is expected in versions earlier than 1.6.4");
+ }
proxy.registerRenderers();
}
diff --git a/common/darkknight/jewelrycraft/item/ItemRing.java b/common/darkknight/jewelrycraft/item/ItemRing.java
index 6e092f1..c420809 100644
--- a/common/darkknight/jewelrycraft/item/ItemRing.java
+++ b/common/darkknight/jewelrycraft/item/ItemRing.java
@@ -11,7 +11,6 @@ import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import darkknight.jewelrycraft.JewelrycraftMod;
import darkknight.jewelrycraft.util.JewelryNBT;
-import darkknight.jewelrycraft.util.JewelrycraftUtil;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
@@ -33,7 +32,6 @@ import net.minecraft.util.MathHelper;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
-import net.minecraftforge.common.FakePlayer;
public class ItemRing extends Item
{
diff --git a/common/darkknight/jewelrycraft/renders/TileEntityDisplayerRender.java b/common/darkknight/jewelrycraft/renders/TileEntityDisplayerRender.java
index e0d43fd..483c5be 100644
--- a/common/darkknight/jewelrycraft/renders/TileEntityDisplayerRender.java
+++ b/common/darkknight/jewelrycraft/renders/TileEntityDisplayerRender.java
@@ -103,7 +103,7 @@ public class TileEntityDisplayerRender extends TileEntitySpecialRenderer
protected void renderLabel(String par2Str, double x, double y, double z, int metadata, TileEntity te)
{
FontRenderer fontrenderer = RenderManager.instance.getFontRenderer();
- if(te.worldObj.getClosestPlayer((double)te.xCoord, (double)te.yCoord, (double)te.zCoord, 3D) != null)
+ if(te.worldObj.getClosestPlayer((double)te.xCoord, (double)te.yCoord, (double)te.zCoord, 3.5D) != null)
{
float var14 = 0.01266667F * 1.5F;
float var17 = 0.015F;
diff --git a/common/darkknight/jewelrycraft/util/JewelrycraftUtil.java b/common/darkknight/jewelrycraft/util/JewelrycraftUtil.java
index 0821565..ff3fe51 100644
--- a/common/darkknight/jewelrycraft/util/JewelrycraftUtil.java
+++ b/common/darkknight/jewelrycraft/util/JewelrycraftUtil.java
@@ -7,6 +7,7 @@ import java.util.Iterator;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
+import net.minecraftforge.oredict.OreDictionary;
import darkknight.jewelrycraft.item.ItemList;
public class JewelrycraftUtil
@@ -14,26 +15,27 @@ public class JewelrycraftUtil
public static ArrayList<ItemStack> modifiers = new ArrayList<ItemStack>();
public static ArrayList<ItemStack> jewel = new ArrayList<ItemStack>();
public static ArrayList<ItemStack> jewelry = new ArrayList<ItemStack>();
+ public static ArrayList<ItemStack> metal = new ArrayList<ItemStack>();
public static ArrayList<String> jamcraftPlayers = new ArrayList<String>();
public static HashMap<ItemStack, ItemStack> combinations = new HashMap<ItemStack, ItemStack>();
public static void addStuff()
{
//Modifiers
- modifiers.add(new ItemStack(Item.blazePowder));
- modifiers.add(new ItemStack(Item.sugar));
modifiers.add(new ItemStack(Block.chest));
- modifiers.add(new ItemStack(Item.pickaxeIron));
+ modifiers.add(new ItemStack(Item.sugar));
+ modifiers.add(new ItemStack(Item.feather));
modifiers.add(new ItemStack(Item.bed));
+ modifiers.add(new ItemStack(Item.pickaxeIron));
+ modifiers.add(new ItemStack(Item.blazePowder));
modifiers.add(new ItemStack(Item.eyeOfEnder));
- modifiers.add(new ItemStack(Item.feather));
modifiers.add(new ItemStack(Item.potion, 1, 8270));
//Jewels
- jewel.add(new ItemStack(Item.enderPearl));
+ jewel.add(new ItemStack(Block.obsidian));
jewel.add(new ItemStack(Item.diamond));
jewel.add(new ItemStack(Item.emerald));
- jewel.add(new ItemStack(Block.obsidian));
+ jewel.add(new ItemStack(Item.enderPearl));
jewel.add(new ItemStack(Item.netherStar));
//Jewelry
@@ -71,6 +73,24 @@ public class JewelrycraftUtil
jamcraftPlayers.add("YSPilot");
jamcraftPlayers.add("direwolf20");
}
+
+ public static void addMetals()
+ {
+ int index = 0, index2 = 0;
+ while(index < OreDictionary.getOreNames().length)
+ {
+ while(index2 < OreDictionary.getOres(OreDictionary.getOreNames()[index]).size())
+ {
+ if(OreDictionary.getOres(OreDictionary.getOreNames()[index]).get(index2).getUnlocalizedName().contains("ingot"))
+ metal.add(OreDictionary.getOres(OreDictionary.getOreNames()[index]).get(index2));
+ index2++;
+ }
+ index2 = 0;
+ index++;
+ }
+ metal.add(new ItemStack(Item.ingotGold));
+ metal.add(new ItemStack(Item.ingotIron));
+ }
public static boolean isModifier(ItemStack item)
{
diff --git a/common/darkknight/jewelrycraft/worldGen/village/ComponentJewelry.java b/common/darkknight/jewelrycraft/worldGen/village/ComponentJewelry.java
new file mode 100644
index 0000000..2d9b99e
--- /dev/null
+++ b/common/darkknight/jewelrycraft/worldGen/village/ComponentJewelry.java
@@ -0,0 +1,334 @@
+package darkknight.jewelrycraft.worldGen.village;
+
+import java.util.List;
+import java.util.Random;
+
+import darkknight.jewelrycraft.block.BlockList;
+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 net.minecraft.block.Block;
+import net.minecraft.item.ItemStack;
+import net.minecraft.tileentity.TileEntityChest;
+import net.minecraft.tileentity.TileEntityFurnace;
+import net.minecraft.world.World;
+import net.minecraft.world.gen.structure.ComponentVillage;
+import net.minecraft.world.gen.structure.ComponentVillageStartPiece;
+import net.minecraft.world.gen.structure.StructureBoundingBox;
+import net.minecraft.world.gen.structure.StructureComponent;
+
+public class ComponentJewelry extends ComponentVillage
+{
+ private int averageGroundLevel = -1;
+
+ public ComponentJewelry()
+ {
+ }
+
+ public ComponentJewelry(ComponentVillageStartPiece par1ComponentVillageStartPiece, int par2, Random par3Random, StructureBoundingBox par4StructureBoundingBox, int par5)
+ {
+ super(par1ComponentVillageStartPiece, par2);
+ this.coordBaseMode = par5;
+ this.boundingBox = par4StructureBoundingBox;
+ }
+
+ @SuppressWarnings("rawtypes")
+ public static ComponentJewelry buildComponent (ComponentVillageStartPiece 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...
+ */
+ public boolean addComponentParts (World world, Random random, StructureBoundingBox sbb)
+ {
+ if (this.averageGroundLevel < 0)
+ {
+ this.averageGroundLevel = this.getAverageGroundLevel(world, sbb);
+
+ if (this.averageGroundLevel < 0)
+ {
+ return true;
+ }
+
+ this.boundingBox.offset(0, this.averageGroundLevel - this.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)
+ */
+ this.fillWithBlocks(world, sbb, 0, 0, 0, 11, 5, 12, 0, 0, false);
+ //Pillars
+ this.fillWithBlocks(world, sbb, 2, 0, 0, 2, 3, 0, Block.wood.blockID, Block.wood.blockID, false);
+ this.fillWithBlocks(world, sbb, 2, 0, 3, 2, 3, 3, Block.wood.blockID, Block.wood.blockID, false);
+ this.fillWithBlocks(world, sbb, 8, 0, 0, 8, 3, 0, Block.wood.blockID, Block.wood.blockID, false);
+ this.fillWithBlocks(world, sbb, 8, 0, 3, 8, 3, 3, Block.wood.blockID, Block.wood.blockID, false);
+
+ //Walls
+ this.fillWithBlocks(world, sbb, 2, 0, 1, 2, 3, 2, Block.planks.blockID, Block.planks.blockID, false);
+ this.fillWithBlocks(world, sbb, 2, 0, 4, 2, 3, 5, Block.planks.blockID, Block.planks.blockID, false);
+ this.fillWithBlocks(world, sbb, 8, 0, 1, 8, 3, 2, Block.planks.blockID, Block.planks.blockID, false);
+ this.fillWithBlocks(world, sbb, 8, 0, 4, 8, 3, 5, Block.planks.blockID, Block.planks.blockID, false);
+ this.fillWithBlocks(world, sbb, 3, 0, 0, 7, 3, 0, Block.planks.blockID, Block.planks.blockID, false);
+
+ this.fillWithBlocks(world, sbb, 0, 0, 6, 10, 3, 6, Block.cobblestone.blockID, Block.cobblestone.blockID, false);
+ this.fillWithBlocks(world, sbb, 0, 0, 11, 10, 3, 11, Block.cobblestone.blockID, Block.cobblestone.blockID, false);
+ this.fillWithBlocks(world, sbb, 0, 0, 6, 0, 3, 11, Block.cobblestone.blockID, Block.cobblestone.blockID, false);
+ this.fillWithBlocks(world, sbb, 10, 0, 6, 10, 3, 11, Block.cobblestone.blockID, Block.cobblestone.blockID, false);
+
+ //Roof
+ for(int i = 3; i <= 7; i++)
+ for(int j = 1; j <= 5; j++)
+ this.placeBlockAtCurrentPosition(world, Block.woodSingleSlab.blockID, 2, i, 4, j, sbb);
+
+ for(int i = 3; i <= 7; i++)
+ for(int j = 6; j <= 6; j++)
+ this.placeBlockAtCurrentPosition(world, Block.stoneSingleSlab.blockID, 0, i, 4, j, sbb);
+
+ for(int i = 1; i <= 9; i++)
+ for(int j = 7; j <= 10; j++)
+ this.placeBlockAtCurrentPosition(world, Block.stoneSingleSlab.blockID, 3, i, 4, j, sbb);
+
+ for(int i = 2; i <= 8; i++)
+ this.placeBlockAtCurrentPosition(world, Block.woodDoubleSlab.blockID, 2, i, 4, 0, sbb);
+
+ for(int i = 1; i <= 5; i++){
+ this.placeBlockAtCurrentPosition(world, Block.woodDoubleSlab.blockID, 2, 2, 4, i, sbb);
+ this.placeBlockAtCurrentPosition(world, Block.woodDoubleSlab.blockID, 2, 8, 4, i, sbb);
+ }
+
+ for(int i = 0; i <= 2; i++){
+ this.placeBlockAtCurrentPosition(world, Block.stoneDoubleSlab.blockID, 0, i, 4, 6, sbb);
+ this.placeBlockAtCurrentPosition(world, Block.stoneDoubleSlab.blockID, 0, i + 8, 4, 6, sbb);
+ }
+
+ for(int i = 7; i <= 11; i++){
+ this.placeBlockAtCurrentPosition(world, Block.stoneDoubleSlab.blockID, 0, 0, 4, i, sbb);
+ this.placeBlockAtCurrentPosition(world, Block.stoneDoubleSlab.blockID, 0, 10, 4, i, sbb);
+ }
+
+ for(int i = 0; i <= 10; i++)
+ this.placeBlockAtCurrentPosition(world, Block.stoneDoubleSlab.blockID, 0, i, 4, 11, sbb);
+
+ //Base
+ for(int i = 2; i <= 8; i++)
+ for(int j = 0; j <= 5; j++)
+ this.placeBlockAtCurrentPosition(world, Block.planks.blockID, 1, i, 0, j, sbb);
+ this.fillWithBlocks(world, sbb, 0, 0, 6, 10, 0, 11, Block.stoneBrick.blockID, Block.stoneBrick.blockID, false);
+
+ for(int i = 6; i <= 10; i++)
+ this.placeBlockAtCurrentPosition(world, Block.stoneDoubleSlab.blockID, 0, 5, 0, i, sbb);
+
+ for(int i = 7; i <= 10; i++){
+ this.placeBlockAtCurrentPosition(world, Block.stoneBrick.blockID, 3, 1, 0, i, sbb);
+ this.placeBlockAtCurrentPosition(world, Block.stoneBrick.blockID, 3, 9, 0, i, sbb);
+ }
+
+ //Decorations
+ this.placeDoorAtCurrentPosition(world, sbb, random, 6, 1, 0, this.getMetadataWithOffset(Block.doorWood.blockID, 1));
+ this.placeDoorAtCurrentPosition(world, sbb, random, 5, 1, 6, this.getMetadataWithOffset(Block.doorWood.blockID, 1));
+
+ this.placeBlockAtCurrentPosition(world, Block.thinGlass.blockID, 0, 3, 2, 0, sbb);
+ this.placeBlockAtCurrentPosition(world, Block.thinGlass.blockID, 0, 4, 2, 0, sbb);
+ this.placeBlockAtCurrentPosition(world, Block.thinGlass.blockID, 0, 2, 2, 1, sbb);
+ this.placeBlockAtCurrentPosition(world, Block.thinGlass.blockID, 0, 2, 2, 2, sbb);
+ this.placeBlockAtCurrentPosition(world, Block.thinGlass.blockID, 0, 2, 2, 4, sbb);
+ this.placeBlockAtCurrentPosition(world, Block.thinGlass.blockID, 0, 2, 2, 5, sbb);
+ this.placeBlockAtCurrentPosition(world, Block.thinGlass.blockID, 0, 8, 2, 1, sbb);
+ this.placeBlockAtCurrentPosition(world, Block.thinGlass.blockID, 0, 8, 2, 2, sbb);
+ this.placeBlockAtCurrentPosition(world, Block.thinGlass.blockID, 0, 8, 2, 4, sbb);
+ this.placeBlockAtCurrentPosition(world, Block.thinGlass.blockID, 0, 8, 2, 5, sbb);
+
+ this.placeBlockAtCurrentPosition(world, Block.torchWood.blockID, 0, 6, 3, 1, sbb);
+ this.placeBlockAtCurrentPosition(world, Block.torchWood.blockID, 0, 3, 3, 3, sbb);
+ this.placeBlockAtCurrentPosition(world, Block.torchWood.blockID, 0, 7, 3, 3, sbb);
+ this.placeBlockAtCurrentPosition(world, Block.torchWood.blockID, 0, 5, 3, 5, sbb);
+
+ this.placeBlockAtCurrentPosition(world, Block.torchWood.blockID, 0, 5, 3, 7, sbb);
+ this.placeBlockAtCurrentPosition(world, Block.torchWood.blockID, 0, 5, 3, 10, sbb);
+ this.placeBlockAtCurrentPosition(world, Block.torchWood.blockID, 0, 1, 3, 8, sbb);
+ this.placeBlockAtCurrentPosition(world, Block.torchWood.blockID, 0, 1, 3, 9, sbb);
+ this.placeBlockAtCurrentPosition(world, Block.torchWood.blockID, 0, 9, 3, 8, sbb);
+ this.placeBlockAtCurrentPosition(world, Block.torchWood.blockID, 0, 9, 3, 9, sbb);
+
+ int bgCarpetColor = random.nextInt(16);
+
+ for(int i = 4; i <= 7; i++)
+ for(int j = 1; j <= 5; j++)
+ this.placeBlockAtCurrentPosition(world, Block.carpet.blockID, bgCarpetColor, i, 1, j, sbb);
+
+ generateChest(world, 3, 1, 1, 0, random, sbb, 2, 6);
+ generateDisplayer(world, 3, 1, 2, (coordBaseMode == 0 || coordBaseMode == 2)?1:2, random, sbb);
+ placeBlockAtCurrentPosition(world, BlockList.jewelCraftingTable.blockID, (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, 2, 6);
+
+ this.placeBlockAtCurrentPosition(world, Block.furnaceIdle.blockID, 0, 1, 1, 7, sbb);
+ this.placeBlockAtCurrentPosition(world, Block.furnaceIdle.blockID, 0, 1, 2, 7, sbb);
+ this.placeBlockAtCurrentPosition(world, Block.furnaceIdle.blockID, 0, 1, 3, 7, sbb);
+ this.placeBlockAtCurrentPosition(world, Block.furnaceIdle.blockID, 0, 1, 1, 10, sbb);
+ this.placeBlockAtCurrentPosition(world, Block.furnaceIdle.blockID, 0, 1, 2, 10, sbb);
+ this.placeBlockAtCurrentPosition(world, Block.furnaceIdle.blockID, 0, 1, 3, 10, sbb);
+
+ 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());
+
+ this.placeBlockAtCurrentPosition(world, Block.chest.blockID, 0, 9, 1, 7, sbb);
+ this.placeBlockAtCurrentPosition(world, Block.chest.blockID, 0, 9, 1, 8, sbb);
+ this.placeBlockAtCurrentPosition(world, Block.chestTrapped.blockID, 0, 9, 1, 9, sbb);
+ this.placeBlockAtCurrentPosition(world, Block.chestTrapped.blockID, 0, 9, 1, 10, sbb);
+
+
+ for (int l = 0; l < 6; ++l)
+ {
+ for (int i1 = 2; i1 < 9; ++i1)
+ {
+ this.clearCurrentPositionBlocksUpwards(world, i1, 9, l, sbb);
+ this.fillCurrentPositionBlocksDownwards(world, Block.cobblestone.blockID, 0, i1, -1, l, sbb);
+ }
+ }
+
+ for (int l = 6; l < 12; ++l)
+ {
+ for (int i1 = 0; i1 < 11; ++i1)
+ {
+ this.clearCurrentPositionBlocksUpwards(world, i1, 9, l, sbb);
+ this.fillCurrentPositionBlocksDownwards(world, Block.cobblestone.blockID, 0, i1, -1, l, sbb);
+ }
+ }
+
+ this.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 i1 = this.getXWithOffset(i, k);
+ int j1 = this.getYWithOffset(j);
+ int k1 = this.getZWithOffset(i, k);
+ int t = random.nextInt(max - min + 1) + min;
+ this.placeBlockAtCurrentPosition(world, Block.chest.blockID, metadata, i, j, k, sbb);
+ TileEntityChest chest = (TileEntityChest)world.getBlockTileEntity(i1, j1, k1);
+ while(chest != null && t > 0)
+ {
+ chest.setChestGuiName("Jeweler's Chest");
+ if(random.nextBoolean()) chest.setInventorySlotContents(random.nextInt(chest.getSizeInventory()), JewelrycraftUtil.modifiers.get(random.nextInt(JewelrycraftUtil.modifiers.size())));
+ else chest.setInventorySlotContents(random.nextInt(chest.getSizeInventory()), JewelrycraftUtil.jewel.get(random.nextInt(JewelrycraftUtil.jewel.size())));
+ t--;
+ }
+ }
+
+ public void generateTrappedChest(World world, int i, int j, int k, int metadata, Random random, StructureBoundingBox sbb, int min, int max)
+ {
+ int i1 = this.getXWithOffset(i, k);
+ int j1 = this.getYWithOffset(j);
+ int k1 = this.getZWithOffset(i, k);
+ int t = random.nextInt(max - min + 1) + min;
+ this.placeBlockAtCurrentPosition(world, Block.chestTrapped.blockID, metadata, i, j, k, sbb);
+ TileEntityChest chest = (TileEntityChest)world.getBlockTileEntity(i1, j1, k1);
+ while(chest != null && t > 0)
+ {
+ chest.setChestGuiName("Jeweler's Chest");
+ if(random.nextBoolean()) chest.setInventorySlotContents(random.nextInt(chest.getSizeInventory()), JewelrycraftUtil.modifiers.get(random.nextInt(JewelrycraftUtil.modifiers.size())));
+ else chest.setInventorySlotContents(random.nextInt(chest.getSizeInventory()), JewelrycraftUtil.jewel.get(random.nextInt(JewelrycraftUtil.jewel.size())));
+ t--;
+ }
+ }
+
+ public void generateDisplayer(World world, int i, int j, int k, int metadata, Random random, StructureBoundingBox sbb)
+ {
+ int i1 = this.getXWithOffset(i, k);
+ int j1 = this.getYWithOffset(j);
+ int k1 = this.getZWithOffset(i, k);
+ placeBlockAtCurrentPosition(world, BlockList.displayer.blockID, metadata, i, j, k, sbb);
+ TileEntityDisplayer displayer = (TileEntityDisplayer)world.getBlockTileEntity(i1, j1, k1);
+ if(displayer != null)
+ {
+ ItemStack ring = new ItemStack(ItemList.ring);
+ JewelryNBT.addMetal(ring, JewelrycraftUtil.metal.get(random.nextInt(JewelrycraftUtil.metal.size())));
+ JewelryNBT.addModifier(ring, JewelrycraftUtil.modifiers.get(random.nextInt(JewelrycraftUtil.modifiers.size())));
+ JewelryNBT.addJewel(ring, JewelrycraftUtil.jewel.get(random.nextInt(JewelrycraftUtil.jewel.size())));
+ displayer.object = ring;
+ displayer.quantity = 1;
+ displayer.hasObject = true;
+ }
+ }
+
+ public void generateSmelter(World world, int i, int j, int k, int metadata, Random random, StructureBoundingBox sbb, boolean isEmpty)
+ {
+ int i1 = this.getXWithOffset(i, k);
+ int j1 = this.getYWithOffset(j);
+ int k1 = this.getZWithOffset(i, k);
+ placeBlockAtCurrentPosition(world, BlockList.smelter.blockID, metadata, i, j, k, sbb);
+ TileEntitySmelter smelter = (TileEntitySmelter)world.getBlockTileEntity(i1, j1, k1);
+ if(smelter != null && !isEmpty)
+ {
+ smelter.moltenMetal = JewelrycraftUtil.metal.get(random.nextInt(JewelrycraftUtil.metal.size()));
+ smelter.hasMoltenMetal = true;
+ }
+ }
+
+ public void generateMolder(World world, int i, int j, int k, int metadata, Random random, StructureBoundingBox sbb, boolean hasMold, boolean hasStuff)
+ {
+ int i1 = this.getXWithOffset(i, k);
+ int j1 = this.getYWithOffset(j);
+ int k1 = this.getZWithOffset(i, k);
+ placeBlockAtCurrentPosition(world, BlockList.molder.blockID, metadata, i, j, k, sbb);
+ TileEntityMolder molder = (TileEntityMolder)world.getBlockTileEntity(i1, j1, k1);
+ if(molder != null)
+ {
+ if(hasMold){
+ int meta = random.nextInt(ItemMolds.moldsItemNames.length + 1);
+ molder.mold = new ItemStack(ItemList.molds, 1, meta);
+ molder.hasMold = true;
+ if(hasStuff){
+ ItemStack ring = new ItemStack(ItemList.ring);
+ JewelryNBT.addMetal(ring, JewelrycraftUtil.metal.get(random.nextInt(JewelrycraftUtil.metal.size())));
+ if(meta == 0) molder.jewelBase = JewelrycraftUtil.metal.get(random.nextInt(JewelrycraftUtil.metal.size()));
+ else molder.jewelBase = ring;
+ molder.hasJewelBase = true;
+ }
+ }
+ }
+ }
+
+ 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 = this.getXWithOffset(i, k);
+ int j1 = this.getYWithOffset(j);
+ int k1 = this.getZWithOffset(i, k);
+ placeBlockAtCurrentPosition(world, Block.furnaceIdle.blockID, metadata, i, j, k, sbb);
+ TileEntityFurnace furnace = (TileEntityFurnace)world.getBlockTileEntity(i1, j1, k1);
+ if(furnace != null)
+ {
+// if(random.nextBoolean()) furnace.setInventorySlotContents(1, new ItemStack(Item.coal, random.nextInt(16)));
+// if(hasMetal){
+// ItemStack metal = JewelrycraftUtil.metal.get(random.nextInt(JewelrycraftUtil.metal.size()));
+// 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.
+ */
+ protected int getVillagerType (int par1)
+ {
+ return 3000;
+ }
+} \ No newline at end of file
diff --git a/common/darkknight/jewelrycraft/worldGen/village/JCTrades.java b/common/darkknight/jewelrycraft/worldGen/village/JCTrades.java
new file mode 100644
index 0000000..4e1022d
--- /dev/null
+++ b/common/darkknight/jewelrycraft/worldGen/village/JCTrades.java
@@ -0,0 +1,142 @@
+package darkknight.jewelrycraft.worldGen.village;
+
+import java.util.Random;
+
+import net.minecraft.block.Block;
+import net.minecraft.entity.passive.EntityVillager;
+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.util.JewelryNBT;
+import darkknight.jewelrycraft.util.JewelrycraftUtil;
+
+public class JCTrades implements IVillageTradeHandler
+{
+
+ public JCTrades()
+ {
+ super();
+ }
+
+ @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:
+ {
+ result = JewelrycraftUtil.metal.get(random.nextInt(JewelrycraftUtil.metal.size()));
+ result.stackSize = 1 + random.nextInt(16);
+ ingredient = new ItemStack(Item.emerald, 8 + random.nextInt(8));
+ if(random.nextBoolean()) ingredient2 = new ItemStack(Item.emerald, 8 + random.nextInt(8));
+ break;
+ }
+ case 1:
+ {
+ result = new ItemStack(ItemList.molds, 1, random.nextInt(2));
+ ingredient = new ItemStack(Item.emerald, 1 + random.nextInt(2));
+ if(random.nextBoolean()) ingredient2 = new ItemStack(Item.emerald, 1 + random.nextInt(2));
+ break;
+ }
+ case 2:
+ {
+ result = new ItemStack(ItemList.thiefGloves);
+ ingredient = new ItemStack(Item.emerald, 16 + random.nextInt(8));
+ if(random.nextBoolean()) ingredient2 = new ItemStack(Item.emerald, 16 + random.nextInt(8));
+ break;
+ }
+ case 3:
+ {
+ result = new ItemStack(BlockList.displayer, 1 + random.nextInt(6));
+ ingredient = new ItemStack(Item.emerald, 8 + random.nextInt(32));
+ if(random.nextBoolean()) ingredient2 = new ItemStack(Block.blockEmerald, 2 + random.nextInt(6));
+ break;
+ }
+ case 4:
+ {
+ result = new ItemStack(BlockList.jewelCraftingTable);
+ ingredient = new ItemStack(Item.emerald, 8 + random.nextInt(17));
+ if(random.nextBoolean()) ingredient2 = new ItemStack(Item.emerald, 8 + random.nextInt(17));
+ break;
+ }
+ case 5:
+ {
+ result = new ItemStack(BlockList.shadowOre, 1 + random.nextInt(16));
+ ingredient = new ItemStack(Item.emerald, 8 + random.nextInt(17));
+ if(random.nextBoolean()) ingredient2 = new ItemStack(Item.emerald, 8 + random.nextInt(17));
+ break;
+ }
+ case 6:
+ {
+ result = new ItemStack(BlockList.molder);
+ ingredient = new ItemStack(Item.emerald, 1 + random.nextInt(2));
+ if(random.nextBoolean()) ingredient2 = new ItemStack(Item.emerald, 1 + random.nextInt(3));
+ break;
+ }
+ case 7:
+ {
+ result = new ItemStack(BlockList.smelter);
+ ingredient = new ItemStack(Item.emerald, 3 + random.nextInt(9));
+ if(random.nextBoolean()) ingredient2 = new ItemStack(Item.emerald, 4 + random.nextInt(2));
+ break;
+ }
+ case 8:
+ {
+ int end = random.nextInt(JewelrycraftUtil.modifiers.size());
+ result = JewelrycraftUtil.modifiers.get(end);
+ if(result.getMaxStackSize() > 1) result.stackSize = 1 + random.nextInt(16);
+ if(JewelrycraftUtil.modifiers.size() - 1 - end >= 3)
+ {
+ ingredient = new ItemStack(Item.emerald, 3 + random.nextInt(9));
+ if(random.nextBoolean()) ingredient2 = new ItemStack(Item.emerald, 4 + random.nextInt(2));
+ }
+ else
+ {
+ ingredient = new ItemStack(Item.emerald, 32 + random.nextInt(33));
+ ingredient2 = new ItemStack(Block.blockEmerald, 8 + random.nextInt(16));
+ }
+ break;
+ }
+ case 9:
+ {
+ int end = random.nextInt(JewelrycraftUtil.jewel.size());
+ result = JewelrycraftUtil.jewel.get(end);
+ result.stackSize = 1 + random.nextInt(3);
+ if(JewelrycraftUtil.modifiers.size() - 1 - end >= 1)
+ {
+ ingredient = new ItemStack(Item.emerald, 6 + random.nextInt(32));
+ if(random.nextBoolean()) ingredient2 = new ItemStack(Item.emerald, 2 + random.nextInt(16));
+ }
+ else
+ {
+ ingredient = new ItemStack(Block.blockEmerald, 16 + random.nextInt(32));
+ ingredient2 = new ItemStack(Block.blockEmerald, 8 + random.nextInt(48));
+ }
+ break;
+ }
+ default:
+ {
+ result = new ItemStack(ItemList.ring, 1, 0);
+ JewelryNBT.addMetal(result, JewelrycraftUtil.metal.get(random.nextInt(JewelrycraftUtil.metal.size())));
+ JewelryNBT.addModifier(result, JewelrycraftUtil.modifiers.get(random.nextInt(JewelrycraftUtil.modifiers.size())));
+ JewelryNBT.addJewel(result, JewelrycraftUtil.jewel.get(random.nextInt(JewelrycraftUtil.jewel.size())));
+ ingredient = new ItemStack(Item.emerald, 16 + random.nextInt(20));
+ ingredient2 = new ItemStack(Block.blockEmerald, 5 + random.nextInt(5));
+ }
+ }
+
+ recipeList.addToListWithCheck(new MerchantRecipe(ingredient, ingredient2, result));
+ }
+ }
+} \ No newline at end of file
diff --git a/common/darkknight/jewelrycraft/worldGen/village/VillageJewelryHandler.java b/common/darkknight/jewelrycraft/worldGen/village/VillageJewelryHandler.java
new file mode 100644
index 0000000..e53b4d7
--- /dev/null
+++ b/common/darkknight/jewelrycraft/worldGen/village/VillageJewelryHandler.java
@@ -0,0 +1,29 @@
+package darkknight.jewelrycraft.worldGen.village;
+
+import java.util.List;
+import java.util.Random;
+
+import net.minecraft.world.gen.structure.ComponentVillageStartPiece;
+import net.minecraft.world.gen.structure.StructureVillagePieceWeight;
+import cpw.mods.fml.common.registry.VillagerRegistry.IVillageCreationHandler;
+
+public class VillageJewelryHandler implements IVillageCreationHandler
+{
+ @Override
+ public StructureVillagePieceWeight getVillagePieceWeight (Random random, int i)
+ {
+ return new StructureVillagePieceWeight(ComponentJewelry.class, 30, i + random.nextInt(4));
+ }
+
+ @Override
+ public Class<?> getComponentClass ()
+ {
+ return ComponentJewelry.class;
+ }
+
+ @Override
+ public Object buildComponent (StructureVillagePieceWeight villagePiece, ComponentVillageStartPiece startPiece, @SuppressWarnings("rawtypes") 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