diff options
| author | OnyxDarkKnight <sor1n.iliutza16@gmail.com> | 2014-03-08 22:16:06 +0200 |
|---|---|---|
| committer | OnyxDarkKnight <sor1n.iliutza16@gmail.com> | 2014-03-08 22:16:06 +0200 |
| commit | 3e0556ee7aadfbb7695f87063662a9ca0d28175f (patch) | |
| tree | 3a5ab57ce1e64e002fc22e16e91ae62a573d5f45 /common | |
| parent | 05b5b13256c420568d1f07ed634dfd47509d53f2 (diff) | |
Lots of new things
Diffstat (limited to 'common')
15 files changed, 380 insertions, 366 deletions
diff --git a/common/darkknight/jewelrycraft/CreativeTabRings.java b/common/darkknight/jewelrycraft/CreativeTabRings.java new file mode 100644 index 0000000..2236943 --- /dev/null +++ b/common/darkknight/jewelrycraft/CreativeTabRings.java @@ -0,0 +1,57 @@ +package darkknight.jewelrycraft; + +import java.util.ArrayList; +import java.util.List; + +import darkknight.jewelrycraft.item.ItemList; +import darkknight.jewelrycraft.util.JewelryNBT; +import darkknight.jewelrycraft.util.JewelrycraftUtil; + +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraftforge.oredict.OreDictionary; + +public class CreativeTabRings extends CreativeTabs +{ + public static ArrayList<ItemStack> metal = new ArrayList<ItemStack>(); + + public CreativeTabRings(String par2Str) + { + super(par2Str); + } + + @Override + public ItemStack getIconItemStack() + { + ItemStack ring = new ItemStack(ItemList.ring); + JewelryNBT.addMetal(ring, JewelrycraftUtil.metal.get(0)); + JewelryNBT.addModifier(ring, JewelrycraftUtil.modifiers.get(3)); + JewelryNBT.addJewel(ring, JewelrycraftUtil.jewel.get(2)); + return ring; + } + + @SuppressWarnings({ "rawtypes", "unchecked" }) + public void displayAllReleventItems(List par1List) + { + 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().toLowerCase().contains("ingot") && !metal.contains(OreDictionary.getOres(OreDictionary.getOreNames()[index]).get(index2))) + metal.add(OreDictionary.getOres(OreDictionary.getOreNames()[index]).get(index2)); + index2++; + } + index2 = 0; + index++; + } + if(!metal.contains(new ItemStack(Item.ingotGold)))metal.add(new ItemStack(Item.ingotGold)); + if(!metal.contains(new ItemStack(Item.ingotIron)))metal.add(new ItemStack(Item.ingotIron)); + for(int i = 0; i < metal.size(); i++) + for(int j = 0; j < JewelrycraftUtil.modifiers.size(); j++) + for(int k = 0; k < JewelrycraftUtil.jewel.size(); k++) + par1List.add(ItemList.ring.getModifiedItemStack(metal.get(i), JewelrycraftUtil.modifiers.get(j),JewelrycraftUtil.jewel.get(k))); + } + +} diff --git a/common/darkknight/jewelrycraft/JewelrycraftMod.java b/common/darkknight/jewelrycraft/JewelrycraftMod.java index 29fe6a2..5191047 100644 --- a/common/darkknight/jewelrycraft/JewelrycraftMod.java +++ b/common/darkknight/jewelrycraft/JewelrycraftMod.java @@ -69,9 +69,10 @@ public class JewelrycraftMod implements IConnectionHandler @Override public ItemStack getIconItemStack() { - return new ItemStack(ItemList.ring, 1, 0); + return new ItemStack(BlockList.jewelCraftingTable); } }; + public static CreativeTabs rings = new CreativeTabRings("Rings"); @EventHandler public void preInit(FMLPreInitializationEvent e) @@ -80,7 +81,8 @@ public class JewelrycraftMod implements IConnectionHandler ItemList.preInit(e); BlockList.preInit(e); CraftingRecipes.preInit(e); - JewelrycraftUtil.addMetals(); + OreDictionary.registerOre("ingotShadow", new ItemStack(ItemList.shadowIngot)); + OreDictionary.registerOre("oreShadow", new ItemStack(BlockList.shadowOre)); VillagerRegistry.instance().registerVillagerId(3000); VillagerRegistry.instance().registerVillageTradeHandler(3000, new JCTrades()); @@ -100,8 +102,6 @@ public class JewelrycraftMod implements IConnectionHandler @EventHandler public void init(FMLInitializationEvent e) { - OreDictionary.registerOre("ingotShadow", new ItemStack(ItemList.shadowIngot)); - OreDictionary.registerOre("oreShadow", new ItemStack(BlockList.shadowOre)); GameRegistry.registerWorldGenerator(new Generation()); new GuiHandler(); } @@ -109,6 +109,7 @@ public class JewelrycraftMod implements IConnectionHandler @EventHandler public void postInit(FMLPostInitializationEvent e) { + JewelrycraftUtil.addMetals(); JewelrycraftUtil.addStuff(); JewelrycraftUtil.jamcrafters(); } diff --git a/common/darkknight/jewelrycraft/block/BlockCrystalizer.java b/common/darkknight/jewelrycraft/block/BlockCrystalizer.java deleted file mode 100644 index c6ea205..0000000 --- a/common/darkknight/jewelrycraft/block/BlockCrystalizer.java +++ /dev/null @@ -1,99 +0,0 @@ -package darkknight.jewelrycraft.block; - -import java.util.Random; -import net.minecraft.block.BlockContainer; -import net.minecraft.block.material.Material; -import net.minecraft.client.renderer.texture.IconRegister; -import net.minecraft.entity.item.EntityItem; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.IBlockAccess; -import net.minecraft.world.World; -import darkknight.jewelrycraft.tileentity.*; - -public class BlockCrystalizer extends BlockContainer -{ - Random rand = new Random(); - - protected BlockCrystalizer(int par1, Material par2Material) - { - super(par1, par2Material); - this.setBlockBounds(0.0F, 0F, 0.0F, 1.0F, 0.8F, 1.0F); - } - - @Override - public TileEntity createNewTileEntity(World world) - { - return new TileEntityCrystalizer(); - } - - @Override - public boolean renderAsNormalBlock() - { - return false; - } - - @Override - public boolean onBlockActivated(World world, int i, int j, int k, EntityPlayer entityPlayer, int par6, float par7, float par8, float par9) - { - TileEntityCrystalizer te = (TileEntityCrystalizer) world.getBlockTileEntity(i, j, k); - ItemStack item = entityPlayer.inventory.getCurrentItem(); - if (te != null && !world.isRemote) - { - } - return true; - } - - public void dropItem(World world, double x, double y, double z, ItemStack stack) - { - EntityItem entityitem = new EntityItem(world, x + 0.5D, y + 1D, z + 0.5D, stack); - entityitem.motionX = 0; - entityitem.motionZ = 0; - entityitem.motionY = 0.21000000298023224D; - world.spawnEntityInWorld(entityitem); - } - - public void breakBlock(World world, int i, int j, int k, int par5, int par6) - { - TileEntityCrystalizer te = (TileEntityCrystalizer) world.getBlockTileEntity(i, j, k); - if (te != null) - { - world.markTileEntityForDespawn(te); - } - super.breakBlock(world, i, j, k, par5, par6); - } - - @Override - public void onBlockClicked(World world, int i, int j, int k, EntityPlayer player) - { - TileEntityCrystalizer te = (TileEntityCrystalizer) world.getBlockTileEntity(i, j, k); - if (te != null && !world.isRemote) - { - } - } - - @Override - public boolean shouldSideBeRendered(IBlockAccess iblockaccess, int i, int j, int k, int l) - { - return false; - } - - @Override - public boolean isOpaqueCube() - { - return false; - } - - @Override - public int getRenderType() - { - return -1; - } - - @Override - public void registerIcons(IconRegister icon) - { - this.blockIcon = icon.registerIcon("jewelrycraft:crystalizer"); - } -} diff --git a/common/darkknight/jewelrycraft/config/ConfigHandler.java b/common/darkknight/jewelrycraft/config/ConfigHandler.java index 648d0bd..24450f9 100644 --- a/common/darkknight/jewelrycraft/config/ConfigHandler.java +++ b/common/darkknight/jewelrycraft/config/ConfigHandler.java @@ -11,6 +11,7 @@ public class ConfigHandler public static int idMolds = 17495; public static int idRing = 17496; public static int idClayMolds = 17497; + public static int idCrystal = 17498; public static int idShadowOre = 1750; public static int idSmelter = 1751; @@ -39,6 +40,7 @@ public class ConfigHandler idMolds = config.getItem("Molds", idMolds).getInt(); idClayMolds = config.getItem("Clay Molds", idClayMolds).getInt(); idRing = config.getItem("Ring", idRing).getInt(); + idCrystal = config.getItem("Crystal", idCrystal).getInt(); idShadowOre = config.getBlock("Shadow Ore", idShadowOre).getInt(); idShadowBlock = config.getBlock("Shadow Block", idShadowBlock).getInt(); diff --git a/common/darkknight/jewelrycraft/item/ItemCrystal.java b/common/darkknight/jewelrycraft/item/ItemCrystal.java new file mode 100644 index 0000000..325c2ce --- /dev/null +++ b/common/darkknight/jewelrycraft/item/ItemCrystal.java @@ -0,0 +1,59 @@ +package darkknight.jewelrycraft.item; + +import java.util.List; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import net.minecraft.client.renderer.texture.IconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.Icon; + +public class ItemCrystal extends Item +{ + public Icon overlay; + public static final int[] dyeColors = new int[] {1973019, 11743532, 3887386, 5320730, 2437522, 8073150, 2651799, 11250603, 4408131, 14188952, 4312372, 14602026, 6719955, 12801229, 15435844, 15790320}; + + public ItemCrystal(int par1) + { + super(par1); + this.setHasSubtypes(true); + this.setMaxDamage(0); + } + + public void registerIcons(IconRegister iconRegister) + { + itemIcon = iconRegister.registerIcon("jewelrycraft:crystal"); + overlay = iconRegister.registerIcon("jewelrycraft:crystalOverlay"); + } + + @Override + public boolean requiresMultipleRenderPasses() + { + return true; + } + + @SideOnly(Side.CLIENT) + public int getColorFromItemStack(ItemStack stack, int pass) + { + if(pass == 1 && this.getDamage(stack) != 16) return dyeColors[this.getDamage(stack)]; + return 16777215; + } + + public Icon getIcon(ItemStack stack, int pass) + { + return pass == 0 ? itemIcon : overlay; + } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + public void getSubItems(int par1, CreativeTabs par2CreativeTabs, List par3List) + { + for (int j = 0; j < 16; ++j) + { + par3List.add(new ItemStack(par1, 1, j)); + } + } + +} diff --git a/common/darkknight/jewelrycraft/item/ItemList.java b/common/darkknight/jewelrycraft/item/ItemList.java index 83bf91b..027f0a6 100644 --- a/common/darkknight/jewelrycraft/item/ItemList.java +++ b/common/darkknight/jewelrycraft/item/ItemList.java @@ -12,7 +12,8 @@ public class ItemList public static Item shadowIngot; public static Item molds; public static Item clayMolds; - public static Item ring; + public static Item crystal; + public static ItemRing ring; private static boolean isInitialized = false; @@ -24,13 +25,15 @@ public class ItemList shadowIngot = new Item(ConfigHandler.idShadowIngot - 256).setUnlocalizedName("Jewelrycraft.ingotShadow").setTextureName("jewelrycraft:ingotShadow").setCreativeTab(JewelrycraftMod.jewelrycraft); molds = new ItemMolds(ConfigHandler.idMolds - 256).setUnlocalizedName("Jewelrycraft.mold").setTextureName("Mold").setCreativeTab(JewelrycraftMod.jewelrycraft); clayMolds = new ItemClayMolds(ConfigHandler.idClayMolds - 256).setUnlocalizedName("Jewelrycraft.mold").setTextureName("Mold").setCreativeTab(JewelrycraftMod.jewelrycraft); - ring = new ItemRing(ConfigHandler.idRing - 256).setUnlocalizedName("Jewelrycraft.ring").setTextureName("jewelrycraft:ring").setCreativeTab(JewelrycraftMod.jewelrycraft); + ring = (ItemRing) new ItemRing(ConfigHandler.idRing - 256).setUnlocalizedName("Jewelrycraft.ring").setTextureName("jewelrycraft:ring"); + crystal = new ItemCrystal(ConfigHandler.idCrystal - 256).setUnlocalizedName("Jewelrycraft.crystal").setTextureName("jewelrycraft:crystal").setCreativeTab(JewelrycraftMod.jewelrycraft); GameRegistry.registerItem(thiefGloves, "thiefGloves"); GameRegistry.registerItem(shadowIngot, "shadowIngot"); GameRegistry.registerItem(molds, "molds"); GameRegistry.registerItem(clayMolds, "clayMolds"); GameRegistry.registerItem(ring, "ring"); + GameRegistry.registerItem(crystal, "crystal"); isInitialized = true; } diff --git a/common/darkknight/jewelrycraft/item/ItemRing.java b/common/darkknight/jewelrycraft/item/ItemRing.java index 184d3f3..bb09d69 100644 --- a/common/darkknight/jewelrycraft/item/ItemRing.java +++ b/common/darkknight/jewelrycraft/item/ItemRing.java @@ -64,11 +64,11 @@ public class ItemRing extends Item } @SideOnly(Side.CLIENT) - public int getColorFromItemStack(ItemStack par1ItemStack, int pass) + public int getColorFromItemStack(ItemStack stack, int pass) { try { - return color(par1ItemStack, pass); + return color(stack, pass); } catch (IOException e) { @@ -79,7 +79,8 @@ public class ItemRing extends Item public Icon getIcon(ItemStack stack, int pass) { - if (JewelryNBT.jewel(stack) != null) return pass == 0 ? itemIcon : jewel; + if(pass == 0) return itemIcon; + if(pass == 1 && JewelryNBT.jewel(stack) != null) return jewel; return itemIcon; } @@ -87,7 +88,8 @@ public class ItemRing extends Item { String domain = "", texture; ResourceManager rm = Minecraft.getMinecraft().getResourceManager(); - if (pass == 1 && JewelryNBT.ingot(stack) != null && JewelryNBT.jewel(stack) == null) + int x=0, y=0, ok = 0; + if (pass == 0 && JewelryNBT.ingot(stack) != null) { if (JewelryNBT.ingot(stack).getIconIndex().getIconName().substring(0, JewelryNBT.ingot(stack).getIconIndex().getIconName().indexOf(":") + 1) != "") domain = JewelryNBT.ingot(stack).getIconIndex().getIconName().substring(0, JewelryNBT.ingot(stack).getIconIndex().getIconName().indexOf(":") + 1).replace(":", " ").trim(); else domain = "minecraft"; @@ -96,30 +98,52 @@ public class ItemRing extends Item if (JewelryNBT.ingot(stack).getUnlocalizedName().contains("item")) ingot = new ResourceLocation(domain, "textures/items/" + texture); else ingot = new ResourceLocation(domain, "textures/blocks/" + texture); BufferedImage bufferedimage = ImageIO.read(rm.getResource(ingot).getInputStream()); - return bufferedimage.getRGB(9, 9); + while(ok == 0){ + int red = (bufferedimage.getRGB(x, y) >> 16) & 0xFF; + int green = (bufferedimage.getRGB(x, y) >> 8) & 0xFF; + int blue = bufferedimage.getRGB(x, y) & 0xFF; + if((red <= 80 && green <=80 && blue <= 80) || (red >= 180 && green >= 180 && blue >= 180)){ + if(x<bufferedimage.getTileWidth()-1) x++; + if(x>=bufferedimage.getTileWidth()-1 && y<bufferedimage.getTileWidth()-1){ + x=0; + y++; + } + if(x == bufferedimage.getTileWidth()-1 && y==bufferedimage.getTileWidth()-1)ok=1; + } + else ok=1; + } + JewelryNBT.addIngotColor(stack, bufferedimage.getRGB(x, y)); } - else if (JewelryNBT.ingot(stack) != null && JewelryNBT.jewel(stack) != null) + else if (pass == 1 && JewelryNBT.jewel(stack) != null) { - if (pass == 1) - { - if (JewelryNBT.jewel(stack).getIconIndex().getIconName().substring(0, JewelryNBT.jewel(stack).getIconIndex().getIconName().indexOf(":") + 1) != "") domain = JewelryNBT.jewel(stack).getIconIndex().getIconName().substring(0, JewelryNBT.jewel(stack).getIconIndex().getIconName().indexOf(":") + 1).replace(":", " ").trim(); - else domain = "minecraft"; - texture = JewelryNBT.jewel(stack).getIconIndex().getIconName().substring(JewelryNBT.jewel(stack).getIconIndex().getIconName().lastIndexOf(":") + 1) + ".png"; - ResourceLocation jewelLoc = null; - if (JewelryNBT.jewel(stack).getUnlocalizedName().contains("item")) jewelLoc = new ResourceLocation(domain, "textures/items/" + texture); - else jewelLoc = new ResourceLocation(domain, "textures/blocks/" + texture); - BufferedImage bufferedimage = ImageIO.read(rm.getResource(jewelLoc).getInputStream()); - return bufferedimage.getRGB(9, 4); - } - if (JewelryNBT.ingot(stack).getIconIndex().getIconName().substring(0, JewelryNBT.ingot(stack).getIconIndex().getIconName().indexOf(":") + 1) != "") domain = JewelryNBT.ingot(stack).getIconIndex().getIconName().substring(0, JewelryNBT.ingot(stack).getIconIndex().getIconName().indexOf(":") + 1).replace(":", " ").trim(); + x = 0; y = 0; ok=0; + if (JewelryNBT.jewel(stack).getIconIndex().getIconName().substring(0, JewelryNBT.jewel(stack).getIconIndex().getIconName().indexOf(":") + 1) != "") domain = JewelryNBT.jewel(stack).getIconIndex().getIconName().substring(0, JewelryNBT.jewel(stack).getIconIndex().getIconName().indexOf(":") + 1).replace(":", " ").trim(); else domain = "minecraft"; - texture = JewelryNBT.ingot(stack).getIconIndex().getIconName().substring(JewelryNBT.ingot(stack).getIconIndex().getIconName().lastIndexOf(":") + 1) + ".png"; - ResourceLocation ingot = null; - if (JewelryNBT.ingot(stack).getUnlocalizedName().contains("item")) ingot = new ResourceLocation(domain, "textures/items/" + texture); - else ingot = new ResourceLocation(domain, "textures/blocks/" + texture); - BufferedImage bufferedimage = ImageIO.read(rm.getResource(ingot).getInputStream()); - return bufferedimage.getRGB(9, 9); + texture = JewelryNBT.jewel(stack).getIconIndex().getIconName().substring(JewelryNBT.jewel(stack).getIconIndex().getIconName().lastIndexOf(":") + 1) + ".png"; + ResourceLocation jewelLoc = null; + if (JewelryNBT.jewel(stack).getUnlocalizedName().contains("item")) jewelLoc = new ResourceLocation(domain, "textures/items/" + texture); + else jewelLoc = new ResourceLocation(domain, "textures/blocks/" + texture); + BufferedImage bufferedimage = ImageIO.read(rm.getResource(jewelLoc).getInputStream()); + while(ok == 0){ + int red = (bufferedimage.getRGB(x, y) >> 16) & 0xFF; + int green = (bufferedimage.getRGB(x, y) >> 8) & 0xFF; + int blue = bufferedimage.getRGB(x, y) & 0xFF; + if((red <= 80 && green <=80 && blue <= 80) || (red >= 180 && green >= 180 && blue >= 180)){ + if(x<bufferedimage.getTileWidth()-1) x++; + if(x>=bufferedimage.getTileWidth()-1 && y<bufferedimage.getTileWidth()-1){ + x=0; + y++; + } + if(x == bufferedimage.getTileWidth()-1 && y==bufferedimage.getTileWidth()-1)ok=1; + } + else ok=1; + } + if(JewelryNBT.jewel(stack).getItem().getColorFromItemStack(JewelryNBT.jewel(stack), 1) == 16777215) JewelryNBT.addJewelColor(stack, bufferedimage.getRGB(x, y)); + else JewelryNBT.addJewelColor(stack, JewelryNBT.jewel(stack).getItem().getColorFromItemStack(JewelryNBT.jewel(stack), 1)); } + if(pass == 0 && JewelryNBT.ingot(stack) != null) return JewelryNBT.ingotColor(stack); + if(pass == 1 && JewelryNBT.jewel(stack) != null) return JewelryNBT.jewelColor(stack); + else if(JewelryNBT.ingot(stack) != null) return JewelryNBT.ingotColor(stack); return 16777215; } @@ -204,7 +228,7 @@ public class ItemRing extends Item @Override public boolean itemInteractionForEntity(ItemStack stack, EntityPlayer player, EntityLivingBase entity) { - if (!player.worldObj.isRemote && JewelryNBT.isJewelX(stack, new ItemStack(Item.netherStar)) && JewelryNBT.isModifierX(stack, new ItemStack(Block.chest)) && JewelryNBT.entity(stack, player) == null){ + if (!player.worldObj.isRemote && entity instanceof EntityLivingBase && JewelryNBT.isJewelX(stack, new ItemStack(Item.netherStar)) && JewelryNBT.isModifierX(stack, new ItemStack(Block.chest)) && JewelryNBT.entity(stack, player) == null){ JewelryNBT.addEntity(stack, entity); JewelryNBT.addEntityID(stack, entity); entity.setDead(); @@ -247,6 +271,12 @@ public class ItemRing extends Item String modeN = JewelryNBT.modeName(stack); if(modeN != null) list.add("Mode: " + modeN); + +// int colorI = JewelryNBT.ingotColor(stack); +// if(colorI != -1) list.add("Ingot Color: " + colorI); +// +// int colorJ = JewelryNBT.jewelColor(stack); +// if(colorJ != -1) list.add("Jewel Color: " + colorJ); } } @@ -255,7 +285,7 @@ public class ItemRing extends Item if (!world.isRemote) { EntityLivingBase entity = JewelryNBT.entity(stack, player); - if(entity != null){ + if(entity != null && entity instanceof EntityLivingBase){ entity.setLocationAndAngles(i + 0.5D, j + 1D, k + 0.5D, MathHelper.wrapAngleTo180_float(world.rand.nextFloat() * 360.0F), 0.0F); world.spawnEntityInWorld(entity); JewelryNBT.removeEntity(stack); @@ -403,4 +433,16 @@ public class ItemRing extends Item } } } + + public ItemStack getModifiedItemStack(ItemStack ingot, ItemStack modifier, ItemStack jewel) + { + ItemStack itemstack = new ItemStack(this); + JewelryNBT.addMetal(itemstack, ingot); + JewelryNBT.addModifier(itemstack, modifier); + JewelryNBT.addJewel(itemstack, jewel); + if(JewelryNBT.isModifierEffectType(itemstack)) JewelryNBT.addMode(itemstack, "Activated"); + if(JewelryNBT.isJewelX(itemstack, new ItemStack(Item.netherStar)) && JewelryNBT.isModifierX(itemstack, new ItemStack(Item.book))) + JewelryNBT.addMode(itemstack, "Disenchant"); + return itemstack; + } } diff --git a/common/darkknight/jewelrycraft/recipes/CraftingRecipes.java b/common/darkknight/jewelrycraft/recipes/CraftingRecipes.java index 25027db..6e396eb 100644 --- a/common/darkknight/jewelrycraft/recipes/CraftingRecipes.java +++ b/common/darkknight/jewelrycraft/recipes/CraftingRecipes.java @@ -17,15 +17,26 @@ public class CraftingRecipes { if (!isInitialized) { + //Items GameRegistry.addRecipe(new ItemStack(ItemList.thiefGloves), "x x", "yxy", "yxy", 'x', ItemList.shadowIngot, 'y', new ItemStack(Block.cloth, 1, 15)); GameRegistry.addRecipe(new ItemStack(ItemList.clayMolds, 1, 0), "xx", 'x', Item.clay); GameRegistry.addRecipe(new ItemStack(ItemList.clayMolds, 1, 1), " x ", "x x", " x ", 'x', Item.clay); + GameRegistry.addRecipe(new ItemStack(ItemList.crystal, 1, 15), " x ", "x x", " x ", 'x', Block.glass); + for(int i=0; i < 15; i++) + { + GameRegistry.addShapelessRecipe(new ItemStack(ItemList.crystal, 1, i), new Object[]{new ItemStack(ItemList.crystal, 1, 15), new ItemStack(Item.dyePowder, 1, i)}); + GameRegistry.addShapelessRecipe(new ItemStack(ItemList.crystal, 1, 15), new Object[]{new ItemStack(ItemList.crystal, 1, i), new ItemStack(Item.dyePowder, 1, 15)}); + } + + //Blocks GameRegistry.addRecipe(new ItemStack(BlockList.molder), "x x", "xxx", 'x', Block.cobblestone); GameRegistry.addRecipe(new ItemStack(BlockList.smelter), "xyx", "x x", "xzx", 'x', Block.cobblestone, 'y', Item.bucketEmpty, 'z', Item.bucketLava); GameRegistry.addRecipe(new ItemStack(BlockList.jewelCraftingTable), "xxx", "y y", "y y", 'x', Block.planks, 'y', Block.cobblestone); GameRegistry.addRecipe(new ItemStack(BlockList.displayer, 2), " x ", "xxx", "yyy", 'x', Item.ingotIron, 'y', Block.blockEmerald); GameRegistry.addRecipe(new ItemStack(BlockList.shadowBlock, 1), "xxx", "xxx", "xxx", 'x', ItemList.shadowIngot); - GameRegistry.addSmelting(BlockList.shadowOre.blockID, new ItemStack(ItemList.shadowIngot), 1.5f); + + //Smelting + GameRegistry.addSmelting(BlockList.shadowOre.blockID, new ItemStack(ItemList.shadowIngot), 1.5f); FurnaceRecipes.smelting().addSmelting(ItemList.clayMolds.itemID, 0, new ItemStack(ItemList.molds, 1, 0), 0.85F); FurnaceRecipes.smelting().addSmelting(ItemList.clayMolds.itemID, 1, new ItemStack(ItemList.molds, 1, 1), 0.85F); diff --git a/common/darkknight/jewelrycraft/renders/TileEntityDisplayerRender.java b/common/darkknight/jewelrycraft/renders/TileEntityDisplayerRender.java index 483c5be..48f24b4 100644 --- a/common/darkknight/jewelrycraft/renders/TileEntityDisplayerRender.java +++ b/common/darkknight/jewelrycraft/renders/TileEntityDisplayerRender.java @@ -17,7 +17,6 @@ import net.minecraft.item.ItemStack; import darkknight.jewelrycraft.model.ModelDisplayer; import darkknight.jewelrycraft.tileentity.TileEntityDisplayer; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; import net.minecraftforge.common.FakePlayer; @@ -45,11 +44,11 @@ public class TileEntityDisplayerRender extends TileEntitySpecialRenderer { int ind = -3; GL11.glPushMatrix(); - renderLabel(EnumChatFormatting.YELLOW + disp.object.getDisplayName(), 0F, (-0.171F)*ind, 0, block, disp); + renderLabel(disp.object.getDisplayName(), 0F, (-0.171F)*ind, 0F, block, disp, Color.YELLOW.getRGB()); GL11.glPopMatrix(); ind++; GL11.glPushMatrix(); - renderLabel(Integer.toString(disp.quantity), 0F, (-0.171F)*ind, 0, block, disp); + renderLabel(Integer.toString(disp.quantity), 0F, (-0.171F)*ind, 0F, block, disp, Color.GRAY.getRGB()); GL11.glPopMatrix(); ind++; if(disp.object.itemID != Item.map.itemID && disp.object != null && disp.object != new ItemStack(0, 0, 0) && disp.object.getTooltip(null, true) != null) @@ -59,7 +58,7 @@ public class TileEntityDisplayerRender extends TileEntitySpecialRenderer if(disp.object.getTooltip(new FakePlayer(te.worldObj, "Player"), true).get(i).toString() != "") { GL11.glPushMatrix(); - renderLabel(disp.object.getTooltip(new FakePlayer(te.worldObj, "Player"), true).get(i).toString(), 0F, (-0.171F)*ind, 0, block, disp); + renderLabel(disp.object.getTooltip(new FakePlayer(te.worldObj, "Player"), true).get(i).toString(), 0F, (-0.171F)*ind, 0F, block, disp, Color.GRAY.getRGB()); GL11.glPopMatrix(); ind++; } @@ -100,45 +99,43 @@ public class TileEntityDisplayerRender extends TileEntitySpecialRenderer OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float) modulousModifier, divModifier); } - protected void renderLabel(String par2Str, double x, double y, double z, int metadata, TileEntity te) + protected void renderLabel(String par2Str, double x, double y, double z, int metadata, TileEntity te, int color) { FontRenderer fontrenderer = RenderManager.instance.getFontRenderer(); - 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; - GL11.glRotatef(180F, 0F, 0F, 1F); - if(metadata == 0) GL11.glRotatef(0F, 0F, 1F, 0F); - else if(metadata == 1) GL11.glRotatef(270F, 0F, 1F, 0F); - else if(metadata == 2) GL11.glRotatef(180F, 0F, 1F, 0F); - else if(metadata == 3) GL11.glRotatef(90F, 0F, 1F, 0F); - GL11.glTranslatef((float)x, (float)y, (float)z + 0.45F); - GL11.glScalef(-0.015F, -var14, 0.015F); - GL11.glPushMatrix(); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glDisable(GL11.GL_DEPTH_TEST); - GL11.glDepthMask(true); - Tessellator tessellator = Tessellator.instance; - GL11.glDisable(GL11.GL_TEXTURE_2D); - int j = fontrenderer.getStringWidth(par2Str) / 2; - tessellator.startDrawingQuads(); - tessellator.setColorRGBA_F(0.2F, 0.2F, 0.2F, 0.8F); - tessellator.addVertex((double)(-33.333 - 0), -1D, 0.1D); - tessellator.addVertex((double)(-33.333 - 0), 8D, 0.1D); - tessellator.addVertex((double)(33.333 + 0), 8D, 0.1D); - tessellator.addVertex((double)(33.333 + 0), -1D, 0.1D); - tessellator.draw(); - if ((fontrenderer.getStringWidth(par2Str)/2) > 30) var17 = 0.9F / fontrenderer.getStringWidth(par2Str); - else var17 = var14; - GL11.glScalef(var17*70F, 1F, 0F); - GL11.glEnable(GL11.GL_TEXTURE_2D); - fontrenderer.drawStringWithShadow(par2Str, -j, 0, Color.GRAY.getRGB()); - GL11.glEnable(GL11.GL_DEPTH_TEST); - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glDisable(GL11.GL_BLEND); - GL11.glPopMatrix(); - } + float var14 = 0.01266667F * 1.5F; +// float var17 = 0.015F; + GL11.glRotatef(180F, 0F, 0F, 1F); + if(metadata == 0) GL11.glRotatef(0F, 0F, 1F, 0F); + else if(metadata == 1) GL11.glRotatef(270F, 0F, 1F, 0F); + else if(metadata == 2) GL11.glRotatef(180F, 0F, 1F, 0F); + else if(metadata == 3) GL11.glRotatef(90F, 0F, 1F, 0F); + GL11.glTranslatef((float)x, (float)y, (float)z + 0.45F); + GL11.glScalef(-0.015F, -var14, 0.015F); + GL11.glPushMatrix(); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDepthMask(true); + Tessellator tessellator = Tessellator.instance; + GL11.glDisable(GL11.GL_TEXTURE_2D); + int j = fontrenderer.getStringWidth(par2Str) / 2; + tessellator.startDrawingQuads(); + tessellator.setColorRGBA_F(0.2F, 0.2F, 0.2F, 0.8F); + tessellator.addVertex((double)(-33.333 - 0), -1D, 0.1D); + tessellator.addVertex((double)(-33.333 - 0), 8D, 0.1D); + tessellator.addVertex((double)(33.333 + 0), 8D, 0.1D); + tessellator.addVertex((double)(33.333 + 0), -1D, 0.1D); + tessellator.draw(); +// if ((fontrenderer.getStringWidth(par2Str)/2) > 20) var17 = 0.9F / fontrenderer.getStringWidth(par2Str); +// else var17 = var14; +// GL11.glScalef(var17*70F, 1F, 0F); + GL11.glEnable(GL11.GL_TEXTURE_2D); + int red = (color >> 16) & 0xFF; + int green = (color >> 8) & 0xFF; + int blue = color & 0xFF; + GL11.glTranslatef((float)x + 1f, (float)y + 1f, (float)z); + fontrenderer.drawString(par2Str, -j, 0, 65536 * (red/2) + 256 * (green/2) + blue/2); + GL11.glTranslatef((float)x - 1f, (float)y - 1f, (float)z - 1F); + fontrenderer.drawString(par2Str, -j, 0, color); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glPopMatrix(); } } diff --git a/common/darkknight/jewelrycraft/tileentity/TileEntityCrystalizer.java b/common/darkknight/jewelrycraft/tileentity/TileEntityCrystalizer.java deleted file mode 100644 index 5a4caeb..0000000 --- a/common/darkknight/jewelrycraft/tileentity/TileEntityCrystalizer.java +++ /dev/null @@ -1,143 +0,0 @@ -package darkknight.jewelrycraft.tileentity; - -import darkknight.jewelrycraft.config.ConfigHandler; -import darkknight.jewelrycraft.util.JewelryNBT; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.network.INetworkManager; -import net.minecraft.network.packet.Packet; -import net.minecraft.network.packet.Packet132TileEntityData; -import net.minecraft.tileentity.TileEntity; - -public class TileEntityCrystalizer extends TileEntity -{ - public boolean hasJewelry, hasModifier, hasEndItem, isDirty, hasJewel; - public ItemStack jewelry, modifier, endItem, jewel; - public int timer, effect; - public float angle; - - public TileEntityCrystalizer() - { - this.jewelry = new ItemStack(0, 0, 0); - this.modifier = new ItemStack(0, 0, 0); - this.endItem = new ItemStack(0, 0, 0); - this.jewel = new ItemStack(0, 0, 0); - this.hasJewelry = false; - this.hasModifier = false; - this.hasEndItem = false; - this.hasJewel = false; - this.timer = 0; - this.effect = 0; - this.angle = 0; - this.isDirty = false; - } - - @Override - public void writeToNBT(NBTTagCompound nbt) - { - super.writeToNBT(nbt); - nbt.setBoolean("hasJewelry", hasJewelry); - nbt.setBoolean("hasModifier", hasModifier); - nbt.setBoolean("hasEndItem", hasEndItem); - nbt.setBoolean("hasJewel", hasJewel); - nbt.setInteger("timer", timer); - nbt.setInteger("effect", effect); - nbt.setFloat("angle", angle); - - NBTTagCompound tag = new NBTTagCompound(); - NBTTagCompound tag1 = new NBTTagCompound(); - NBTTagCompound tag2 = new NBTTagCompound(); - NBTTagCompound tag3 = new NBTTagCompound(); - - this.jewelry.writeToNBT(tag); - nbt.setCompoundTag("jewelry", tag); - this.modifier.writeToNBT(tag1); - nbt.setCompoundTag("modifier", tag1); - this.endItem.writeToNBT(tag2); - nbt.setCompoundTag("endItem", tag2); - this.jewel.writeToNBT(tag3); - nbt.setCompoundTag("jewel", tag3); - } - - @Override - public void readFromNBT(NBTTagCompound nbt) - { - super.readFromNBT(nbt); - this.hasJewelry = nbt.getBoolean("hasJewelry"); - this.hasModifier = nbt.getBoolean("hasModifier"); - this.hasEndItem = nbt.getBoolean("hasEndItem"); - this.hasJewel = nbt.getBoolean("hasJewel"); - - this.timer = nbt.getInteger("timer"); - this.effect = nbt.getInteger("effect"); - this.angle = nbt.getFloat("angle"); - this.jewelry = new ItemStack(0, 0, 0); - this.jewelry.readFromNBT(nbt.getCompoundTag("jewelry")); - this.modifier = new ItemStack(0, 0, 0); - this.modifier.readFromNBT(nbt.getCompoundTag("modifier")); - this.endItem = new ItemStack(0, 0, 0); - this.endItem.readFromNBT(nbt.getCompoundTag("endItem")); - this.jewel = new ItemStack(0, 0, 0); - this.jewel.readFromNBT(nbt.getCompoundTag("jewel")); - } - - @Override - public void updateEntity() - { - super.updateEntity(); - if(isDirty){ - worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); - isDirty = true; - } - if(angle<360F)angle+=3F; - else angle=0F; - if (this.hasJewelry && (this.hasModifier || this.hasJewel) && !this.hasEndItem) - { - if (timer > 0) - { - timer--; - for (int l = 0; l < ConfigHandler.jewelryCraftingTime/(timer + 2); ++l) - { - if(this.getBlockMetadata() == 0) this.worldObj.spawnParticle("witchMagic", xCoord + 0.5F, (double) yCoord + 0.8F, zCoord + 0.2F, 0.0D, 0.0D, 0.0D); - if(this.getBlockMetadata() == 1) this.worldObj.spawnParticle("witchMagic", xCoord + 0.8F, (double) yCoord + 0.8F, zCoord + 0.5F, 0.0D, 0.0D, 0.0D); - if(this.getBlockMetadata() == 2) this.worldObj.spawnParticle("witchMagic", xCoord + 0.5F, (double) yCoord + 0.8F, zCoord + 0.8F, 0.0D, 0.0D, 0.0D); - if(this.getBlockMetadata() == 3) this.worldObj.spawnParticle("witchMagic", xCoord + 0.2F, (double) yCoord + 0.8F, zCoord + 0.5F, 0.0D, 0.0D, 0.0D); - } - } - if (timer == 0) - { - this.hasEndItem = true; - this.endItem = jewelry.copy(); - if (hasModifier && modifier != new ItemStack(0, 0, 0)) JewelryNBT.addModifier(endItem, modifier); - if (hasJewel && jewel != new ItemStack(0, 0, 0)) JewelryNBT.addJewel(endItem, jewel); - if (hasJewel && hasModifier && JewelryNBT.isJewelX(endItem, new ItemStack(Item.netherStar)) && JewelryNBT.isModifierX(endItem, new ItemStack(Item.book))) JewelryNBT.addMode(endItem, "Disenchant"); - if (hasModifier && JewelryNBT.isModifierEffectType(endItem)) JewelryNBT.addMode(endItem, "Activated"); - this.hasJewelry = false; - this.jewelry = new ItemStack(0, 0, 0); - this.hasModifier = false; - this.modifier = new ItemStack(0, 0, 0); - this.hasJewel = false; - this.jewel = new ItemStack(0, 0, 0); - timer = -1; - } - } - } - - @Override - public Packet getDescriptionPacket() - { - Packet132TileEntityData packet = (Packet132TileEntityData) super.getDescriptionPacket(); - NBTTagCompound dataTag = packet != null ? packet.data : new NBTTagCompound(); - writeToNBT(dataTag); - return new Packet132TileEntityData(xCoord, yCoord, zCoord, 1, dataTag); - } - - @Override - public void onDataPacket(INetworkManager net, Packet132TileEntityData pkt) - { - super.onDataPacket(net, pkt); - NBTTagCompound tag = pkt != null ? pkt.data : new NBTTagCompound(); - readFromNBT(tag); - } -} diff --git a/common/darkknight/jewelrycraft/util/JewelryNBT.java b/common/darkknight/jewelrycraft/util/JewelryNBT.java index 606ea4a..263b6b6 100644 --- a/common/darkknight/jewelrycraft/util/JewelryNBT.java +++ b/common/darkknight/jewelrycraft/util/JewelryNBT.java @@ -287,15 +287,19 @@ public class JewelryNBT int entityID = 0; entityID = enID.getInteger("entityID"); EntityLivingBase entity = (EntityLivingBase) EntityList.createEntityByID(entityID, player.worldObj); - entity.readFromNBT(en); - return entity; + if(entity != null && entity instanceof EntityLivingBase) + { + entity.readFromNBT(en); + return entity; + } + else return null; } return null; } public static boolean isEntityX(ItemStack stack, EntityPlayer player, EntityLivingBase entity) { - if(entity(stack, player) != null && entity(stack, player).equals(entity)) return true; + if(entity != null && entity instanceof EntityLivingBase && entity(stack, player) != null && entity(stack, player).equals(entity)) return true; return false; } @@ -409,4 +413,56 @@ public class JewelryNBT } return -1; } + + public static void addIngotColor(ItemStack item, int color) + { + NBTTagCompound itemStackData; + if (item.hasTagCompound()) + itemStackData = item.getTagCompound(); + else + { + itemStackData = new NBTTagCompound(); + item.setTagCompound(itemStackData); + } + NBTTagCompound colors = new NBTTagCompound(); + colors.setInteger("ingotColor", color); + itemStackData.setTag("ingotColor", colors); + } + + public static int ingotColor(ItemStack stack) + { + if(stack != null && stack != new ItemStack(0, 0, 0) && stack.hasTagCompound() && stack.getTagCompound().hasKey("ingotColor")) + { + NBTTagCompound colors = (NBTTagCompound) stack.getTagCompound().getTag("ingotColor"); + int color = colors.getInteger("ingotColor"); + return color; + } + return 16777215; + } + + public static void addJewelColor(ItemStack item, int color) + { + NBTTagCompound itemStackData; + if (item.hasTagCompound()) + itemStackData = item.getTagCompound(); + else + { + itemStackData = new NBTTagCompound(); + item.setTagCompound(itemStackData); + } + NBTTagCompound colors = new NBTTagCompound(); + colors.setInteger("jewelColor", color); + itemStackData.setTag("jewelColor", colors); + } + + public static int jewelColor(ItemStack stack) + { + if(stack != null && stack != new ItemStack(0, 0, 0) && stack.hasTagCompound() && stack.getTagCompound().hasKey("jewelColor")) + { + NBTTagCompound colors = (NBTTagCompound) stack.getTagCompound().getTag("jewelColor"); + int color = colors.getInteger("jewelColor"); + return color; + } + return 16777215; + } } diff --git a/common/darkknight/jewelrycraft/util/JewelrycraftUtil.java b/common/darkknight/jewelrycraft/util/JewelrycraftUtil.java index b344724..4247175 100644 --- a/common/darkknight/jewelrycraft/util/JewelrycraftUtil.java +++ b/common/darkknight/jewelrycraft/util/JewelrycraftUtil.java @@ -34,6 +34,12 @@ public class JewelrycraftUtil modifiers.add(new ItemStack(Item.potion, 1, 8270)); //Jewels + for(int i=0; i <= 16; i++) + jewel.add(new ItemStack(ItemList.crystal, 1, i)); + jewel.add(new ItemStack(Item.redstone)); + jewel.add(new ItemStack(Block.blockRedstone)); + jewel.add(new ItemStack(Item.dyePowder, 1, 4)); + jewel.add(new ItemStack(Block.blockLapis)); jewel.add(new ItemStack(Block.obsidian)); jewel.add(new ItemStack(Item.diamond)); jewel.add(new ItemStack(Item.emerald)); @@ -83,15 +89,15 @@ public class JewelrycraftUtil { while(index2 < OreDictionary.getOres(OreDictionary.getOreNames()[index]).size()) { - if(OreDictionary.getOres(OreDictionary.getOreNames()[index]).get(index2).getUnlocalizedName().contains("ingot")) + if(OreDictionary.getOres(OreDictionary.getOreNames()[index]).get(index2).getUnlocalizedName().toLowerCase().contains("ingot") && !JewelrycraftUtil.metal.contains(OreDictionary.getOres(OreDictionary.getOreNames()[index]).get(index2))) 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)); + if(!metal.contains(new ItemStack(Item.ingotGold)))metal.add(new ItemStack(Item.ingotGold)); + if(!metal.contains(new ItemStack(Item.ingotIron)))metal.add(new ItemStack(Item.ingotIron)); } public static boolean isModifier(ItemStack item) diff --git a/common/darkknight/jewelrycraft/worldGen/Generation.java b/common/darkknight/jewelrycraft/worldGen/Generation.java index 9444e6a..32da73d 100644 --- a/common/darkknight/jewelrycraft/worldGen/Generation.java +++ b/common/darkknight/jewelrycraft/worldGen/Generation.java @@ -36,7 +36,8 @@ public class Generation implements IWorldGenerator int x = i + random.nextInt(16); int y = 5 + random.nextInt(4); int z = j + random.nextInt(16); - if(world.rand.nextInt(10) == 0) world.setBlock(x, y, z, BlockList.shadowOre.blockID); + world.setBlock(x, y, z, BlockList.shadowOre.blockID); + if(random.nextInt(3) == 0) world.setBlock(x + random.nextInt(2), y + random.nextInt(1), z + random.nextInt(2), BlockList.shadowOre.blockID); } } diff --git a/common/darkknight/jewelrycraft/worldGen/village/ComponentJewelry.java b/common/darkknight/jewelrycraft/worldGen/village/ComponentJewelry.java index 3983274..2c740f5 100644 --- a/common/darkknight/jewelrycraft/worldGen/village/ComponentJewelry.java +++ b/common/darkknight/jewelrycraft/worldGen/village/ComponentJewelry.java @@ -175,12 +175,12 @@ public class ComponentJewelry extends ComponentVillage 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); + generateFurnace(world, 1, 1, 7, 0, random, sbb, 1, 2, true); + generateFurnace(world, 1, 2, 7, 0, random, sbb, 2, 3, true); + generateFurnace(world, 1, 3, 7, 0, random, sbb, 1, 3, true); + generateFurnace(world, 1, 1, 10, 0, random, sbb, 1, 2, true); + generateFurnace(world, 1, 2, 10, 0, random, sbb, 2, 3, true); + generateFurnace(world, 1, 3, 10, 0, random, sbb, 1, 3, true); 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()); @@ -188,10 +188,10 @@ public class ComponentJewelry extends ComponentVillage 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); + generateIngotChest(world, 9, 1, 7, 0, random, sbb, 3, 12, Block.chest, 5); + generateIngotChest(world, 9, 1, 8, 0, random, sbb, 5, 16, Block.chest, 3); + generateIngotChest(world, 9, 1, 9, 0, random, sbb, 3, 10, Block.chestTrapped, 2); + generateIngotChest(world, 9, 1, 10, 0, random, sbb, 3, 9, Block.chestTrapped, 6); for (int l = 0; l < 6; ++l) @@ -234,6 +234,22 @@ public class ComponentJewelry extends ComponentVillage } } + public void generateIngotChest(World world, int i, int j, int k, int metadata, Random random, StructureBoundingBox sbb, int min, int max, Block chestB, int randomAmount) + { + int i1 = 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, chestB.blockID, metadata, i, j, k, sbb); + TileEntityChest chest = (TileEntityChest)world.getBlockTileEntity(i1, j1, k1); + while(chest != null && t > 0) + { + chest.setChestGuiName("Ingot Chest"); + if(random.nextBoolean()) chest.setInventorySlotContents(random.nextInt(chest.getSizeInventory()), new ItemStack(JewelrycraftUtil.metal.get(random.nextInt(JewelrycraftUtil.metal.size())).getItem(), 2 + random.nextInt(randomAmount))); + 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); @@ -320,12 +336,11 @@ public class ComponentJewelry extends ComponentVillage 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); -// } + if(random.nextBoolean()) furnace.setInventorySlotContents(1, new ItemStack(Item.coal, 1 + random.nextInt(16))); + if(hasMetal){ + ItemStack metal = JewelrycraftUtil.metal.get(random.nextInt(JewelrycraftUtil.metal.size())); + furnace.setInventorySlotContents(2, new ItemStack(metal.getItem(), random.nextInt(max - min + 1) + min)); + } } } diff --git a/common/darkknight/jewelrycraft/worldGen/village/JCTrades.java b/common/darkknight/jewelrycraft/worldGen/village/JCTrades.java index a60696b..2a5ba6f 100644 --- a/common/darkknight/jewelrycraft/worldGen/village/JCTrades.java +++ b/common/darkknight/jewelrycraft/worldGen/village/JCTrades.java @@ -37,15 +37,15 @@ public class JCTrades implements IVillageTradeHandler 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)); + result.stackSize = 5 + random.nextInt(8); + ingredient = new ItemStack(Item.emerald, 2 + random.nextInt(2)); + if(random.nextBoolean()) ingredient2 = new ItemStack(Item.emerald, 2 + random.nextInt(2)); break; } case 1: { - result = new ItemStack(ItemList.molds, 1, random.nextInt(2)); - ingredient = new ItemStack(Item.emerald, 1 + random.nextInt(2)); + result = new ItemStack(ItemList.molds, 5 + random.nextInt(7), random.nextInt(2)); + ingredient = new ItemStack(Item.emerald, 1 + random.nextInt(1)); if(random.nextBoolean()) ingredient2 = new ItemStack(Item.emerald, 1 + random.nextInt(2)); break; } @@ -53,70 +53,76 @@ public class JCTrades implements IVillageTradeHandler { 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)); + if(random.nextBoolean()) ingredient2 = new ItemStack(Item.emerald, 8 + random.nextInt(4)); 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)); + ingredient = new ItemStack(Item.emerald, 3 + random.nextInt(8)); + if(random.nextBoolean()) ingredient2 = new ItemStack(Item.emerald, 3 + random.nextInt(8)); 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)); + ingredient = new ItemStack(Item.emerald, 1 + random.nextInt(2)); + if(random.nextBoolean()) ingredient2 = new ItemStack(Item.emerald, 1 + random.nextInt(2)); 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)); + ingredient = new ItemStack(Item.emerald, 3 + random.nextInt(4)); + if(random.nextBoolean()) ingredient2 = new ItemStack(Item.emerald, 3 + random.nextInt(4)); 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)); + result = new ItemStack(BlockList.molder, 5 + random.nextInt(5)); + ingredient = new ItemStack(Item.emerald, 1 + random.nextInt(1)); + if(random.nextBoolean()) ingredient2 = new ItemStack(Item.emerald, 1 + random.nextInt(1)); 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)); + ingredient = new ItemStack(Item.emerald, 1 + random.nextInt(2)); + if(random.nextBoolean()) ingredient2 = new ItemStack(Item.emerald, 1 + 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)); + result.stackSize = 1 + random.nextInt(JewelrycraftUtil.modifiers.size() - end); + int value = end; + if(value > 64) value = 64; + ingredient = new ItemStack(Item.emerald, 3 + random.nextInt(value)); + if(random.nextBoolean()) ingredient2 = new ItemStack(Item.emerald, 4 + random.nextInt(value)); } else { - ingredient = new ItemStack(Item.emerald, 32 + random.nextInt(33)); - ingredient2 = new ItemStack(Block.blockEmerald, 8 + random.nextInt(16)); + result.stackSize = 1 + random.nextInt(7); + ingredient = new ItemStack(Item.emerald, result.stackSize/2 + 1 + random.nextInt(7)); + ingredient2 = new ItemStack(Item.emerald, result.stackSize/2 + 1 + random.nextInt(4)); } + if(result.getMaxStackSize()<=1) result.stackSize = 1; 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) + result.stackSize = 1 + random.nextInt(JewelrycraftUtil.jewel.size() - end); + if(JewelrycraftUtil.jewel.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)); + int value = end; + if(value > 64) value = 64; + ingredient = new ItemStack(Item.emerald, 2 + random.nextInt(value)); + if(random.nextBoolean()) ingredient2 = new ItemStack(Item.emerald, 2 + random.nextInt(value)); } else { |
