diff options
| author | OnyxDarkKnight <sor1n.iliutza16@gmail.com> | 2014-04-15 23:05:32 +0300 |
|---|---|---|
| committer | OnyxDarkKnight <sor1n.iliutza16@gmail.com> | 2014-04-15 23:05:32 +0300 |
| commit | 256653501365eb4f95d3dddbcdfdc23a2a9594d5 (patch) | |
| tree | 682c8ff1f943936d173299acfa42e77462eb297c /src/main/java/darkknight | |
| parent | 4b8b13b34d7a8fd0ee7c7b13f11be9c2bf3b5d18 (diff) | |
Moved source files
Diffstat (limited to 'src/main/java/darkknight')
66 files changed, 9277 insertions, 0 deletions
diff --git a/src/main/java/darkknight/jewelrycraft/CommonProxy.java b/src/main/java/darkknight/jewelrycraft/CommonProxy.java new file mode 100644 index 0000000..354f3a9 --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/CommonProxy.java @@ -0,0 +1,9 @@ +package darkknight.jewelrycraft; + +public class CommonProxy +{ + public void registerRenderers() + { + + } +} diff --git a/src/main/java/darkknight/jewelrycraft/CreativeTabLiquids.java b/src/main/java/darkknight/jewelrycraft/CreativeTabLiquids.java new file mode 100644 index 0000000..2551628 --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/CreativeTabLiquids.java @@ -0,0 +1,50 @@ +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.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraftforge.oredict.OreDictionary; + +public class CreativeTabLiquids extends CreativeTabs +{ + public static ArrayList<ItemStack> metal = new ArrayList<ItemStack>(); + + public CreativeTabLiquids(String par2Str) + { + super(par2Str); + metal.add(new ItemStack(Items.gold_ingot)); + metal.add(new ItemStack(Items.iron_ingot)); + } + + @Override + public Item getTabIconItem() + { + return ItemList.bucket; + } + + @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++; + } + for(int i = 0; i < metal.size(); i++) par1List.add(ItemList.bucket.getModifiedItemStack(metal.get(i))); + } + +} diff --git a/src/main/java/darkknight/jewelrycraft/CreativeTabNecklaces.java b/src/main/java/darkknight/jewelrycraft/CreativeTabNecklaces.java new file mode 100644 index 0000000..3f1fe92 --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/CreativeTabNecklaces.java @@ -0,0 +1,55 @@ +package darkknight.jewelrycraft; +import java.util.ArrayList; +import java.util.List; + +import darkknight.jewelrycraft.item.ItemList; +import darkknight.jewelrycraft.util.JewelrycraftUtil; + +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraftforge.oredict.OreDictionary; + +public class CreativeTabNecklaces extends CreativeTabs +{ + public static ArrayList<ItemStack> metal = new ArrayList<ItemStack>(); + + public CreativeTabNecklaces(String par2Str) + { + super(par2Str); + metal.add(new ItemStack(Items.gold_ingot)); + metal.add(new ItemStack(Items.iron_ingot)); + } + + @Override + public Item getTabIconItem() + { + return ItemList.necklace; + } + + @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++; + } + 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.necklace.getModifiedItemStack(metal.get(i), null, JewelrycraftUtil.jewel.get(k))); + par1List.add(ItemList.necklace.getModifiedItemStack(metal.get(i), JewelrycraftUtil.modifiers.get(j), JewelrycraftUtil.jewel.get(k))); + } + } + +} diff --git a/src/main/java/darkknight/jewelrycraft/CreativeTabRings.java b/src/main/java/darkknight/jewelrycraft/CreativeTabRings.java new file mode 100644 index 0000000..4061dcf --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/CreativeTabRings.java @@ -0,0 +1,54 @@ +package darkknight.jewelrycraft; +import java.util.ArrayList; +import java.util.List; + +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraftforge.oredict.OreDictionary; +import darkknight.jewelrycraft.item.ItemList; +import darkknight.jewelrycraft.util.JewelrycraftUtil; + +public class CreativeTabRings extends CreativeTabs +{ + public static ArrayList<ItemStack> metal = new ArrayList<ItemStack>(); + + public CreativeTabRings(String par2Str) + { + super(par2Str); + metal.add(new ItemStack(Items.gold_ingot)); + metal.add(new ItemStack(Items.iron_ingot)); + } + + @Override + public Item getTabIconItem() + { + return ItemList.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++; + } + 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), null, JewelrycraftUtil.jewel.get(k))); + par1List.add(ItemList.ring.getModifiedItemStack(metal.get(i), JewelrycraftUtil.modifiers.get(j), JewelrycraftUtil.jewel.get(k))); + } + } + +} diff --git a/src/main/java/darkknight/jewelrycraft/JewelrycraftMod.java b/src/main/java/darkknight/jewelrycraft/JewelrycraftMod.java new file mode 100644 index 0000000..f6672ee --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/JewelrycraftMod.java @@ -0,0 +1,134 @@ +/* + * Mod made by DarkKnight during the Modjam 3 + * It's an awesome mod + * I love me! :D + */ + +package darkknight.jewelrycraft; + +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.logging.Logger; + +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.gen.structure.MapGenStructureIO; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.fluids.FluidContainerRegistry; +import net.minecraftforge.fluids.FluidContainerRegistry.FluidContainerData; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.oredict.OreDictionary; +import cpw.mods.fml.common.Mod; +import cpw.mods.fml.common.Mod.EventHandler; +import cpw.mods.fml.common.Mod.Instance; +import cpw.mods.fml.common.Mod.Metadata; +import cpw.mods.fml.common.ModMetadata; +import cpw.mods.fml.common.SidedProxy; +import cpw.mods.fml.common.event.FMLInitializationEvent; +import cpw.mods.fml.common.event.FMLPostInitializationEvent; +import cpw.mods.fml.common.event.FMLPreInitializationEvent; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.common.registry.VillagerRegistry; +import darkknight.jewelrycraft.block.BlockList; +import darkknight.jewelrycraft.config.ConfigHandler; +import darkknight.jewelrycraft.container.GuiHandler; +import darkknight.jewelrycraft.events.BucketHandler; +import darkknight.jewelrycraft.events.EntityEventHandler; +import darkknight.jewelrycraft.item.ItemList; +import darkknight.jewelrycraft.lib.Reference; +import darkknight.jewelrycraft.recipes.CraftingRecipes; +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) +public class JewelrycraftMod +{ + @Instance(Reference.MODID) + public static JewelrycraftMod instance; + + @Metadata(Reference.MODID) + public static ModMetadata metadata; + + @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") + { + @Override + public Item getTabIconItem() + { + return Item.getItemFromBlock(BlockList.jewelCraftingTable); + } + }; + public static CreativeTabs rings = new CreativeTabRings("Rings"); + public static CreativeTabs necklaces = new CreativeTabNecklaces("Necklaces"); + public static CreativeTabs liquids = new CreativeTabLiquids("Liquids"); + + public static File liquidsConf; + public static NBTTagCompound saveData; + + @EventHandler + public void preInit(FMLPreInitializationEvent e) throws IOException + { + ConfigHandler.preInit(e); + BlockList.preInit(e); + ItemList.preInit(e); + CraftingRecipes.preInit(e); + OreDictionary.registerOre("ingotShadow", new ItemStack(ItemList.shadowIngot)); + OreDictionary.registerOre("oreShadow", new ItemStack(BlockList.shadowOre)); + + VillagerRegistry.instance().registerVillagerId(3000); + VillagerRegistry.instance().registerVillageTradeHandler(3000, new JCTrades()); + 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.7.2"); + } + MinecraftForge.EVENT_BUS.register(new EntityEventHandler()); + MinecraftForge.EVENT_BUS.register(BucketHandler.INSTANCE); + BucketHandler.INSTANCE.buckets.put(BlockList.moltenMetal, ItemList.bucket); + + proxy.registerRenderers(); + ModMetadata metadata = e.getModMetadata(); + + List<String> authorList = new ArrayList<String>(); + authorList.add("DarkKnight (or sor1n)"); + authorList.add("bspkrs"); + + metadata.autogenerated = false; + metadata.authorList = authorList; + metadata.url = "https://github.com/sor1n/Modjam-Mod"; + + liquidsConf = new File(e.getModConfigurationDirectory(), "JLP.cfg"); + if(!liquidsConf.exists() && !liquidsConf.createNewFile()); + } + + @EventHandler + public void init(FMLInitializationEvent e) + { + GameRegistry.registerWorldGenerator(new Generation(), 0); + new GuiHandler(); + } + + @EventHandler + public void postInit(FMLPostInitializationEvent e) + { + JewelrycraftUtil.addMetals(); + JewelrycraftUtil.addStuff(); + JewelrycraftUtil.jamcrafters(); + } +} diff --git a/src/main/java/darkknight/jewelrycraft/block/BlockDisplayer.java b/src/main/java/darkknight/jewelrycraft/block/BlockDisplayer.java new file mode 100644 index 0000000..efdddff --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/block/BlockDisplayer.java @@ -0,0 +1,185 @@ +package darkknight.jewelrycraft.block; + +import java.util.Random; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockContainer; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.MathHelper; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import darkknight.jewelrycraft.tileentity.TileEntityDisplayer; + +public class BlockDisplayer extends BlockContainer +{ + Random rand = new Random(); + + protected BlockDisplayer(Material par2Material) + { + super(par2Material); + } + + @Override + public TileEntity createNewTileEntity(World world, int var2) + { + return new TileEntityDisplayer(); + } + + @Override + public boolean renderAsNormalBlock() + { + return false; + } + + @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 boolean onBlockActivated(World world, int i, int j, int k, EntityPlayer entityPlayer, int par6, float par7, float par8, float par9) + { + TileEntityDisplayer te = (TileEntityDisplayer) world.getTileEntity(i, j, k); + ItemStack item = entityPlayer.inventory.getCurrentItem(); + if (te != null && item != null && item != new ItemStack(Item.getItemById(0), 0, 0) && !world.isRemote) + { + if(!te.hasObject) + { + te.object = item.copy(); + te.object.stackSize = 1; + te.quantity += item.stackSize; + te.hasObject = true; + if (!entityPlayer.capabilities.isCreativeMode) item.stackSize = 0; + te.isDirty = true; + te.markDirty(); + } + else if(te.object.getItem() == item.getItem() && te.object != null && te.object != new ItemStack(Item.getItemById(0), 0, 0) && te.object.getItemDamage() == item.getItemDamage()) + { + if(te.object.hasTagCompound() && item.hasTagCompound() && te.object.getTagCompound().equals(item.getTagCompound())) + { + te.quantity += item.stackSize; + te.object.stackSize = 1; + if (!entityPlayer.capabilities.isCreativeMode) item.stackSize = 0; + te.isDirty = true; + te.markDirty(); + } + else if(!te.object.hasTagCompound() && !item.hasTagCompound()) + { + te.quantity += item.stackSize; + te.object.stackSize = 1; + if (!entityPlayer.capabilities.isCreativeMode) item.stackSize = 0; + te.isDirty = true; + te.markDirty(); + } + } + } + return true; + } + + @Override + public void onBlockClicked(World world, int i, int j, int k, EntityPlayer player) + { + TileEntityDisplayer te = (TileEntityDisplayer) world.getTileEntity(i, j, k); + if (te != null && !world.isRemote) + { + if (te.hasObject && te.object != null && te.object != new ItemStack(Item.getItemById(0), 0, 0) && player.inventory.addItemStackToInventory(te.object)) + { + if(player.isSneaking()) + { + if(te.quantity > te.object.getMaxStackSize()) + { + te.object.stackSize = te.object.getMaxStackSize() - 1; + player.inventory.addItemStackToInventory(te.object); + te.object.stackSize = 1; + te.quantity -= te.object.getMaxStackSize(); + } + else + { + te.object.stackSize = te.quantity - 1; + player.inventory.addItemStackToInventory(te.object); + te.hasObject = false; + te.object = new ItemStack(Item.getItemById(0), 0, 0); + te.quantity = 0; + } + te.isDirty = true; + te.markDirty(); + } + else + { + if(te.quantity >= 2) + { + player.inventory.addItemStackToInventory(te.object); + te.object.stackSize = 1; + --te.quantity; + } + else + { + player.inventory.addItemStackToInventory(te.object); + te.object.stackSize = 1; + te.hasObject = false; + te.object = new ItemStack(Item.getItemById(0), 0, 0); + te.quantity = 0; + } + te.isDirty = true; + te.markDirty(); + } + } + } + } + + public void dropItem(World world, double x, double y, double z, ItemStack stack) + { + EntityItem entityitem = new EntityItem(world, x + 0.5D, y + 1.5D, z + 0.5D, stack); + entityitem.motionX = 0; + entityitem.motionZ = 0; + entityitem.motionY = 0.11000000298023224D; + world.spawnEntityInWorld(entityitem); + } + + public void breakBlock(World world, int i, int j, int k, Block block, int par6) + { + TileEntityDisplayer te = (TileEntityDisplayer) world.getTileEntity(i, j, k); + + if (te != null && te.hasObject) + { + te.object.stackSize = te.quantity; + dropItem(te.getWorldObj(), (double)te.xCoord, (double)te.yCoord, (double)te.zCoord, te.object); + world.removeTileEntity(i, j, k); + } + + super.breakBlock(world, i, j, k, block, par6); + } + + @Override + public void onBlockPlacedBy(World world, int i, int j, int k, EntityLivingBase entityLiving, ItemStack par6ItemStack) + { + int rotation = MathHelper.floor_double(entityLiving.rotationYaw * 4.0F / 360.0F + 0.5D) & 3; + world.setBlockMetadataWithNotify(i, j, k, rotation, 2); + } + + @Override + public void registerBlockIcons(IIconRegister icon) + { + this.blockIcon = icon.registerIcon("jewelrycraft:displayer"); + } +} diff --git a/src/main/java/darkknight/jewelrycraft/block/BlockGlow.java b/src/main/java/darkknight/jewelrycraft/block/BlockGlow.java new file mode 100644 index 0000000..f8a09d4 --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/block/BlockGlow.java @@ -0,0 +1,39 @@ +package darkknight.jewelrycraft.block; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.world.World; + +public class BlockGlow extends Block +{ + protected BlockGlow() + { + super(Material.air); + } + + public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int i) + { + return null; + } + + public boolean isCollidable() + { + return false; + } + + public boolean isOpaqueCube() + { + return false; + } + + public boolean renderAsNormalBlock() + { + return false; + } + + public int getRenderType() + { + return -1; + } +} diff --git a/src/main/java/darkknight/jewelrycraft/block/BlockJCOre.java b/src/main/java/darkknight/jewelrycraft/block/BlockJCOre.java new file mode 100644 index 0000000..e6bb31c --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/block/BlockJCOre.java @@ -0,0 +1,15 @@ +package darkknight.jewelrycraft.block; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.world.World; + +public class BlockJCOre extends Block +{ + protected BlockJCOre() + { + super(Material.rock); + setHarvestLevel("pickaxe", 3); + } +} diff --git a/src/main/java/darkknight/jewelrycraft/block/BlockJewelAltar.java b/src/main/java/darkknight/jewelrycraft/block/BlockJewelAltar.java new file mode 100644 index 0000000..cbf7fef --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/block/BlockJewelAltar.java @@ -0,0 +1,119 @@ +package darkknight.jewelrycraft.block; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockContainer; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import darkknight.jewelrycraft.item.ItemList; +import darkknight.jewelrycraft.tileentity.TileEntityAltar; + +public class BlockJewelAltar extends BlockContainer +{ + @SideOnly(Side.CLIENT) + private IIcon altarSide; + @SideOnly(Side.CLIENT) + private IIcon altarBottom; + @SideOnly(Side.CLIENT) + private IIcon altarTop; + + public BlockJewelAltar() + { + super(Material.iron); + } + + public static boolean isNormalCube(int par0) + { + return true; + } + + public void registerBlockIcons(IIconRegister par1IconRegister) + { + this.altarSide = par1IconRegister.registerIcon(this.getTextureName() + "_" + "side"); + this.altarBottom = par1IconRegister.registerIcon(this.getTextureName() + "_" + "bottom"); + this.altarTop = par1IconRegister.registerIcon(this.getTextureName() + "_" + "top"); + } + + public IIcon getIcon(int par1, int par2) + { + return par1 == 1 ? this.altarTop : (par1 == 0 ? this.altarBottom : this.altarSide); + } + + @Override + public boolean onBlockActivated(World world, int i, int j, int k, EntityPlayer entityPlayer, int par6, float par7, float par8, float par9) + { + TileEntityAltar te = (TileEntityAltar) world.getTileEntity(i, j, k); + ItemStack item = entityPlayer.inventory.getCurrentItem(); + if (te != null && !world.isRemote) + { + if(item != null && item != new ItemStack(Item.getItemById(0), 0, 0) && (item.getItem() == ItemList.ring || item.getItem() == ItemList.necklace) && !te.hasObject) + { + te.object = item.copy(); + item.stackSize = 0; + te.playerName = entityPlayer.getDisplayName(); + te.isDirty = true; + te.markDirty(); + te.hasObject = true; + } + + if(te.object != null && te.object != new ItemStack(Item.getItemById(0), 0, 0) && te.hasObject && entityPlayer.isSneaking()) + { + entityPlayer.inventory.addItemStackToInventory(te.object); + te.object = new ItemStack(Item.getItemById(0), 0, 0); + te.playerName = ""; + te.isDirty = true; + te.markDirty(); + te.hasObject = false; + } + } + return true; + } + + @Override + public void onBlockClicked(World world, int i, int j, int k, EntityPlayer player) + { + TileEntityAltar te = (TileEntityAltar) world.getTileEntity(i, j, k); + if (te != null && !world.isRemote) + { + if (te.object != null && te.object != new ItemStack(Item.getItemById(0), 0, 0)) + { + } + } + } + + public void dropItem(World world, double x, double y, double z, ItemStack stack) + { + EntityItem entityitem = new EntityItem(world, x + 0.5D, y + 1.5D, z + 0.5D, stack); + entityitem.motionX = 0; + entityitem.motionZ = 0; + entityitem.motionY = 0.11000000298023224D; + world.spawnEntityInWorld(entityitem); + } + + public void breakBlock(World world, int i, int j, int k, Block block, int par6) + { + TileEntityAltar te = (TileEntityAltar) world.getTileEntity(i, j, k); + + if (te != null && te.object != null && te.object != new ItemStack(Item.getItemById(0), 0, 0)) + { + dropItem(te.getWorldObj(), (double)te.xCoord, (double)te.yCoord, (double)te.zCoord, te.object); + world.removeTileEntity(i, j, k); + } + + super.breakBlock(world, i, j, k, block, par6); + } + + @Override + public TileEntity createNewTileEntity(World world, int var2) + { + return new TileEntityAltar(); + } +} diff --git a/src/main/java/darkknight/jewelrycraft/block/BlockJewelrsCraftingTable.java b/src/main/java/darkknight/jewelrycraft/block/BlockJewelrsCraftingTable.java new file mode 100644 index 0000000..a701467 --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/block/BlockJewelrsCraftingTable.java @@ -0,0 +1,222 @@ +package darkknight.jewelrycraft.block; + +import java.util.Random; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockContainer; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.MathHelper; +import net.minecraft.util.StatCollector; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import darkknight.jewelrycraft.config.ConfigHandler; +import darkknight.jewelrycraft.tileentity.TileEntityJewelrsCraftingTable; +import darkknight.jewelrycraft.util.JewelrycraftUtil; + +public class BlockJewelrsCraftingTable extends BlockContainer +{ + Random rand = new Random(); + + protected BlockJewelrsCraftingTable(Material par2Material) + { + super(par2Material); + this.setBlockBounds(0.0F, 0F, 0.0F, 1.0F, 0.8F, 1.0F); + } + + @Override + public TileEntity createNewTileEntity(World world, int var2) + { + return new TileEntityJewelrsCraftingTable(); + } + + @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) + { + TileEntityJewelrsCraftingTable te = (TileEntityJewelrsCraftingTable) world.getTileEntity(i, j, k); + ItemStack item = entityPlayer.inventory.getCurrentItem(); + if (te != null && !world.isRemote) + { + if (!te.hasEndItem && !te.hasJewelry && item != null && JewelrycraftUtil.isJewelry(item)) + { + if(te.hasModifier && te.hasJewel && item.hasTagCompound() && item.getTagCompound().hasKey("modifier") && item.getTagCompound().hasKey("jewel")) + entityPlayer.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage.Jewelrycraft.table.jewelrymodifiedfull"))); + else if(te.hasJewel && item.hasTagCompound() && item.getTagCompound().hasKey("jewel")) + entityPlayer.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage.Jewelrycraft.table.jewelrycontainsjewel"))); + else if(te.hasModifier && item.hasTagCompound() && item.getTagCompound().hasKey("modifier")) + entityPlayer.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage.Jewelrycraft.table.jewelrycontainsmodifier"))); + else + { + te.jewelry = item.copy(); + te.hasJewelry = true; + if (!entityPlayer.capabilities.isCreativeMode) --item.stackSize; + entityPlayer.inventory.markDirty(); + world.setTileEntity(i, j, k, te); + te.isDirty = true; + te.markDirty(); + } + } + if (!te.hasEndItem && !te.hasModifier && item != null && JewelrycraftUtil.isModifier(item)) + { + if(te.hasJewelry && te.jewelry.hasTagCompound() && te.jewelry.getTagCompound().hasKey("modifier")) + entityPlayer.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage.Jewelrycraft.table.jewelrycontainsmodifier"))); + else + { + te.modifier = item.copy(); + te.modifier.stackSize = 1; + te.hasModifier = true; + if (!entityPlayer.capabilities.isCreativeMode) --item.stackSize; + entityPlayer.inventory.markDirty(); + world.setTileEntity(i, j, k, te); + te.isDirty = true; + te.markDirty(); + } + } + if (!te.hasEndItem && !te.hasJewel && item != null && JewelrycraftUtil.isJewel(item)) + { + if(te.hasJewelry && te.jewelry.hasTagCompound() && te.jewelry.getTagCompound().hasKey("jewel")) + entityPlayer.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage.Jewelrycraft.table.jewelrycontainsjewel"))); + else + { + te.jewel = item.copy(); + te.jewel.stackSize = 1; + te.hasJewel = true; + if (!entityPlayer.capabilities.isCreativeMode) --item.stackSize; + entityPlayer.inventory.markDirty(); + world.setTileEntity(i, j, k, te); + te.isDirty = true; + te.markDirty(); + } + } + if (te.timer <= 0 && !te.hasEndItem && te.hasJewelry && (te.hasModifier || te.hasJewel)){ te.timer = ConfigHandler.jewelryCraftingTime; te.angle = 0;} + if (te.hasEndItem && item != null) entityPlayer.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage.Jewelrycraft.table.hasenditem"))); + + if (te.hasModifier && entityPlayer.isSneaking()) + { + dropItem(world, (double) te.xCoord, (double) te.yCoord, (double) te.zCoord, te.modifier.copy()); + te.modifier = new ItemStack(Item.getItemById(0), 0, 0); + te.hasModifier = false; + te.timer = 0; + te.angle = 0F; + te.isDirty = true; + te.markDirty(); + world.markBlockForUpdate(i, j, k); + world.setTileEntity(i, j, k, te); + } + if (te.hasJewelry && entityPlayer.isSneaking()) + { + dropItem(world, (double) te.xCoord, (double) te.yCoord, (double) te.zCoord, te.jewelry.copy()); + te.jewelry = new ItemStack(Item.getItemById(0), 0, 0); + te.hasJewelry = false; + te.timer = 0; + te.angle = 0F; + te.isDirty = true; + te.markDirty(); + world.markBlockForUpdate(i, j, k); + world.setTileEntity(i, j, k, te); + } + if (te.hasJewel && entityPlayer.isSneaking()) + { + dropItem(world, (double) te.xCoord, (double) te.yCoord, (double) te.zCoord, te.jewel.copy()); + te.jewel = new ItemStack(Item.getItemById(0), 0, 0); + te.hasJewel = false; + te.timer = 0; + te.angle = 0F; + te.isDirty = true; + te.markDirty(); + world.markBlockForUpdate(i, j, k); + world.setTileEntity(i, j, k, te); + } + } + 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, Block par5, int par6) + { + TileEntityJewelrsCraftingTable te = (TileEntityJewelrsCraftingTable) world.getTileEntity(i, j, k); + if (te != null) + { + if (te.hasModifier) dropItem(world, (double) te.xCoord, (double) te.yCoord, (double) te.zCoord, te.modifier.copy()); + if (te.hasJewelry) dropItem(world, (double) te.xCoord, (double) te.yCoord, (double) te.zCoord, te.jewelry.copy()); + if (te.hasJewel) dropItem(world, (double) te.xCoord, (double) te.yCoord, (double) te.zCoord, te.jewel.copy()); + if (te.hasEndItem) dropItem(te.getWorldObj(), (double) te.xCoord, (double) te.yCoord, (double) te.zCoord, te.endItem.copy()); + world.removeTileEntity(i, j, k); + } + super.breakBlock(world, i, j, k, par5, par6); + } + + @Override + public void onBlockPlacedBy(World world, int i, int j, int k, EntityLivingBase entityLiving, ItemStack par6ItemStack) + { + int rotation = MathHelper.floor_double(entityLiving.rotationYaw * 4.0F / 360.0F + 0.5D) & 3; + world.setBlockMetadataWithNotify(i, j, k, rotation, 2); + } + + @Override + public void onBlockClicked(World world, int i, int j, int k, EntityPlayer player) + { + TileEntityJewelrsCraftingTable te = (TileEntityJewelrsCraftingTable) world.getTileEntity(i, j, k); + if (te != null && !world.isRemote) + { + if (te.hasEndItem) + { + dropItem(te.getWorldObj(), (double) te.xCoord, (double) te.yCoord, (double) te.zCoord, te.endItem.copy()); + te.endItem = new ItemStack(Item.getItemById(0), 0, 0); + te.hasEndItem = false; + te.isDirty = true; + te.markDirty(); + world.markBlockForUpdate(i, j, k); + world.setTileEntity(i, j, k, te); + } + else if (te.hasJewelry && (te.hasModifier || te.hasJewel) && te.timer > 0 && te.jewelry != null) player.addChatMessage(new ChatComponentText(StatCollector.translateToLocalFormatted("chatmessage.Jewelrycraft.table.iscrafting", te.jewelry.getDisplayName()) + " (" + ((ConfigHandler.jewelryCraftingTime - te.timer) * 100 / ConfigHandler.jewelryCraftingTime) + "%)")); + else if ((!te.hasModifier || !te.hasJewel) && !te.hasJewelry) player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage.Jewelrycraft.table.missingjewelryandmodifierorjewel"))); + else if (!te.hasJewelry) player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage.Jewelrycraft.table.missingjewelry"))); + else if (!te.hasModifier || !te.hasJewel) player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage.Jewelrycraft.table.missingmodifierorjewel"))); + } + } + + @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; + } + + public void registerBlockIcons(IIconRegister icon) + { + this.blockIcon = icon.registerIcon("jewelrycraft:jewelrsCraftingTable"); + } +} diff --git a/src/main/java/darkknight/jewelrycraft/block/BlockList.java b/src/main/java/darkknight/jewelrycraft/block/BlockList.java new file mode 100644 index 0000000..60d4b96 --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/block/BlockList.java @@ -0,0 +1,68 @@ +package darkknight.jewelrycraft.block; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidRegistry; +import cpw.mods.fml.common.event.FMLPreInitializationEvent; +import cpw.mods.fml.common.registry.GameRegistry; +import darkknight.jewelrycraft.JewelrycraftMod; +import darkknight.jewelrycraft.tileentity.TileEntityAltar; +import darkknight.jewelrycraft.tileentity.TileEntityBlockShadow; +import darkknight.jewelrycraft.tileentity.TileEntityDisplayer; +import darkknight.jewelrycraft.tileentity.TileEntityJewelrsCraftingTable; +import darkknight.jewelrycraft.tileentity.TileEntityMolder; +import darkknight.jewelrycraft.tileentity.TileEntitySmelter; + +public class BlockList +{ + public static Block shadowOre; + public static Block glow; + public static Block smelter; + public static Block molder; + public static Block displayer; + public static Block jewelCraftingTable; + public static Block shadowBlock; + public static Block jewelAltar; + public static BlockMoltenMetal moltenMetal; + public static Fluid moltenMetalFluid; + + private static boolean isInitialized = false; + + public static void preInit(FMLPreInitializationEvent e) + { + if (!isInitialized) + { + shadowOre = new BlockJCOre().setHardness(3.0F).setResistance(5.0F).setStepSound(Block.soundTypeStone).setBlockTextureName("jewelrycraft:oreShadow").setBlockName("Jewelrycraft.oreShadow").setCreativeTab(JewelrycraftMod.jewelrycraft); + glow = new BlockGlow().setBlockName("Jewelrycraft.glow").setLightLevel(1F); + smelter = new BlockSmelter(Material.rock).setHardness(5.0F).setResistance(6.0F).setStepSound(Block.soundTypeStone).setBlockName("Jewelrycraft.smelter").setCreativeTab(JewelrycraftMod.jewelrycraft); + molder = new BlockMolder(Material.rock).setHardness(5.0F).setResistance(6.0F).setStepSound(Block.soundTypeStone).setBlockName("Jewelrycraft.molder").setCreativeTab(JewelrycraftMod.jewelrycraft); + displayer = new BlockDisplayer(Material.iron).setHardness(5.0F).setResistance(6.0F).setStepSound(Block.soundTypeMetal).setBlockName("Jewelrycraft.displayer").setCreativeTab(JewelrycraftMod.jewelrycraft); + jewelCraftingTable = new BlockJewelrsCraftingTable(Material.rock).setHardness(3.0F).setResistance(5.0F).setStepSound(Block.soundTypeStone).setBlockName("Jewelrycraft.jewelCraftingTable").setCreativeTab(JewelrycraftMod.jewelrycraft); + shadowBlock = new BlockShadow().setHardness(5.0F).setResistance(7.0F).setStepSound(Block.soundTypeMetal).setBlockTextureName("jewelrycraft:blockShadow").setBlockName("Jewelrycraft.blockShadow").setCreativeTab(JewelrycraftMod.jewelrycraft); + jewelAltar = new BlockJewelAltar().setHardness(5.0F).setResistance(2.0F).setStepSound(Block.soundTypeMetal).setBlockTextureName("jewelrycraft:altar").setBlockName("Jewelrycraft.altar").setCreativeTab(JewelrycraftMod.jewelrycraft); + + GameRegistry.registerBlock(shadowOre, "shadowOre"); + GameRegistry.registerBlock(shadowBlock, "shadowBlock"); + GameRegistry.registerBlock(smelter, "Smelter"); + GameRegistry.registerBlock(molder, "Molder"); + GameRegistry.registerBlock(jewelCraftingTable, "jewelCraftingTable"); + GameRegistry.registerBlock(displayer, "Displayer"); + GameRegistry.registerBlock(jewelAltar, "Altar"); + + GameRegistry.registerTileEntity(TileEntitySmelter.class, "30"); + GameRegistry.registerTileEntity(TileEntityMolder.class, "31"); + GameRegistry.registerTileEntity(TileEntityJewelrsCraftingTable.class, "32"); + GameRegistry.registerTileEntity(TileEntityDisplayer.class, "33"); + GameRegistry.registerTileEntity(TileEntityBlockShadow.class, "34"); + GameRegistry.registerTileEntity(TileEntityAltar.class, "35"); + + moltenMetalFluid = new Fluid("metal.molten").setLuminosity(15).setDensity(3000).setTemperature(2000).setViscosity(6000); + if (!FluidRegistry.registerFluid(moltenMetalFluid)) moltenMetalFluid = FluidRegistry.getFluid("metal.molten"); + moltenMetal = new BlockMoltenMetal(moltenMetalFluid, Material.lava); + GameRegistry.registerBlock(moltenMetal, "moltenMetalLiquid"); + + isInitialized = true; + } + } +} diff --git a/src/main/java/darkknight/jewelrycraft/block/BlockMolder.java b/src/main/java/darkknight/jewelrycraft/block/BlockMolder.java new file mode 100644 index 0000000..1ed58d7 --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/block/BlockMolder.java @@ -0,0 +1,151 @@ +package darkknight.jewelrycraft.block; + +import java.util.Random; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockContainer; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.MathHelper; +import net.minecraft.util.StatCollector; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import darkknight.jewelrycraft.config.ConfigHandler; +import darkknight.jewelrycraft.item.ItemList; +import darkknight.jewelrycraft.tileentity.TileEntityMolder; + +public class BlockMolder extends BlockContainer +{ + Random rand = new Random(); + + protected BlockMolder(Material par2Material) + { + super(par2Material); + this.setBlockBounds(0.1F, 0F, 0.1F, 0.9F, 0.2F, 0.9F); + } + + @Override + public TileEntity createNewTileEntity(World world, int var2) + { + return new TileEntityMolder(); + } + + @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) + { + TileEntityMolder te = (TileEntityMolder) world.getTileEntity(i, j, k); + ItemStack item = entityPlayer.inventory.getCurrentItem(); + if (te != null && !world.isRemote) + { + if(item != null && !te.hasMold && item.getItem() == ItemList.molds) + { + te.mold = item.copy(); + te.hasMold = true; + if (!entityPlayer.capabilities.isCreativeMode) --item.stackSize; + entityPlayer.addChatMessage(new ChatComponentText(StatCollector.translateToLocalFormatted("chatmessage.Jewelrycraft.molder.addedmold", te.mold.getDisplayName()))); + te.isDirty = true; + te.markDirty(); + world.markTileEntityChunkModified(i, j, k, te); + } + if (te.hasMold && entityPlayer.isSneaking() && !te.hasMoltenMetal) + { + dropItem(world, (double)te.xCoord, (double)te.yCoord, (double)te.zCoord, te.mold.copy()); + te.mold = new ItemStack(Item.getItemById(0), 0, 0); + te.hasMold = false; + te.isDirty = true; + te.markDirty(); + } + else if(te.hasMoltenMetal) entityPlayer.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage.Jewelrycraft.molder.hasmoltenmetal"))); + } + return true; + } + + public void dropItem(World world, double x, double y, double z, ItemStack stack) + { + EntityItem entityitem = new EntityItem(world, x + 0.5D, y + 0.5D, z + 0.5D, stack); + entityitem.motionX = 0; + entityitem.motionZ = 0; + entityitem.motionY = 0.11000000298023224D; + world.spawnEntityInWorld(entityitem); + } + + public void breakBlock(World world, int i, int j, int k, Block par5, int par6) + { + TileEntityMolder te = (TileEntityMolder) world.getTileEntity(i, j, k); + + if (te != null) + { + if(te.hasJewelBase) dropItem(te.getWorldObj(), (double)te.xCoord, (double)te.yCoord, (double)te.zCoord, te.jewelBase.copy()); + if(te.hasMold) dropItem(world, (double)te.xCoord, (double)te.yCoord, (double)te.zCoord, te.mold.copy()); + world.removeTileEntity(i, j, k); + } + + super.breakBlock(world, i, j, k, par5, par6); + } + + @Override + public void onBlockPlacedBy(World world, int i, int j, int k, EntityLivingBase entityLiving, ItemStack par6ItemStack) + { + int rotation = MathHelper.floor_double(entityLiving.rotationYaw * 4.0F / 360.0F + 0.5D) & 3; + world.setBlockMetadataWithNotify(i, j, k, rotation, 2); + } + + @Override + public void onBlockClicked(World world, int i, int j, int k, EntityPlayer player) + { + TileEntityMolder me = (TileEntityMolder) world.getTileEntity(i, j, k); + if (me != null && !world.isRemote) + { + if (me.hasJewelBase) + { + dropItem(me.getWorldObj(), (double)me.xCoord, (double)me.yCoord, (double)me.zCoord, me.jewelBase.copy()); + me.jewelBase = new ItemStack(Item.getItemById(0), 0, 0); + me.hasJewelBase = false; + } + else if (me.hasMoltenMetal && me.cooling > 0) + player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage.Jewelrycraft.molder.metaliscooling") + " (" + ((ConfigHandler.ingotCoolingTime - me.cooling)*100/ConfigHandler.ingotCoolingTime) + "%)")); + else if (me.mold.getItem() == ItemList.molds && !me.hasMoltenMetal) + player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage.Jewelrycraft.molder.moldisempty"))); + else if (me.mold.getItem() != ItemList.molds) + player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage.Jewelrycraft.molder.moldismissing"))); + me.isDirty = true; + me.markDirty(); + } + } + + @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; + } + + public void registerBlockIcons(IIconRegister icon) + { + this.blockIcon = icon.registerIcon("jewelrycraft:molder"); + } +} diff --git a/src/main/java/darkknight/jewelrycraft/block/BlockMoltenMetal.java b/src/main/java/darkknight/jewelrycraft/block/BlockMoltenMetal.java new file mode 100644 index 0000000..9adbf59 --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/block/BlockMoltenMetal.java @@ -0,0 +1,117 @@ +package darkknight.jewelrycraft.block; + +import java.awt.image.BufferedImage; +import java.io.IOException; + +import javax.imageio.ImageIO; + +import net.minecraft.block.material.Material; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.client.resources.IResourceManager; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.util.ResourceLocation; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import net.minecraftforge.fluids.BlockFluidClassic; +import net.minecraftforge.fluids.Fluid; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import darkknight.jewelrycraft.util.JewelryNBT; +import darkknight.jewelrycraft.util.JewelrycraftUtil; + +public class BlockMoltenMetal extends BlockFluidClassic { + + @SideOnly(Side.CLIENT) + protected IIcon stillIcon; + @SideOnly(Side.CLIENT) + protected IIcon flowingIcon; + + public BlockMoltenMetal(Fluid fluid, Material material) { + super(fluid, material); + setBlockName("Jewelrycraft.moltenMetal"); + this.setQuantaPerBlock(100); + } + + @Override + public IIcon getIcon(int side, int meta) { + return (side == 0 || side == 1)? stillIcon : flowingIcon; + } + + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister register) { + stillIcon = register.registerIcon("jewelrycraft:moltenMetalStill"); + flowingIcon = register.registerIcon("jewelrycraft:moltenMetalFlow"); + } + + @Override + public boolean canDisplace(IBlockAccess world, int x, int y, int z) { + if (world.getBlock(x, y, z).getMaterial().isLiquid()) return false; + return super.canDisplace(world, x, y, z); + } + + @Override + public boolean displaceIfPossible(World world, int x, int y, int z) { + if (world.getBlock(x, y, z).getMaterial().isLiquid()) return false; + return super.displaceIfPossible(world, x, y, z); + } + + @SideOnly(Side.CLIENT) + public int colorMultiplier(IBlockAccess world, int i, int j, int k) + { +// try { +// return color(world, i, j, k); +// } catch (IOException e) { +// e.printStackTrace(); +// } + return 0; + } + + public static int color(IBlockAccess world, int i, int j, int k) throws IOException + { + String domain = "", texture; + IResourceManager rm = Minecraft.getMinecraft().getResourceManager(); + BufferedImage icon; + ItemStack item = new ItemStack(BlockList.moltenMetal); + JewelryNBT.addMetal(item, new ItemStack(JewelrycraftUtil.liquids.get(String.valueOf(i) + " " + String.valueOf(j) + " " + String.valueOf(k)))); + int x=0, y=0, ok = 0, red, green, blue; + if (JewelryNBT.ingot(item) != null && JewelryNBT.ingot(item).getIconIndex() != null && JewelryNBT.ingotColor(item) == 16777215) + { + String ingotIconName = JewelryNBT.ingot(item).getIconIndex().getIconName(); + + if (ingotIconName.substring(0, ingotIconName.indexOf(":") + 1) != "") domain = ingotIconName.substring(0, ingotIconName.indexOf(":") + 1).replace(":", " ").trim(); + else domain = "minecraft"; + + texture = ingotIconName.substring(ingotIconName.lastIndexOf(":") + 1) + ".png"; + ResourceLocation ingot = null; + + if (JewelryNBT.ingot(item).getUnlocalizedName().contains("item")) ingot = new ResourceLocation(domain, "textures/items/" + texture); + else ingot = new ResourceLocation(domain, "textures/blocks/" + texture); + + icon = ImageIO.read(rm.getResource(ingot).getInputStream()); + while(ok == 0) + { + red = (icon.getRGB(x, y) >> 16) & 0xFF; + green = (icon.getRGB(x, y) >> 8) & 0xFF; + blue = icon.getRGB(x, y) & 0xFF; + if((red <= 80 && green <= 80 && blue <= 80) || (red >= 180 && green >= 180 && blue >= 180)) + { + if(x<icon.getTileWidth()-1) x++; + if(x>=icon.getTileWidth()-1 && y<icon.getTileWidth()-1) + { + x=0; + y++; + } + if(x == icon.getTileWidth()-1 && y==icon.getTileWidth()-1) ok=1; + } + else ok=1; + } + JewelryNBT.addIngotColor(item, icon.getRGB(x, y)); + } + if(JewelryNBT.ingot(item) != null) return JewelryNBT.ingotColor(item); + return 16777215; + } +} diff --git a/src/main/java/darkknight/jewelrycraft/block/BlockShadow.java b/src/main/java/darkknight/jewelrycraft/block/BlockShadow.java new file mode 100644 index 0000000..acce92f --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/block/BlockShadow.java @@ -0,0 +1,117 @@ +package darkknight.jewelrycraft.block; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.block.Block; +import net.minecraft.block.BlockContainer; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.init.Blocks; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.Facing; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; +import darkknight.jewelrycraft.tileentity.TileEntityBlockShadow; + +public class BlockShadow extends BlockContainer +{ + private IIcon[] iconArray; + private static final String __OBFID = "CL_00000312"; + + public BlockShadow() + { + super(Material.iron); + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + } + + public int getRenderBlockPass() + { + return 1; + } + + public boolean isBeaconBase(World worldObj, int x, int y, int z, int beaconX, int beaconY, int beaconZ) + { + return true; + } + + public boolean isOpaqueCube() + { + return false; + } + + public boolean renderAsNormalBlock() + { + return false; + } + + public boolean isBlockSolidOnSide(World world, int x, int y, int z, ForgeDirection side) + { + return false; + } + + public static boolean isNormalCube(int par0) + { + return true; + } + + @Override + public TileEntity createNewTileEntity(World world, int var2) + { + return new TileEntityBlockShadow(); + } + + public void registerBlockIcons(IIconRegister par1IconRegister) + { + this.iconArray = new IIcon[16]; + + for (int i = 0; i < this.iconArray.length; ++i) + { + this.iconArray[i] = par1IconRegister.registerIcon(this.getTextureName() + (15 - i)); + } + } + + public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) + { + if(world.getBlockMetadata(x, y, z) == 15) return null; + return super.getCollisionBoundingBoxFromPool(world, x, y, z); + } + + public void setBlockBoundsBasedOnState(IBlockAccess par1IBlockAccess, int par2, int par3, int par4) + { + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + } + + public boolean shouldSideBeRendered(IBlockAccess p_149646_1_, int p_149646_2_, int p_149646_3_, int p_149646_4_, int p_149646_5_) + { + Block block = p_149646_1_.getBlock(p_149646_2_, p_149646_3_, p_149646_4_); + + if (this == BlockList.shadowBlock) + { + if (block == this) + { + return false; + } + } + + return block == this ? false : super.shouldSideBeRendered(p_149646_1_, p_149646_2_, p_149646_3_, p_149646_4_, p_149646_5_); + } + + public boolean hasComparatorInputOverride() + { + return true; + } + + public int getComparatorInputOverride(World world, int x, int y, int z, int meta) + { + return world.getBlockMetadata(x, y, z); + } + + @SideOnly(Side.CLIENT) + public IIcon getIcon(int side, int meta) + { + return this.iconArray[meta]; + } +} diff --git a/src/main/java/darkknight/jewelrycraft/block/BlockSmelter.java b/src/main/java/darkknight/jewelrycraft/block/BlockSmelter.java new file mode 100644 index 0000000..176a6f2 --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/block/BlockSmelter.java @@ -0,0 +1,197 @@ +package darkknight.jewelrycraft.block; + +import java.util.Random; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockContainer; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.MathHelper; +import net.minecraft.util.StatCollector; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import darkknight.jewelrycraft.config.ConfigHandler; +import darkknight.jewelrycraft.tileentity.TileEntityMolder; +import darkknight.jewelrycraft.tileentity.TileEntitySmelter; +import darkknight.jewelrycraft.util.JewelrycraftUtil; + +public class BlockSmelter extends BlockContainer +{ + Random rand = new Random(); + + protected BlockSmelter(Material par2Material) + { + super(par2Material); + } + + @Override + public TileEntity createNewTileEntity(World world, int var2) + { + return new TileEntitySmelter(); + } + + @Override + public boolean renderAsNormalBlock() + { + return false; + } + + public void dropItem(World world, double x, double y, double z, ItemStack stack) + { + EntityItem entityitem = new EntityItem(world, x + 0.5D, y + 1.3D, z + 0.5D, stack); + entityitem.motionX = 0; + entityitem.motionZ = 0; + entityitem.motionY = 0.11000000298023224D; + world.spawnEntityInWorld(entityitem); + } + + public void breakBlock(World world, int i, int j, int k, Block par5, int par6) + { + TileEntitySmelter te = (TileEntitySmelter) world.getTileEntity(i, j, k); + if (te != null && te.hasMetal){ + dropItem(world, (double)te.xCoord, (double)te.yCoord, (double)te.zCoord, te.metal.copy()); + world.removeTileEntity(i, j, k); + } + super.breakBlock(world, i, j, k, par5, par6); + } + + @Override + public boolean onBlockActivated(World world, int i, int j, int k, EntityPlayer entityPlayer, int par6, float par7, float par8, float par9) + { + TileEntitySmelter te = (TileEntitySmelter) world.getTileEntity(i, j, k); + ItemStack item = entityPlayer.inventory.getCurrentItem(); + if (te != null && !world.isRemote) + { + int index = -1; + for(int a = 0; a < JewelrycraftUtil.jamcraftPlayers.size(); a++) if(entityPlayer.getDisplayName().equals(JewelrycraftUtil.jamcraftPlayers.get(a))) index = a; + if (!te.hasMetal && !te.hasMoltenMetal && item != null && (item.getUnlocalizedName().toLowerCase().contains("ingot") || index != -1) && !item.getUnlocalizedName().toLowerCase().contains("mold")) + { + entityPlayer.addChatMessage(new ChatComponentText(StatCollector.translateToLocalFormatted("chatmessage.Jewelrycraft.smelter.nowsmeltingingot", item.getDisplayName()))); + te.metal = item.copy(); + te.metal.stackSize = 1; + te.hasMetal = true; + te.melting = ConfigHandler.ingotMeltingTime; + if (!entityPlayer.capabilities.isCreativeMode) --item.stackSize; + te.isDirty = true; + te.markDirty(); + } + else if (te.hasMetal && !te.hasMoltenMetal && item != null && item.getDisplayName().contains("Ingot") && !item.getDisplayName().contains("Mold")) + entityPlayer.addChatMessage(new ChatComponentText(StatCollector.translateToLocalFormatted("chatmessage.Jewelrycraft.smelter.alreadyhasingot", te.metal.getDisplayName()))); + else if (te.hasMoltenMetal) + entityPlayer.addChatMessage(new ChatComponentText(StatCollector.translateToLocalFormatted("chatmessage.Jewelrycraft.smelter.hasmolteningot", te.moltenMetal.getDisplayName()))); + else if (item != null && !item.getUnlocalizedName().toLowerCase().contains("ingot") && item.getDisplayName().contains("Ingot")) + entityPlayer.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage.Jewelrycraft.smelter.itemrenamedtoingot"))); + else if (item != null && (!item.getUnlocalizedName().toLowerCase().contains("ingot") || item.getUnlocalizedName().toLowerCase().contains("mold"))) + entityPlayer.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage.Jewelrycraft.smelter.itemneedstobeingot"))); + + if (te.hasMetal && entityPlayer.isSneaking()) + { + dropItem(world, (double)te.xCoord, (double)te.yCoord, (double)te.zCoord, te.metal.copy()); + te.hasMetal = false; + te.melting = -1; + te.isDirty = true; + te.markDirty(); + world.markBlockForUpdate(i, j, k); + world.setTileEntity(i, j, k, te); + } + if(te != null) world.setTileEntity(i, j, k, te); + } + return true; + } + + @Override + public void onBlockClicked(World world, int i, int j, int k, EntityPlayer player) + { + TileEntitySmelter te = (TileEntitySmelter) world.getTileEntity(i, j, k); + TileEntityMolder me = null; + if (world.getBlockMetadata(i, j, k) == 0 && world.getTileEntity(i, j, k - 1) != null && world.getTileEntity(i, j, k - 1) instanceof TileEntityMolder) + me = (TileEntityMolder) world.getTileEntity(i, j, k - 1); + else if (world.getBlockMetadata(i, j, k) == 1 && world.getTileEntity(i + 1, j, k) != null && world.getTileEntity(i + 1, j, k) instanceof TileEntityMolder) + me = (TileEntityMolder) world.getTileEntity(i + 1, j, k); + else if (world.getBlockMetadata(i, j, k) == 2 && world.getTileEntity(i, j, k + 1) != null && world.getTileEntity(i, j, k + 1) instanceof TileEntityMolder) + me = (TileEntityMolder) world.getTileEntity(i, j, k + 1); + else if (world.getBlockMetadata(i, j, k) == 3 && world.getTileEntity(i - 1, j, k) != null && world.getTileEntity(i - 1, j, k) instanceof TileEntityMolder) + me = (TileEntityMolder) world.getTileEntity(i - 1, j, k); + + if (te != null && me != null && !world.isRemote) + { + if (te.hasMoltenMetal && isConnectedToMolder(world, i, j, k) && me != null && me.hasMold && !me.hasMoltenMetal && !me.hasJewelBase) + { + me.moltenMetal = te.moltenMetal; + me.hasMoltenMetal = true; + me.cooling = ConfigHandler.ingotCoolingTime; + te.moltenMetal = new ItemStack(Item.getItemById(0), 0, 0); + te.hasMoltenMetal = false; + te.isDirty = true; + te.markDirty(); + world.markBlockForUpdate(i, j, k); + world.setTileEntity(i, j, k, te); + } + else if (te.hasMetal && te.melting > 0) + player.addChatMessage(new ChatComponentText(StatCollector.translateToLocalFormatted("chatmessage.Jewelrycraft.smelter.metalismelting", te.metal.getDisplayName()) + " (" + ((ConfigHandler.ingotMeltingTime - te.melting)*100/ConfigHandler.ingotMeltingTime) + "%)")); + else if (te.hasMoltenMetal && !isConnectedToMolder(world, i, j, k)) + player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage.Jewelrycraft.smelter.molderismissing"))); + else if (!me.hasMold && te.hasMoltenMetal) + player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage.Jewelrycraft.smelter.molderhasnomold"))); + else if (me.hasMoltenMetal && te.hasMoltenMetal) + player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage.Jewelrycraft.smelter.molderhasmoltenmetal"))); + else if (me.hasJewelBase && te.hasMoltenMetal) + player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage.Jewelrycraft.smelter.modlerhasitem"))); + else + player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage.Jewelrycraft.smelter.empty"))); + } + + } + + public boolean isConnectedToMolder(World world, int i, int j, int k) + { + int blockMeta = world.getBlockMetadata(i, j, k); + if (blockMeta == 0 && world.getBlock(i, j, k - 1) instanceof BlockMolder) + return true; + else if (blockMeta == 1 && world.getBlock(i + 1, j, k) instanceof BlockMolder) + return true; + else if (blockMeta == 2 && world.getBlock(i, j, k + 1) instanceof BlockMolder) + return true; + else if (blockMeta == 3 && world.getBlock(i - 1, j, k) instanceof BlockMolder) + return true; + return false; + } + + @Override + public void onBlockPlacedBy(World world, int i, int j, int k, EntityLivingBase entityLiving, ItemStack par6ItemStack) + { + int rotation = MathHelper.floor_double(entityLiving.rotationYaw * 4.0F / 360.0F + 0.5D) & 3; + world.setBlockMetadataWithNotify(i, j, k, rotation, 2); + } + + @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; + } + + public void registerBlockIcons(IIconRegister icon) + { + this.blockIcon = icon.registerIcon("jewelrycraft:smelter"); + } + +} diff --git a/src/main/java/darkknight/jewelrycraft/client/ClientProxy.java b/src/main/java/darkknight/jewelrycraft/client/ClientProxy.java new file mode 100644 index 0000000..e086e94 --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/client/ClientProxy.java @@ -0,0 +1,21 @@ +package darkknight.jewelrycraft.client; + +import net.minecraft.util.ResourceLocation; +import cpw.mods.fml.client.registry.ClientRegistry; +import cpw.mods.fml.common.registry.VillagerRegistry; +import darkknight.jewelrycraft.CommonProxy; +import darkknight.jewelrycraft.renders.*; +import darkknight.jewelrycraft.tileentity.*; + +public class ClientProxy extends CommonProxy +{ + @Override + public void registerRenderers() + { + ClientRegistry.bindTileEntitySpecialRenderer(TileEntitySmelter.class, new TileEntitySmelterRender()); + ClientRegistry.bindTileEntitySpecialRenderer(TileEntityMolder.class, new TileEntityMolderRender()); + ClientRegistry.bindTileEntitySpecialRenderer(TileEntityJewelrsCraftingTable.class, new TileEntityJewelrsCraftingTableRender()); + ClientRegistry.bindTileEntitySpecialRenderer(TileEntityDisplayer.class, new TileEntityDisplayerRender()); + VillagerRegistry.instance().registerVillagerSkin(3000, new ResourceLocation("jewelrycraft", "textures/entities/jeweler.png")); + } +} diff --git a/src/main/java/darkknight/jewelrycraft/client/GuiGuide.java b/src/main/java/darkknight/jewelrycraft/client/GuiGuide.java new file mode 100644 index 0000000..fbf02ee --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/client/GuiGuide.java @@ -0,0 +1,215 @@ +package darkknight.jewelrycraft.client; + +import java.util.ArrayList; +import java.util.List; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.inventory.Container; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; +import net.minecraft.world.World; + +import org.lwjgl.opengl.GL11; + +import darkknight.jewelrycraft.block.BlockList; +import darkknight.jewelrycraft.container.GuiRectangle; +import darkknight.jewelrycraft.container.GuiTab; +import darkknight.jewelrycraft.container.GuiTabBlocks; +import darkknight.jewelrycraft.container.GuiTabItems; +import darkknight.jewelrycraft.container.GuiTabJewelsAndModifiers; +import darkknight.jewelrycraft.container.GuiTabNecklaces; +import darkknight.jewelrycraft.container.GuiTabRings; + +public class GuiGuide extends GuiContainer +{ + public int page, rot, del; + public boolean prevHover, nextHover; + World world; + private final GuiTab[] tabs; + private GuiTab activeTab; + + public GuiGuide(Container container, World world) + { + super(container); + page = 1; + rot = 0; + del = 0; + this.world = world; + + tabs = new GuiTab[] { + new GuiTabBlocks(0), + new GuiTabItems(1), + new GuiTabJewelsAndModifiers(2), + new GuiTabRings(3), + new GuiTabNecklaces(4) + }; + + activeTab = tabs[0]; + } + + @Override + protected void drawGuiContainerBackgroundLayer(float f, int i, int j) + { + nextHover = false; + prevHover = false; + if(del == 0) rot++; + del++; + if(del >= 2) del = 0; + Minecraft.getMinecraft().getTextureManager().bindTexture(new ResourceLocation("jewelrycraft", "textures/gui/guidePage.png")); + drawTexturedModalRect(guiLeft + 147/2 + 20, guiTop - 10, 0, 0, 145, 180); + Minecraft.getMinecraft().getTextureManager().bindTexture(new ResourceLocation("jewelrycraft", "textures/gui/guidePageFlip.png")); + drawTexturedModalRect(guiLeft - 147/2 + 21, guiTop - 10, 0, 0, 145, 180); + + for (GuiRectangle tab : tabs) { + int srcX = 24; + int sizeX = 19; + + if (tab == activeTab) { + srcX += 38; + sizeX +=3; + }else if(tab.inRect(this, i, j)) { + srcX += 19; + } + + tab.draw(this, srcX, 180, sizeX, 18); + } + + if(i >= guiLeft + 195 + 20 && i <= guiLeft + 195 + 20 + 11 && j >= guiTop + 127 + 20 && j <= guiTop + 127 + 20 + 14 && page + 2 <= activeTab.getMaxPages()) + { + drawTexturedModalRect(guiLeft + 195 + 20, guiTop + 127 + 20, 0, 180, 11, 14); + nextHover = true; + } + + if(i >= guiLeft + 20 - 61 && i <= guiLeft - 61 + 20 + 11 && j >= guiTop + 127 + 20 && j <= guiTop + 127 + 20 + 14 && page - 2 > 0) + { + drawTexturedModalRect(guiLeft - 61 + 20, guiTop + 127 + 20, 11, 180, 11, 14); + prevHover = true; + } + + activeTab.drawBackground(this, i, j, page); + activeTab.drawBackground(this, i, j, page + 1); + + ArrayList<String> text = new ArrayList<String>(); + text.add(Integer.toString(page)); + this.drawHoveringText(text, guiLeft - 10 + 20 - text.get(0).length(), guiTop + 150 + 20, fontRendererObj); + text.remove(Integer.toString(page)); + text.add(Integer.toString(page + 1)); + this.drawHoveringText(text, guiLeft - 10 + 20 + 147 - text.get(0).length(), guiTop + 150 + 20, fontRendererObj); + + for(int tab = 0; tab < tabs.length; tab++) + renderItem(tabs[tab].getIcon(), guiLeft - 52, guiTop + 26 + tab*19, activeTab.getIcon()); + + } + + protected void drawGuiContainerForegroundLayer(int x, int y) + { + activeTab.drawForeground(this, x, y, page); + activeTab.drawForeground(this, x, y, page + 1); + + for (GuiTab tab : tabs) { + tab.drawString(this, x, y, tab.getName()); + } + } + + @Override + protected void mouseClicked(int x, int y, int button) + { + if(nextHover && page+2 <= activeTab.getMaxPages()) page+=2; + else if (prevHover && page > 1) page-=2; + + activeTab.mouseClick(this, x, y, button); + + for (GuiTab tab : tabs) { + if (activeTab != tab) { + if (tab.inRect(this, x, y)) { + activeTab = tab; + page = 1; + break; + } + } + } + } + + public void renderItem(ItemStack item, float x, float y, ItemStack activeIcon) + { + GL11.glPushMatrix(); + GL11.glDisable(GL11.GL_LIGHTING); + EntityItem entityitem = new EntityItem(world, 0.0D, 0.0D, 0.0D, item); + entityitem.hoverStart = 0.0F; + if(item.isItemEqual(new ItemStack(BlockList.jewelAltar))) + { + y-=4; + } + GL11.glTranslatef(x, y, 100); + + float scale = 30F; + GL11.glScalef(-scale, scale, scale); + + if(activeIcon != null && item.isItemEqual(activeIcon)) GL11.glRotatef(rot, 0, 1, 0); + if(item.isItemEqual(new ItemStack(BlockList.jewelAltar))) + { + GL11.glRotatef(160.0F, 1.0F, 0.0F, 0.0F); + GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F); + } + else GL11.glRotatef(180.0F, 0.0F, 0.0F, 1.0F); + + if(RenderManager.instance.options.fancyGraphics) + RenderManager.instance.renderEntityWithPosYaw(entityitem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F); + else + { + GL11.glRotatef(180F, 0F, 1F, 0F); + RenderManager.instance.options.fancyGraphics = true; + RenderManager.instance.renderEntityWithPosYaw(entityitem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F); + RenderManager.instance.options.fancyGraphics = false; + } + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glPopMatrix(); + + } + + public void renderItem(ItemStack item, float x, float y, float scale) + { + GL11.glPushMatrix(); + EntityItem entityitem = new EntityItem(world, 0.0D, 0.0D, 0.0D, item); + entityitem.hoverStart = 0.0F; + GL11.glTranslatef(x, y, 100); + GL11.glScalef(-scale, scale, scale); + GL11.glRotatef(160.0F, 1.0F, 0.0F, 0.0F); + GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(rot, 0.0F, 1.0F, 0.0F); + if(RenderManager.instance.options.fancyGraphics) + RenderManager.instance.renderEntityWithPosYaw(entityitem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F); + else + { + RenderManager.instance.options.fancyGraphics = true; + RenderManager.instance.renderEntityWithPosYaw(entityitem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F); + RenderManager.instance.options.fancyGraphics = false; + } + GL11.glPopMatrix(); + } + + public int getLeft() + { + return guiLeft; + } + + public int getTop() + { + return guiTop; + } + + public FontRenderer getFont() + { + return fontRendererObj; + } + + @SuppressWarnings("rawtypes") + public void drawHoverString(List lst, int x, int y) + { + drawHoveringText(lst, x, y, fontRendererObj); + } +}
\ No newline at end of file diff --git a/src/main/java/darkknight/jewelrycraft/client/GuiRingChest.java b/src/main/java/darkknight/jewelrycraft/client/GuiRingChest.java new file mode 100644 index 0000000..f711558 --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/client/GuiRingChest.java @@ -0,0 +1,39 @@ +package darkknight.jewelrycraft.client; + +import org.lwjgl.opengl.GL11; + +import darkknight.jewelrycraft.container.ContainerRingChest; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.util.ResourceLocation; + +public class GuiRingChest extends GuiContainer +{ + public ContainerRingChest container; + + public GuiRingChest(ContainerRingChest container) + { + super(container); + this.container = container; + xSize = 176; + ySize = 166; + } + + @Override + public void drawGuiContainerBackgroundLayer(float f, int mouseX, int mouseY) + { + GL11.glColor3f(1, 1, 1); + + Minecraft.getMinecraft().getTextureManager().bindTexture(new ResourceLocation("jewelrycraft", "textures/gui/chest_ring.png")); + + drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize); + } + + @Override + public void drawGuiContainerForegroundLayer(int mouseX, int mouseY) + { + fontRendererObj.drawString("Linked Chest", 8, 6, 0x404040); + fontRendererObj.drawString("Inventory", 8, 72, 0x404040); + } +} diff --git a/src/main/java/darkknight/jewelrycraft/config/ConfigHandler.java b/src/main/java/darkknight/jewelrycraft/config/ConfigHandler.java new file mode 100644 index 0000000..e9040c9 --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/config/ConfigHandler.java @@ -0,0 +1,32 @@ +package darkknight.jewelrycraft.config; + +import net.minecraftforge.common.config.Configuration; +import cpw.mods.fml.common.event.FMLPreInitializationEvent; + +public class ConfigHandler +{ + private static Configuration config; + public static int ingotCoolingTime = 200; + public static int ingotMeltingTime = 1500; + public static int jewelryCraftingTime = 2000; + + private static boolean isInitialized = false; + + public static void preInit(FMLPreInitializationEvent e) + { + if (!isInitialized) + { + config = new Configuration(e.getSuggestedConfigurationFile()); + + config.load(); + + ingotCoolingTime = config.get("timers", "Molder Ingot Cooling Time", ingotCoolingTime).getInt(); + ingotMeltingTime = config.get("timers", "Ingot Melting Time", ingotMeltingTime).getInt(); + jewelryCraftingTime = config.get("timers", "Jewelry Crafting Time", jewelryCraftingTime).getInt(); + + config.save(); + + isInitialized = true; + } + } +} diff --git a/src/main/java/darkknight/jewelrycraft/container/ContainerGuide.java b/src/main/java/darkknight/jewelrycraft/container/ContainerGuide.java new file mode 100644 index 0000000..ef05cc4 --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/container/ContainerGuide.java @@ -0,0 +1,18 @@ +package darkknight.jewelrycraft.container; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; + +/** + * User: joel / Date: 16.12.13 / Time: 22:36 + */ +public class ContainerGuide extends Container { + + public ContainerGuide() { + } + + @Override + public boolean canInteractWith(EntityPlayer entityplayer) { + return true; + } +}
\ No newline at end of file diff --git a/src/main/java/darkknight/jewelrycraft/container/ContainerRingChest.java b/src/main/java/darkknight/jewelrycraft/container/ContainerRingChest.java new file mode 100644 index 0000000..2728941 --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/container/ContainerRingChest.java @@ -0,0 +1,71 @@ +package darkknight.jewelrycraft.container; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntityChest; + +public class ContainerRingChest extends Container +{ + public TileEntityChest theChest; + + public ContainerRingChest(InventoryPlayer inv, TileEntityChest chest) + { + theChest = chest; + + int x, y; + + for (x = 0; x < 9; x++) + addSlotToContainer(new SlotRingChest(inv, x, 8 + (18 * x), 142, x == inv.currentItem)); + for (y = 0; y < 3; y++) + for (x = 0; x < 9; x++) + addSlotToContainer(new Slot(inv, x + 9 + (y * 9), 8 + (18 * x), 84 + (y * 18))); + + for (y = 0; y < 3; y++) + for (x = 0; x < 9; x++) + addSlotToContainer(new SlotRingChest(chest, 26 - (x + (y * 9)), 8 + (18 * (8 - x)), 17 + ((2 - y) * 18), false)); + } + @Override + public boolean canInteractWith(EntityPlayer player) + { + return true; + } + + @Override + public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par2) + { + ItemStack itemstack = null; + Slot slot = (Slot)this.inventorySlots.get(par2); + + if (slot != null && slot.getHasStack()) + { + ItemStack itemstack1 = slot.getStack(); + itemstack = itemstack1.copy(); + + if (par2 < 27) + { + if (!this.mergeItemStack(itemstack1, 27, this.inventorySlots.size(), true)) + { + return null; + } + } + else if (!this.mergeItemStack(itemstack1, 0, 27, false)) + { + return null; + } + + if (itemstack1.stackSize == 0) + { + slot.putStack((ItemStack)null); + } + else + { + slot.onSlotChanged(); + } + } + + return itemstack; + } +} diff --git a/src/main/java/darkknight/jewelrycraft/container/GuiHandler.java b/src/main/java/darkknight/jewelrycraft/container/GuiHandler.java new file mode 100644 index 0000000..3efe71c --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/container/GuiHandler.java @@ -0,0 +1,40 @@ +package darkknight.jewelrycraft.container; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.tileentity.TileEntityChest; +import net.minecraft.world.World; +import cpw.mods.fml.common.network.IGuiHandler; +import cpw.mods.fml.common.network.NetworkRegistry; +import darkknight.jewelrycraft.JewelrycraftMod; +import darkknight.jewelrycraft.client.GuiGuide; +import darkknight.jewelrycraft.client.GuiRingChest; + +public class GuiHandler implements IGuiHandler +{ + public GuiHandler() + { + NetworkRegistry.INSTANCE.registerGuiHandler(JewelrycraftMod.instance, this); + } + + @Override + public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) + { + switch(ID) + { + case 0: return new ContainerRingChest(player.inventory, (TileEntityChest) world.getTileEntity(x, y, z)); + case 1: return new ContainerGuide(); + default: return null; + } + } + + @Override + public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) + { + switch(ID) + { + case 0: return new GuiRingChest((ContainerRingChest) getServerGuiElement(ID, player, world, x, y, z)); + case 1: return new GuiGuide((ContainerGuide) getServerGuiElement(ID, player, world, x, y, z), world); + default: return null; + } + } +} diff --git a/src/main/java/darkknight/jewelrycraft/container/GuiRectangle.java b/src/main/java/darkknight/jewelrycraft/container/GuiRectangle.java new file mode 100644 index 0000000..76dee04 --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/container/GuiRectangle.java @@ -0,0 +1,66 @@ +package darkknight.jewelrycraft.container; + +import java.util.Arrays; + +import net.minecraft.item.ItemStack; + +import darkknight.jewelrycraft.client.GuiGuide; + +public class GuiRectangle +{ + + private int x; + private int y; + private int w; + private int h; + + public GuiRectangle(int x, int y, int w, int h) + { + this.x = x; + this.y = y; + this.w = w; + this.h = h; + } + + public boolean inRect(GuiGuide gui, int mouseX, int mouseY) + { + mouseX -= gui.getLeft(); + mouseY -= gui.getTop(); + + return x <= mouseX && mouseX <= x + w && y <= mouseY && mouseY <= y + h; + } + + public void setX(int x) + { + this.x = x; + } + + public void setY(int y) + { + this.y = y; + } + + + public void draw(GuiGuide gui, int srcX, int srcY) + { + gui.drawTexturedModalRect(gui.getLeft() + x, gui.getTop() + y, srcX, srcY, w, h); + } + + + public void draw(GuiGuide gui, int srcX, int srcY, int width, int height) + { + gui.drawTexturedModalRect(gui.getLeft() + x, gui.getTop() + y, srcX, srcY, width, height); + } + + public void drawString(GuiGuide gui, int mouseX, int mouseY, String str) + { + if (inRect(gui, mouseX, mouseY)) { + gui.drawHoverString(Arrays.asList(str.split("\n")), mouseX - gui.getLeft(), mouseY - gui.getTop()); + } + } + + public ItemStack getIcon() + { + return null; + } +} diff --git a/src/main/java/darkknight/jewelrycraft/container/GuiTab.java b/src/main/java/darkknight/jewelrycraft/container/GuiTab.java new file mode 100644 index 0000000..c092ba6 --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/container/GuiTab.java @@ -0,0 +1,37 @@ +package darkknight.jewelrycraft.container; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import darkknight.jewelrycraft.client.GuiGuide; + +@SideOnly(Side.CLIENT) +public abstract class GuiTab extends GuiRectangle +{ + int values, del; + private String name; + + public GuiTab(String name, int id) + { + super(-62, 10 + 19*id, 19, 18); + this.name = name; + values = 0; + del = 0; + } + + public String getName() + { + return name; + } + + public abstract void drawBackground(GuiGuide gui, int x, int y, int page); + public abstract void drawForeground(GuiGuide gui, int x, int y, int page); + public void mouseClick(GuiGuide gui, int x, int y, int button) {} + public void mouseMoveClick(GuiGuide gui, int x, int y, int button, long timeSinceClicked) {} + public void mouseReleased(GuiGuide gui, int x, int y, int button) {} + + public int getMaxPages() + { + return 1; + } + +} diff --git a/src/main/java/darkknight/jewelrycraft/container/GuiTabBlocks.java b/src/main/java/darkknight/jewelrycraft/container/GuiTabBlocks.java new file mode 100644 index 0000000..9627cf1 --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/container/GuiTabBlocks.java @@ -0,0 +1,295 @@ +package darkknight.jewelrycraft.container; + +import java.util.ArrayList; + +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import darkknight.jewelrycraft.block.BlockList; +import darkknight.jewelrycraft.client.GuiGuide; +import darkknight.jewelrycraft.item.ItemList; + +public class GuiTabBlocks extends GuiTab +{ + + public GuiTabBlocks(int id) + { + super("Blocks", id); + } + + public ItemStack getIcon() + { + return new ItemStack(BlockList.jewelAltar); + } + + @Override + public void drawBackground(GuiGuide gui, int x, int y, int page) + { + ArrayList<String> text = new ArrayList<String>(); + ArrayList<ItemStack> items = new ArrayList<ItemStack>(); + int xPos = (page%2==0)?107:-35; + switch(page) + { + case 1: + text.add(" This ore is extremely"); + text.add("rare and can be found"); + text.add("only between Y level 5"); + text.add("and 8. It can only be"); + text.add("mined using a diamond"); + text.add("pickaxe."); + Page.addImageTextPage(gui, gui.getLeft() + xPos, gui.getTop(), new ItemStack(BlockList.shadowOre), text, 90f); + break; + case 2: + text.add(" The Shadow Block is"); + text.add("crafted using 9 shadow"); + text.add("ingots. It has been"); + text.add("discovered that it"); + text.add("poseses abnormal"); + text.add("properties in the"); + text.add("shadow. The darker it"); + items.add(new ItemStack(BlockList.shadowBlock)); + for(int i = 1; i <= 9; i++) items.add(new ItemStack(ItemList.shadowIngot)); + Page.addCraftingRecipeTextPage(gui, gui.getLeft() + xPos, gui.getTop(), false, text, items, x, y); + break; + case 3: + text.add("is, the more"); + text.add("transparent it will be,"); + text.add("until it becomes"); + text.add("walkable through. If a"); + text.add("comparator is attached"); + text.add("to it, the output"); + text.add("strength will be equal"); + text.add("to the value of"); + text.add("darkness it is in."); + Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text); + break; + case 4: + text.add(" The smelter is one of"); + text.add("the first blocks needed"); + text.add("to get started with"); + text.add("Jewelrycraft. Requiring"); + text.add("just some cobble and"); + text.add("a couple buckets, it's"); + text.add("the most important"); + items.add(new ItemStack(BlockList.smelter)); + items.add(new ItemStack(Blocks.cobblestone)); + items.add(new ItemStack(Items.bucket)); + items.add(new ItemStack(Blocks.cobblestone)); + items.add(new ItemStack(Blocks.cobblestone)); + items.add(null); + items.add(new ItemStack(Blocks.cobblestone)); + items.add(new ItemStack(Blocks.cobblestone)); + items.add(new ItemStack(Items.lava_bucket)); + items.add(new ItemStack(Blocks.cobblestone)); + Page.addCraftingRecipeTextPage(gui, gui.getLeft() + xPos, gui.getTop(), false, text, items, x, y); + break; + case 5: + text.add("block as it can melt"); + text.add("ingots which can be"); + text.add("made into pieces of"); + text.add("jewellery, like rings"); + text.add("or necklaces. To use"); + text.add("the block all you need"); + text.add("to do is right click"); + text.add("on it with any ingot."); + text.add("If left clicked while"); + text.add("smelting, a message"); + text.add("will appear saying the"); + text.add("percentage it is done."); + Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text); + break; + case 6: + text.add("If left clicked when"); + text.add("it's done smelting,"); + text.add("a message will be"); + text.add("displayed, mentioning"); + text.add("the contents of the"); + text.add("block."); + Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text); + break; + case 7: + text.add(" The molder is a key"); + text.add("piece in creating"); + text.add("jewellery. You need"); + text.add("to pour the molten"); + text.add("metal out of the"); + text.add("smelter somewhere."); + text.add("That somewhere is the"); + + items.add(new ItemStack(BlockList.molder)); + items.add(new ItemStack(Blocks.cobblestone)); + items.add(null); + items.add(new ItemStack(Blocks.cobblestone)); + for(int i = 1; i <= 3; i++) items.add(new ItemStack(Blocks.cobblestone)); + Page.addCraftingRecipeTextPage(gui, gui.getLeft() + xPos, gui.getTop(), false, text, items, x, y); + break; + case 8: + text.add("molder. But before"); + text.add("pouring the molten"); + text.add("metal in it, you must"); + text.add("first add a mold."); + text.add("You can do that by"); + text.add("simply right clicking"); + text.add("the block with the"); + text.add("mold of your choice."); + text.add("If you want to get the"); + text.add("mold out, simply crouch"); + text.add("and right click it with"); + text.add("an empty hand."); + Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text); + break; + case 9: + text.add(" Once you have a mold"); + text.add("inside, left click on"); + text.add("the smelter and wait"); + text.add("for the metal to cool"); + text.add("down. When it's done,"); + text.add("left click on the"); + text.add("molder to get the"); + text.add("jewellery. " + EnumChatFormatting.DARK_RED + "Be aware"); + text.add(EnumChatFormatting.DARK_RED + "that this block must be"); + text.add(EnumChatFormatting.DARK_RED + "placed directly in front"); + text.add(EnumChatFormatting.DARK_RED + "of the smelter,"); + text.add(EnumChatFormatting.DARK_RED + "otherwise it won't work!"); + Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text); + break; + case 10: + text.add(" Your jewellery on"); + text.add("their own don't do"); + text.add("much. They need to be"); + text.add("modified a bit and the"); + text.add("only way to do that is"); + text.add("by using this block."); + text.add("Simply right click the"); + if(del == 0) values++; + del++; + if(del >= 300) del = 0; + if(values >= 4) values = 0; + items.add(new ItemStack(BlockList.jewelCraftingTable)); + for(int i = 1; i <= 3; i++)items.add(new ItemStack(Blocks.planks, 1, values)); + items.add(new ItemStack(Blocks.cobblestone)); + items.add(null); + items.add(new ItemStack(Blocks.cobblestone)); + items.add(new ItemStack(Blocks.cobblestone)); + items.add(null); + items.add(new ItemStack(Blocks.cobblestone)); + Page.addCraftingRecipeTextPage(gui, gui.getLeft() + xPos, gui.getTop(), false, text, items, x, y); + break; + case 11: + text.add("block while holding the"); + text.add("jewellery to place it in."); + text.add("After that just add in"); + text.add("a jewel or a modifier,"); + text.add("or even both, to the"); + text.add("block. To do that simply"); + text.add("right click with them on"); + text.add("the block. Once it's"); + text.add("done modifying, left"); + text.add("click on it to retrieve"); + text.add("the modified item. If"); + text.add("you wish to know how"); + Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text); + break; + case 12: + text.add("much is left before the"); + text.add("transformation is done,"); + text.add("simply left click on the"); + text.add("table in the process."); + text.add(" A list with all the"); + text.add("possible modifiers is"); + text.add("located in a separate"); + text.add("tab."); + Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text); + break; + case 13: + text.add(" This block can store"); + text.add("any jewellery in it"); + text.add("and activate their"); + text.add("effects as it were a"); + text.add("player. However, it"); + text.add("does not work with"); + text.add("everything. You can"); + items.add(new ItemStack(BlockList.jewelAltar)); + items.add(new ItemStack(Blocks.end_stone)); + items.add(new ItemStack(Blocks.wool, 1, 5)); + items.add(new ItemStack(Blocks.end_stone)); + items.add(new ItemStack(Blocks.nether_brick)); + items.add(new ItemStack(Blocks.wool, 1, 5)); + items.add(new ItemStack(Blocks.nether_brick)); + items.add(new ItemStack(Blocks.nether_brick)); + items.add(new ItemStack(Blocks.nether_brick)); + items.add(new ItemStack(Blocks.nether_brick)); + Page.addCraftingRecipeTextPage(gui, gui.getLeft() + xPos, gui.getTop(), false, text, items, x, y); + break; + case 14: + text.add("find out which jewellery"); + text.add("works by looking in"); + text.add("their apropriate tab."); + text.add(" Each item will have a"); + text.add("note where it is"); + text.add("mentioned their effect"); + text.add("when placed in this"); + text.add("block."); + Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text); + break; + case 15: + text.add(" The Storage"); + text.add("Displayer, as the"); + text.add("name suggests, can"); + text.add("store a large amount"); + text.add("of a single item/block"); + text.add("placed in it. This will"); + text.add("display all possible"); + items.add(new ItemStack(BlockList.displayer)); + items.add(null); + items.add(new ItemStack(Items.iron_ingot)); + items.add(null); + items.add(new ItemStack(Items.iron_ingot)); + items.add(new ItemStack(Items.iron_ingot)); + items.add(new ItemStack(Items.iron_ingot)); + items.add(new ItemStack(Blocks.emerald_block)); + items.add(new ItemStack(Blocks.emerald_block)); + items.add(new ItemStack(Blocks.emerald_block)); + Page.addCraftingRecipeTextPage(gui, gui.getLeft() + xPos, gui.getTop(), false, text, items, x, y); + break; + case 16: + text.add("infromation about the"); + text.add("object in it, such as"); + text.add("the name, durability,"); + text.add("enchantments and many"); + text.add("more. Below the name"); + text.add("is shown the amount"); + text.add("stored. To store"); + text.add("something in it simply"); + text.add("right click with that"); + text.add("object on it and the"); + text.add("whole amount of items"); + text.add("or blocks will be"); + Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text); + break; + case 17: + text.add("immediately stored"); + text.add("inside. To retrieve"); + text.add("a single item just"); + text.add("left click the block."); + text.add("If you wish to get"); + text.add("a whole stack, just"); + text.add("crouch and left click."); + Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text); + break; + default:; + } + } + + public int getMaxPages() + { + return 17; + } + + @Override + public void drawForeground(GuiGuide gui, int x, int y, int page) + { + } + +} diff --git a/src/main/java/darkknight/jewelrycraft/container/GuiTabItems.java b/src/main/java/darkknight/jewelrycraft/container/GuiTabItems.java new file mode 100644 index 0000000..a4ea44e --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/container/GuiTabItems.java @@ -0,0 +1,278 @@ +package darkknight.jewelrycraft.container; + +import java.awt.Desktop; +import java.net.URL; +import java.util.ArrayList; + +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import darkknight.jewelrycraft.block.BlockList; +import darkknight.jewelrycraft.client.GuiGuide; +import darkknight.jewelrycraft.item.ItemList; + +public class GuiTabItems extends GuiTab +{ + + public GuiTabItems(int id) + { + super("Items", id); + } + + public ItemStack getIcon() + { + return new ItemStack(ItemList.thiefGloves); + } + + @Override + public void drawBackground(GuiGuide gui, int x, int y, int page) + { + ArrayList<String> text = new ArrayList<String>(); + ArrayList<ItemStack> items = new ArrayList<ItemStack>(); + int xPos = (page%2==0)?107:-35; + switch(page) + { + case 1: + text.add(" Shadow ingots are"); + text.add("obtained by smelting"); + text.add("shadow ore. They are"); + text.add("used in a few recipes"); + text.add("and an important key"); + text.add("for making some"); + text.add("jewellery work."); + items.add(new ItemStack(BlockList.shadowOre)); + items.add(new ItemStack(ItemList.shadowIngot)); + Page.addSmeltingRecipeTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text, items, x, y); + break; + case 2: + text.add(" These gloves allow"); + text.add("you to steal the trades"); + text.add("the pesky Testificates"); + text.add("have to offer."); + text.add(" To use these simply"); + text.add("open their gui at least"); + text.add("once, then crouch and"); + items.add(new ItemStack(ItemList.thiefGloves)); + items.add(new ItemStack(ItemList.shadowIngot)); + items.add(null); + items.add(new ItemStack(ItemList.shadowIngot)); + items.add(new ItemStack(Blocks.wool, 1, 15)); + items.add(new ItemStack(ItemList.shadowIngot)); + items.add(new ItemStack(Blocks.wool, 1, 15)); + items.add(new ItemStack(Blocks.wool, 1, 15)); + items.add(new ItemStack(ItemList.shadowIngot)); + items.add(new ItemStack(Blocks.wool, 1, 15)); + Page.addCraftingRecipeTextPage(gui, gui.getLeft() + xPos, gui.getTop(), false, text, items, x, y); + break; + case 3: + text.add("right click on the them"); + text.add("to steal the trades."); + text.add("A villager has 7 of the"); + text.add("same trade item. So, for"); + text.add("example, if he wants 2"); + text.add("emeralds in exchange"); + text.add("for 4 diamonds, you will"); + text.add("get 28 diamonds from"); + text.add("him, because 7*4=28."); + text.add("However, if you have"); + text.add("traded with him before,"); + text.add("then he will have that"); + Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text); + break; + case 4: + text.add("many times less of the"); + text.add("item. This has a maximum"); + text.add("of 10 uses before it"); + text.add("breaks."); + Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text); + break; + case 5: + text.add(" In order to get the"); + text.add("ingot back from the"); + text.add("smelter you need a"); + text.add("mold for it. However,"); + text.add("this mold can't be used."); + text.add("It is too soft. It needs"); + text.add("to be hardened in"); + text.add("order for it to be used."); + items.add(new ItemStack(ItemList.clayMolds, 1, 0)); + items.add(new ItemStack(Items.clay_ball)); + items.add(new ItemStack(Items.clay_ball)); + Page.addCraftingRecipeTextPage(gui, gui.getLeft() + xPos, gui.getTop(), true, text, items, x, y); + break; + case 6: + text.add(" By smelting the clay_ball"); + text.add("mold you get a harder"); + text.add("version which can be"); + text.add("used to create ingots."); + text.add("Simply right click with"); + text.add("this on a molder to"); + text.add("attach it and you're"); + text.add("ready to go."); + items.add(new ItemStack(ItemList.clayMolds, 1, 0)); + items.add(new ItemStack(ItemList.molds, 1, 0)); + Page.addSmeltingRecipeTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text, items, x, y); + break; + case 7: + text.add(" In order to create a"); + text.add("ring you need a mold"); + text.add("for it. However, this"); + text.add("one can't be used. It is"); + text.add("too soft. It needs to be"); + text.add("hardened in order for"); + text.add("it to be used."); + items.add(new ItemStack(ItemList.clayMolds, 1, 1)); + items.add(null); + items.add(new ItemStack(Items.clay_ball)); + items.add(null); + items.add(new ItemStack(Items.clay_ball)); + items.add(null); + items.add(new ItemStack(Items.clay_ball)); + items.add(null); + items.add(new ItemStack(Items.clay_ball)); + items.add(null); + Page.addCraftingRecipeTextPage(gui, gui.getLeft() + xPos, gui.getTop(), false, text, items, x, y); + break; + case 8: + text.add(" By smelting the clay_ball"); + text.add("mold you get a harder"); + text.add("version which can be"); + text.add("used to create rings."); + text.add("Simply right click with"); + text.add("this on a molder to"); + text.add("attach it and you're"); + text.add("ready to go."); + items.add(new ItemStack(ItemList.clayMolds, 1, 1)); + items.add(new ItemStack(ItemList.molds, 1, 1)); + Page.addSmeltingRecipeTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text, items, x, y); + break; + case 9: + text.add(" In order to create a"); + text.add("necklace you need a"); + text.add("mold for it. However,"); + text.add("this one can't be used."); + text.add("It is too soft. It needs"); + text.add("to be hardened in"); + text.add("order for it to be used."); + items.add(new ItemStack(ItemList.clayMolds, 1, 2)); + items.add(new ItemStack(Items.clay_ball)); + items.add(null); + items.add(new ItemStack(Items.clay_ball)); + items.add(new ItemStack(Items.clay_ball)); + items.add(null); + items.add(new ItemStack(Items.clay_ball)); + items.add(null); + items.add(new ItemStack(Items.clay_ball)); + items.add(null); + Page.addCraftingRecipeTextPage(gui, gui.getLeft() + xPos, gui.getTop(), false, text, items, x, y); + break; + case 10: + text.add(" By smelting the clay_ball"); + text.add("mold you get a harder"); + text.add("version which can be"); + text.add("used to create"); + text.add("necklaces. Simply right"); + text.add("click with this on a"); + text.add("molder to attach it and"); + text.add("you're ready to go."); + items.add(new ItemStack(ItemList.clayMolds, 1, 2)); + items.add(new ItemStack(ItemList.molds, 1, 2)); + Page.addSmeltingRecipeTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text, items, x, y); + break; + case 11: + text.add(" Crystals don't do"); + text.add("much. They can be dyed"); + text.add("in any color and used"); + text.add("as jewels to create a"); + text.add("nice jewellery."); + items.add(new ItemStack(ItemList.crystal, 1, 15)); + items.add(null); + items.add(new ItemStack(Blocks.glass)); + items.add(null); + items.add(new ItemStack(Blocks.glass)); + items.add(null); + items.add(new ItemStack(Blocks.glass)); + items.add(null); + items.add(new ItemStack(Blocks.glass)); + items.add(null); + Page.addCraftingRecipeTextPage(gui, gui.getLeft() + xPos, gui.getTop(), false, text, items, x, y); + break; + case 12: + if(del == 0) values++; + del++; + if(del >= 300) del = 0; + if(values >= 15) values = 0; + items.add(new ItemStack(ItemList.crystal, 1, values)); + items.add(new ItemStack(Items.dye, 1, values)); + items.add(new ItemStack(ItemList.crystal, 1, 15)); + Page.addCraftingRecipeTextPage(gui, gui.getLeft() + xPos, gui.getTop(), true, text, items, x, y); + items.removeAll(items); + items.add(new ItemStack(ItemList.crystal, 1, 15)); + items.add(new ItemStack(Items.dye, 1, 15)); + items.add(new ItemStack(ItemList.crystal, 1, values)); + Page.addCraftingRecipeTextPage(gui, gui.getLeft() + xPos, gui.getTop() + 60, true, text, items, x, y); + break; + case 13: + if(del == 0) values++; + del++; + if(del >= 300) del = 0; + if(values >= 3) values = 0; + text.add(" It's this exact guide."); + text.add("I don't even know why"); + text.add("you're reading this."); + text.add("I added this recipe in"); + text.add("case you lose the"); + text.add("original. In case you"); + text.add("don't have it, I suggest"); + text.add("adding NEI so you can"); + items.add(new ItemStack(ItemList.guide)); + items.add(new ItemStack(ItemList.molds, 1, values)); + items.add(new ItemStack(Items.book)); + Page.addCraftingRecipeTextPage(gui, gui.getLeft() + xPos, gui.getTop(), true, text, items, x, y); + break; + case 14: + String link = "HERE"; + if(x >= gui.getLeft() + 138 && x <= gui.getLeft() + 168 && y >= gui.getTop() + 98 && y <= gui.getTop() + 108) link = EnumChatFormatting.DARK_BLUE + "HERE" + EnumChatFormatting.BLACK; + text.add("see all the recipes."); + text.add("Since you are reading"); + text.add("this, how about making"); + text.add("a youtube video"); + text.add("spotlighting this mod."); + text.add("I'd really appreciate it."); + text.add("After that you can"); + text.add("share it in the main"); + text.add("thread " + link + "."); + text.add(" This mod was made by"); + text.add("DarkKnight (or sor1n"); + text.add("depending from where"); + text.add("you got this)"); + Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text); + break; + default:; + } + } + + public int getMaxPages() + { + return 13; + } + + public void mouseClick(GuiGuide gui, int x, int y, int button) + { + if(gui.page == 13 && x >= gui.getLeft() + 138 && x <= gui.getLeft() + 168 && y >= gui.getTop() + 98 && y <= gui.getTop() + 108) + { + try + { + Desktop.getDesktop().browse(new URL("http://www.minecraftforum.net/topic/2210959-164smp-ssp-jewelrycraft-version-12/").toURI()); + } + catch (Exception e) {} + } + } + + @Override + public void drawForeground(GuiGuide gui, int x, int y, int page) + { + } + +} diff --git a/src/main/java/darkknight/jewelrycraft/container/GuiTabJewelsAndModifiers.java b/src/main/java/darkknight/jewelrycraft/container/GuiTabJewelsAndModifiers.java new file mode 100644 index 0000000..1085f7d --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/container/GuiTabJewelsAndModifiers.java @@ -0,0 +1,87 @@ +package darkknight.jewelrycraft.container; + +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; + +import org.lwjgl.opengl.GL11; + +import darkknight.jewelrycraft.client.GuiGuide; +import darkknight.jewelrycraft.util.JewelrycraftUtil; + +public class GuiTabJewelsAndModifiers extends GuiTab +{ + public GuiTabJewelsAndModifiers(int id) + { + super("Jewels and modifiers", id); + } + + public ItemStack getIcon() + { + return new ItemStack(Items.emerald); + } + + @Override + public void drawBackground(GuiGuide gui, int x, int y, int page) + { + int xPos = (page%2==0)?107:-35; + switch(page) + { + case 1: + gui.getFont().drawString(EnumChatFormatting.DARK_BLUE + "\u00a7n" + "Jewels", gui.getLeft() + xPos + 40, gui.getTop(), 0); + for(int i = 0; i <= 8; i++){ + gui.renderItem(JewelrycraftUtil.jewel.get(i), gui.getLeft() + xPos + 10, gui.getTop() + 22 + 16*i, 30f); + gui.getFont().drawString(JewelrycraftUtil.jewel.get(i).getDisplayName(), gui.getLeft() + xPos + 20, gui.getTop() + 12 + 16*i, 0); + } + break; + case 2: + gui.getFont().drawString(EnumChatFormatting.DARK_BLUE + "\u00a7n" + "Jewels", gui.getLeft() + xPos + 40, gui.getTop(), 0); + for(int i = 0; i <= 8; i++){ + gui.renderItem(JewelrycraftUtil.jewel.get(i+9), gui.getLeft() + xPos + 10, gui.getTop() + 22 + 16*i, 30f); + gui.getFont().drawString(JewelrycraftUtil.jewel.get(i+9).getDisplayName(), gui.getLeft() + xPos + 20, gui.getTop() + 12 + 16*i, 0); + } + break; + case 3: + gui.getFont().drawString(EnumChatFormatting.DARK_BLUE + "\u00a7n" + "Jewels", gui.getLeft() + xPos + 40, gui.getTop(), 0); + for(int i = 0; i <= 8; i++) + if(i+18 < JewelrycraftUtil.jewel.size()){ + gui.renderItem(JewelrycraftUtil.jewel.get(i+18), gui.getLeft() + xPos + 10, gui.getTop() + 22 + 16*i, 30f); + gui.getFont().drawString(JewelrycraftUtil.jewel.get(i+18).getDisplayName(), gui.getLeft() + xPos + 20, gui.getTop() + 12 + 16*i, 0); + GL11.glDisable(GL11.GL_LIGHTING); + } + break; + case 4: + gui.getFont().drawString(EnumChatFormatting.DARK_BLUE + "\u00a7n" + "Modifiers", gui.getLeft() + xPos + 40, gui.getTop(), 0); + for(int i = 0; i <= 8; i++){ + if(i < JewelrycraftUtil.modifiers.size()) + { + gui.renderItem(JewelrycraftUtil.modifiers.get(i), gui.getLeft() + xPos + 10, gui.getTop() + 22 + 16*i, 30f); + gui.getFont().drawString(JewelrycraftUtil.modifiers.get(i).getDisplayName(), gui.getLeft() + xPos + 20, gui.getTop() + 12 + 16*i, 0); + } + } + break; + case 5: + gui.getFont().drawString(EnumChatFormatting.DARK_BLUE + "\u00a7n" + "Modifiers", gui.getLeft() + xPos + 40, gui.getTop(), 0); + for(int i = 0; i <= 8; i++){ + if(i+9 < JewelrycraftUtil.modifiers.size()){ + gui.renderItem(JewelrycraftUtil.modifiers.get(i + 9), gui.getLeft() + xPos + 10, gui.getTop() + 22 + 16*i, 30f); + gui.getFont().drawString(JewelrycraftUtil.modifiers.get(i + 9).getDisplayName(), gui.getLeft() + xPos + 20, gui.getTop() + 12 + 16*i, 0); + GL11.glDisable(GL11.GL_LIGHTING); + } + } + break; + default:; + } + } + + public int getMaxPages() + { + return 5; + } + + @Override + public void drawForeground(GuiGuide gui, int x, int y, int page) + { + } + +} diff --git a/src/main/java/darkknight/jewelrycraft/container/GuiTabNecklaces.java b/src/main/java/darkknight/jewelrycraft/container/GuiTabNecklaces.java new file mode 100644 index 0000000..4271928 --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/container/GuiTabNecklaces.java @@ -0,0 +1,380 @@ +package darkknight.jewelrycraft.container; + +import java.util.ArrayList; + +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import darkknight.jewelrycraft.client.GuiGuide; +import darkknight.jewelrycraft.item.ItemList; +import darkknight.jewelrycraft.util.JewelryNBT; +import darkknight.jewelrycraft.util.JewelrycraftUtil; + +public class GuiTabNecklaces extends GuiTab +{ + int jValues; + public GuiTabNecklaces(int id) + { + super("Necklaces", id); + jValues = 0; + } + + public ItemStack getIcon() + { + ItemStack it = new ItemStack(ItemList.necklace); + JewelryNBT.addMetal(it, new ItemStack(Items.iron_ingot)); + JewelryNBT.addJewel(it, new ItemStack(Blocks.redstone_block)); + return it; + } + + @Override + public void drawBackground(GuiGuide gui, int x, int y, int page) + { + ArrayList<String> text = new ArrayList<String>(); + ArrayList<ItemStack> jewels = new ArrayList<ItemStack>(); + ItemStack item = new ItemStack(ItemList.necklace); + int xPos = (page%2==0)?107:-35; + switch(page) + { + case 1: + if(del == 0) values++; + del++; + if(del >= 300) del = 0; + if(values > JewelrycraftUtil.metal.size() - 1) values = 0; + + JewelryNBT.addMetal(item, JewelrycraftUtil.metal.get(values)); + JewelryNBT.addJewel(item, new ItemStack(Items.ender_pearl)); + + text.add(EnumChatFormatting.DARK_GREEN + "Jewel: " + EnumChatFormatting.BLACK + "Ender Pearl"); + text.add(EnumChatFormatting.DARK_GREEN + "Modifier: " + EnumChatFormatting.BLACK + "None"); + text.add(EnumChatFormatting.DARK_GREEN + "Ingot: " + EnumChatFormatting.BLACK + "Any"); + text.add(" This ring teleports"); + text.add("you and anyone around "); + text.add("in any location from the"); + text.add("same dimension. Just"); + text.add("right click once in a"); + text.add("location to se the "); + text.add("position. Then right "); + text.add("click any time you want"); + Page.addImageTextPage(gui, gui.getLeft() + xPos, gui.getTop(), item, text, 50f, 0, -10, false, 45, 0); + break; + case 2: + text.add("to teleport there."); + text.add(EnumChatFormatting.DARK_RED + "\u00a7nAltar Effect"); + text.add(" This teleports anyone"); + text.add("or anything that steps"); + text.add("or goes near the altar"); + text.add("to the necklaces"); + text.add("coordonates, as long"); + text.add("as that is in the same"); + text.add("dimension."); + Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text); + break; + case 3: + if(del == 0) values++; + del++; + if(del >= 300) del = 0; + if(values > JewelrycraftUtil.metal.size() - 1) values = 0; + + JewelryNBT.addMetal(item, JewelrycraftUtil.metal.get(values)); + JewelryNBT.addJewel(item, new ItemStack(Items.ender_pearl)); + JewelryNBT.addModifier(item, new ItemStack(Items.bed)); + + text.add(EnumChatFormatting.DARK_GREEN + "Jewel: " + EnumChatFormatting.BLACK + "Ender Pearl"); + text.add(EnumChatFormatting.DARK_GREEN + "Modifier: " + EnumChatFormatting.BLACK + "Bed"); + text.add(EnumChatFormatting.DARK_GREEN + "Ingot: " + EnumChatFormatting.BLACK + "Any"); + text.add(" Just like the other"); + text.add("necklace this teleports"); + text.add("you and anybody close"); + text.add("to you to the set"); + text.add("destination. The only"); + text.add("difference is that you"); + text.add("can travel between"); + text.add("dimensions with this."); + Page.addImageTextPage(gui, gui.getLeft() + xPos, gui.getTop(), item, text, 50f, 0, -10, false, 45, 0); + break; + case 4: + text.add(EnumChatFormatting.DARK_RED + "\u00a7nAltar Effect"); + text.add(" This teleports anyone"); + text.add("or anything that step"); + text.add("on or around the altar"); + text.add("to the set location, with"); + text.add("the benefit of it being"); + text.add("capable of"); + text.add("inter-dimensional"); + text.add("travels."); + Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text); + break; + case 5: + jewels.add(null); + jewels.add(new ItemStack(Items.diamond)); + jewels.add(new ItemStack(Items.emerald)); + jewels.add(new ItemStack(Items.nether_star)); + + if(del == 0) { values++; jValues++;} + del++; + if(del >= 300) del = 0; + if(values > JewelrycraftUtil.metal.size() - 1) values = 0; + if(jValues > jewels.size() - 1) jValues = 0; + + JewelryNBT.addMetal(item, JewelrycraftUtil.metal.get(values)); + JewelryNBT.addJewel(item, jewels.get(jValues)); + JewelryNBT.addModifier(item, new ItemStack(Items.blaze_powder)); + + text.add(EnumChatFormatting.DARK_GREEN + "Jewel: " + EnumChatFormatting.BLACK + "None, Diamond"); + text.add("Emerald or Nether Star"); + text.add(EnumChatFormatting.DARK_GREEN + "Modifier: " + EnumChatFormatting.BLACK + "Blaze Powder"); + text.add(EnumChatFormatting.DARK_GREEN + "Ingot: " + EnumChatFormatting.BLACK + "Any"); + text.add(" This necklace gives"); + text.add("you and those around"); + text.add("you " + EnumChatFormatting.DARK_RED + "Fire Resistance"); + text.add("when activated and in"); + text.add("your inventory. To"); + text.add("deactivate it simply"); + text.add("right click with it."); + Page.addImageTextPage(gui, gui.getLeft() + xPos, gui.getTop(), item, text, 50f, 0, -10, false, 45, 0); + break; + case 6: + text.add("Depending on the jewel"); + text.add("used, you and the"); + text.add("others get " + EnumChatFormatting.DARK_RED + "Fire"); + text.add(EnumChatFormatting.DARK_RED + "Resistance" + EnumChatFormatting.BLACK + " I if you"); + text.add("haven't got any jewel,"); + text.add("II for Diamond,"); + text.add("III for Emerald and"); + text.add("VIII for Nether Star."); + Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text); + break; + case 7: + jewels.add(null); + jewels.add(new ItemStack(Items.diamond)); + jewels.add(new ItemStack(Items.emerald)); + jewels.add(new ItemStack(Items.nether_star)); + + if(del == 0) { values++; jValues++;} + del++; + if(del >= 300) del = 0; + if(values > JewelrycraftUtil.metal.size() - 1) values = 0; + if(jValues > jewels.size() - 1) jValues = 0; + + JewelryNBT.addMetal(item, JewelrycraftUtil.metal.get(values)); + JewelryNBT.addJewel(item, jewels.get(jValues)); + JewelryNBT.addModifier(item, new ItemStack(Items.sugar)); + + text.add(EnumChatFormatting.DARK_GREEN + "Jewel: " + EnumChatFormatting.BLACK + "None, Diamond"); + text.add("Emerald or Nether Star"); + text.add(EnumChatFormatting.DARK_GREEN + "Modifier: " + EnumChatFormatting.BLACK + "Sugar"); + text.add(EnumChatFormatting.DARK_GREEN + "Ingot: " + EnumChatFormatting.BLACK + "Any"); + text.add(" This necklace gives"); + text.add("you and those around"); + text.add("you " + EnumChatFormatting.DARK_RED + "Speed" + EnumChatFormatting.BLACK + " when"); + text.add("activated and in your"); + text.add("inventory. To"); + text.add("deactivate it simply"); + text.add("right click with it."); + Page.addImageTextPage(gui, gui.getLeft() + xPos, gui.getTop(), item, text, 50f, 0, -10, false, 45, 0); + break; + case 8: + text.add("Depending on the jewel"); + text.add("used, you and the"); + text.add("others get " + EnumChatFormatting.DARK_RED + "Speed" + EnumChatFormatting.BLACK + " I"); + text.add("if you haven't got any"); + text.add("jewel, II for Diamond,"); + text.add("III for Emerald and"); + text.add("VIII for Nether Star."); + Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text); + break; + case 9: + jewels.add(null); + jewels.add(new ItemStack(Items.diamond)); + jewels.add(new ItemStack(Items.emerald)); + jewels.add(new ItemStack(Items.nether_star)); + + if(del == 0) { values++; jValues++;} + del++; + if(del >= 300) del = 0; + if(values > JewelrycraftUtil.metal.size() - 1) values = 0; + if(jValues > jewels.size() - 1) jValues = 0; + + JewelryNBT.addMetal(item, JewelrycraftUtil.metal.get(values)); + JewelryNBT.addJewel(item, jewels.get(jValues)); + JewelryNBT.addModifier(item, new ItemStack(Items.iron_pickaxe)); + + text.add(EnumChatFormatting.DARK_GREEN + "Jewel: " + EnumChatFormatting.BLACK + "None, Diamond"); + text.add("Emerald or Nether Star"); + text.add(EnumChatFormatting.DARK_GREEN + "Modifier: " + EnumChatFormatting.BLACK + "Iron Pickaxe"); + text.add(EnumChatFormatting.DARK_GREEN + "Ingot: " + EnumChatFormatting.BLACK + "Any"); + text.add(" This necklace gives"); + text.add("you and those around"); + text.add("you " + EnumChatFormatting.DARK_RED + "Haste" + EnumChatFormatting.BLACK + " when"); + text.add("activated and in your"); + text.add("inventory. To"); + text.add("deactivate it simply"); + text.add("right click with it."); + Page.addImageTextPage(gui, gui.getLeft() + xPos, gui.getTop(), item, text, 50f, 0, -10, false, 45, 0); + break; + case 10: + text.add("Depending on the jewel"); + text.add("used, you and the"); + text.add("others get " + EnumChatFormatting.DARK_RED + "Haste" + EnumChatFormatting.BLACK + " I"); + text.add("if you haven't got any"); + text.add("jewel, II for Diamond,"); + text.add("III for Emerald and"); + text.add("VIII for Nether Star."); + Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text); + break; + case 11: + jewels.add(null); + jewels.add(new ItemStack(Items.diamond)); + jewels.add(new ItemStack(Items.emerald)); + jewels.add(new ItemStack(Items.nether_star)); + + if(del == 0) { values++; jValues++;} + del++; + if(del >= 300) del = 0; + if(values > JewelrycraftUtil.metal.size() - 1) values = 0; + if(jValues > jewels.size() - 1) jValues = 0; + + JewelryNBT.addMetal(item, JewelrycraftUtil.metal.get(values)); + JewelryNBT.addJewel(item, jewels.get(jValues)); + JewelryNBT.addModifier(item, new ItemStack(Items.feather)); + + text.add(EnumChatFormatting.DARK_GREEN + "Jewel: " + EnumChatFormatting.BLACK + "None, Diamond"); + text.add("Emerald or Nether Star"); + text.add(EnumChatFormatting.DARK_GREEN + "Modifier: " + EnumChatFormatting.BLACK + "Feather"); + text.add(EnumChatFormatting.DARK_GREEN + "Ingot: " + EnumChatFormatting.BLACK + "Any"); + text.add(" This necklace gives"); + text.add("you and those around"); + text.add("you " + EnumChatFormatting.DARK_RED + "Jump Boost" + EnumChatFormatting.BLACK + " when"); + text.add("activated and in your"); + text.add("inventory. To"); + text.add("deactivate it simply"); + text.add("right click with it."); + Page.addImageTextPage(gui, gui.getLeft() + xPos, gui.getTop(), item, text, 50f, 0, -10, false, 45, 0); + break; + case 12: + text.add("Depending on the jewel"); + text.add("used, you and the"); + text.add("others get " + EnumChatFormatting.DARK_RED + "Jump Boost"); + text.add("I if you haven't got any"); + text.add("jewel, II for Diamond,"); + text.add("III for Emerald and"); + text.add("VIII for Nether Star."); + Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text); + break; + case 13: + jewels.add(null); + jewels.add(new ItemStack(Items.diamond)); + jewels.add(new ItemStack(Items.emerald)); + jewels.add(new ItemStack(Items.nether_star)); + + if(del == 0) { values++; jValues++;} + del++; + if(del >= 300) del = 0; + if(values > JewelrycraftUtil.metal.size() - 1) values = 0; + if(jValues > jewels.size() - 1) jValues = 0; + + JewelryNBT.addMetal(item, JewelrycraftUtil.metal.get(values)); + JewelryNBT.addJewel(item, jewels.get(jValues)); + JewelryNBT.addModifier(item, new ItemStack(Items.potionitem, 1, 8270)); + + text.add(EnumChatFormatting.DARK_GREEN + "Jewel: " + EnumChatFormatting.BLACK + "None, Diamond"); + text.add("Emerald or Nether Star"); + text.add(EnumChatFormatting.DARK_GREEN + "Modifier: " + EnumChatFormatting.BLACK + "8min Potion of"); + text.add("Invisibility"); + text.add(EnumChatFormatting.DARK_GREEN + "Ingot: " + EnumChatFormatting.BLACK + "Any"); + text.add(" This necklace gives"); + text.add("you and those around"); + text.add("you " + EnumChatFormatting.DARK_RED + "Invisibility" + EnumChatFormatting.BLACK + " when"); + text.add("activated and in your"); + text.add("inventory. To"); + text.add("deactivate it simply"); + Page.addImageTextPage(gui, gui.getLeft() + xPos, gui.getTop(), item, text, 50f, 0, -10, false, 45, 0); + break; + case 14: + text.add("right click with it."); + text.add("Depending on the jewel"); + text.add("used, you and the"); + text.add("others get " + EnumChatFormatting.DARK_RED + "Invisibility" + EnumChatFormatting.BLACK + " I"); + text.add("if you haven't got any"); + text.add("jewel, II for Diamond,"); + text.add("III for Emerald and"); + text.add("VIII for Nether Star."); + Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text); + break; + case 15: + jewels.add(null); + jewels.add(new ItemStack(Items.diamond)); + jewels.add(new ItemStack(Items.emerald)); + jewels.add(new ItemStack(Items.nether_star)); + + if(del == 0){values++; jValues++;} + del++; + if(del >= 300) del = 0; + if(values > JewelrycraftUtil.metal.size() - 1) values = 0; + if(jValues > jewels.size() - 1) jValues = 0; + + JewelryNBT.addMetal(item, JewelrycraftUtil.metal.get(values)); + JewelryNBT.addJewel(item, jewels.get(jValues)); + JewelryNBT.addModifier(item, new ItemStack(Items.dye, 1, 15)); + + text.add(EnumChatFormatting.DARK_GREEN + "Jewel: " + EnumChatFormatting.BLACK + "None, Diamond"); + text.add("Emerald or Nether Star"); + text.add(EnumChatFormatting.DARK_GREEN + "Modifier: " + EnumChatFormatting.BLACK + "Bone Meal"); + text.add(EnumChatFormatting.DARK_GREEN + "Ingot: " + EnumChatFormatting.BLACK + "Any"); + text.add(" This hydrates the"); + text.add("farm blocks under you"); + text.add("in a defined area. If"); + text.add("you right click with this,"); + text.add("it will help plants in"); + text.add("that area grow faster."); + text.add("The are it affects is"); + Page.addImageTextPage(gui, gui.getLeft() + xPos, gui.getTop(), item, text, 50f, 0, -10, false, 45, 0); + break; + case 16: + text.add("determined by the jewel"); + text.add("used. For none, the"); + text.add("area is a block, diamond"); + text.add("is 3x3, emerald 5x5 and"); + text.add("nether star 11x11."); + text.add(EnumChatFormatting.DARK_RED + "\u00a7nAltar Effect"); + text.add(" In the altar, this"); + text.add("has the ability to"); + text.add("hydrate any tilted land"); + text.add("and speed up the"); + text.add("growth of plants in a"); + text.add("7x3x7 area."); + Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text); + break; + case 17: + JewelryNBT.addMetal(item, new ItemStack(ItemList.shadowIngot)); + JewelryNBT.addJewel(item, new ItemStack(Items.nether_star)); + JewelryNBT.addModifier(item, new ItemStack(Items.diamond_pickaxe)); + + text.add(EnumChatFormatting.DARK_GREEN + "Jewel: " + EnumChatFormatting.BLACK + "Nether Star"); + text.add(EnumChatFormatting.DARK_GREEN + "Modifier: " + EnumChatFormatting.BLACK + "Diamond Pick"); + text.add(EnumChatFormatting.DARK_GREEN + "Ingot: " + EnumChatFormatting.BLACK + "Shadow Ingot"); + text.add(" This will break all"); + text.add("blocks in a 3x3x1 area."); + text.add("Just right click on a"); + text.add("block and let the mining"); + text.add("begin."); + Page.addImageTextPage(gui, gui.getLeft() + xPos, gui.getTop(), item, text, 50f, 0, -10, false, 45, 0); + break; + default:; + } + } + + public int getMaxPages() + { + return 17; + } + + @Override + public void drawForeground(GuiGuide gui, int x, int y, int page) + { + } + +} diff --git a/src/main/java/darkknight/jewelrycraft/container/GuiTabRings.java b/src/main/java/darkknight/jewelrycraft/container/GuiTabRings.java new file mode 100644 index 0000000..646a78b --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/container/GuiTabRings.java @@ -0,0 +1,587 @@ +package darkknight.jewelrycraft.container; + +import java.util.ArrayList; + +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import darkknight.jewelrycraft.client.GuiGuide; +import darkknight.jewelrycraft.item.ItemList; +import darkknight.jewelrycraft.util.JewelryNBT; +import darkknight.jewelrycraft.util.JewelrycraftUtil; + +public class GuiTabRings extends GuiTab +{ + int jValues; + public GuiTabRings(int id) + { + super("Rings", id); + jValues = 0; + } + + public ItemStack getIcon() + { + ItemStack it = new ItemStack(ItemList.ring); + JewelryNBT.addMetal(it, new ItemStack(Items.gold_ingot)); + JewelryNBT.addJewel(it, new ItemStack(Items.ender_pearl)); + return it; + } + + @Override + public void drawBackground(GuiGuide gui, int x, int y, int page) + { + ArrayList<String> text = new ArrayList<String>(); + ArrayList<ItemStack> jewels = new ArrayList<ItemStack>(); + ItemStack item = new ItemStack(ItemList.ring); + int xPos = (page%2==0)?107:-35; + switch(page) + { + case 1: + if(del == 0) values++; + del++; + if(del >= 300) del = 0; + if(values > JewelrycraftUtil.metal.size() - 1) values = 0; + + JewelryNBT.addMetal(item, JewelrycraftUtil.metal.get(values)); + JewelryNBT.addJewel(item, new ItemStack(Items.ender_pearl)); + + text.add(EnumChatFormatting.DARK_GREEN + "Jewel: " + EnumChatFormatting.BLACK + "Ender Pearl"); + text.add(EnumChatFormatting.DARK_GREEN + "Modifier: " + EnumChatFormatting.BLACK + "None"); + text.add(EnumChatFormatting.DARK_GREEN + "Ingot: " + EnumChatFormatting.BLACK + "Any"); + text.add(" This ring allows you"); + text.add("to teleport in any"); + text.add("location from the same"); + text.add("dimension. Simply right"); + text.add("click once in a location"); + text.add("to se the position. Then"); + text.add("right click any time you"); + text.add("want to teleport there."); + Page.addImageTextPage(gui, gui.getLeft() + xPos, gui.getTop(), item, text, 50f, 0, -10, false, 45, 0); + break; + case 2: + text.add(EnumChatFormatting.DARK_RED + "\u00a7nAltar Effect"); + text.add(" If this ring is placed"); + text.add("in the altar and if the"); + text.add("ring has coordonates"); + text.add("memorized, then anyone"); + text.add("who steps on the block"); + text.add("will get teleported in"); + text.add("that location, as long"); + text.add("as it is in the same"); + text.add("dimension. This works"); + text.add("for other entities as"); + text.add("well, not just players."); + Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text); + break; + case 3: + if(del == 0) values++; + del++; + if(del >= 300) del = 0; + if(values > JewelrycraftUtil.metal.size() - 1) values = 0; + + JewelryNBT.addMetal(item, JewelrycraftUtil.metal.get(values)); + JewelryNBT.addJewel(item, new ItemStack(Items.ender_pearl)); + JewelryNBT.addModifier(item, new ItemStack(Items.bed)); + + text.add(EnumChatFormatting.DARK_GREEN + "Jewel: " + EnumChatFormatting.BLACK + "Ender Pearl"); + text.add(EnumChatFormatting.DARK_GREEN + "Modifier: " + EnumChatFormatting.BLACK + "Bed"); + text.add(EnumChatFormatting.DARK_GREEN + "Ingot: " + EnumChatFormatting.BLACK + "Any"); + text.add(" Just like the other"); + text.add("ring that had only an"); + text.add("ender pearl as a jewel,"); + text.add("by adding a bed as a"); + text.add("modifier to it you can"); + text.add("travel between"); + text.add("dimensions."); + Page.addImageTextPage(gui, gui.getLeft() + xPos, gui.getTop(), item, text, 50f, 0, -10, false, 45, 0); + break; + case 4: + text.add(EnumChatFormatting.DARK_RED + "\u00a7nAltar Effect"); + text.add(" Just like the other"); + text.add("one, when in the altar"); + text.add("if somebody steps on"); + text.add("the block they get"); + text.add("teleported in that spot."); + text.add("The only difference is"); + text.add("that you can teleport"); + text.add("between dimesnions with"); + text.add("this. It works for mobs"); + text.add("and other entities as"); + text.add("well."); + Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text); + break; + case 5: + jewels.add(null); + jewels.add(new ItemStack(Items.diamond)); + jewels.add(new ItemStack(Items.emerald)); + jewels.add(new ItemStack(Items.nether_star)); + + if(del == 0) { values++; jValues++;} + del++; + if(del >= 300) del = 0; + if(values > JewelrycraftUtil.metal.size() - 1) values = 0; + if(jValues > jewels.size() - 1) jValues = 0; + + JewelryNBT.addMetal(item, JewelrycraftUtil.metal.get(values)); + JewelryNBT.addJewel(item, jewels.get(jValues)); + JewelryNBT.addModifier(item, new ItemStack(Items.blaze_powder)); + + text.add(EnumChatFormatting.DARK_GREEN + "Jewel: " + EnumChatFormatting.BLACK + "None, Diamond"); + text.add("Emerald or Nether Star"); + text.add(EnumChatFormatting.DARK_GREEN + "Modifier: " + EnumChatFormatting.BLACK + "Blaze Powder"); + text.add(EnumChatFormatting.DARK_GREEN + "Ingot: " + EnumChatFormatting.BLACK + "Any"); + text.add(" This ring grants you"); + text.add(EnumChatFormatting.DARK_RED + "Fire Resistance" + EnumChatFormatting.BLACK + " when"); + text.add("activated and in your"); + text.add("inventory. To deactivate"); + text.add("it simply right click with"); + text.add("it. Depending on the"); + text.add("jewel you used, you"); + Page.addImageTextPage(gui, gui.getLeft() + xPos, gui.getTop(), item, text, 50f, 0, -10, false, 45, 0); + break; + case 6: + text.add("get " + EnumChatFormatting.DARK_RED + "Fire Resistance" + EnumChatFormatting.BLACK + " I"); + text.add("if you haven't got any"); + text.add("jewel, II for Diamond,"); + text.add("III for Emerald and"); + text.add("VIII for Nether Star."); + Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text); + break; + case 7: + jewels.add(null); + jewels.add(new ItemStack(Items.diamond)); + jewels.add(new ItemStack(Items.emerald)); + jewels.add(new ItemStack(Items.nether_star)); + + if(del == 0) { values++; jValues++;} + del++; + if(del >= 300) del = 0; + if(values > JewelrycraftUtil.metal.size() - 1) values = 0; + if(jValues > jewels.size() - 1) jValues = 0; + + JewelryNBT.addMetal(item, JewelrycraftUtil.metal.get(values)); + JewelryNBT.addJewel(item, jewels.get(jValues)); + JewelryNBT.addModifier(item, new ItemStack(Items.sugar)); + + text.add(EnumChatFormatting.DARK_GREEN + "Jewel: " + EnumChatFormatting.BLACK + "None, Diamond"); + text.add("Emerald or Nether Star"); + text.add(EnumChatFormatting.DARK_GREEN + "Modifier: " + EnumChatFormatting.BLACK + "Sugar"); + text.add(EnumChatFormatting.DARK_GREEN + "Ingot: " + EnumChatFormatting.BLACK + "Any"); + text.add(" This ring grants you"); + text.add(EnumChatFormatting.DARK_RED + "Speed" + EnumChatFormatting.BLACK + " when activated"); + text.add("and in your inventory."); + text.add("To deactivate it simply"); + text.add("right click with it."); + text.add("Depending on the"); + text.add("jewel you used, you"); + Page.addImageTextPage(gui, gui.getLeft() + xPos, gui.getTop(), item, text, 50f, 0, -10, false, 45, 0); + break; + case 8: + text.add("get " + EnumChatFormatting.DARK_RED + "Speed" + EnumChatFormatting.BLACK + " I if you"); + text.add("haven't got any jewel,"); + text.add("II for Diamond,"); + text.add("III for Emerald and"); + text.add("VIII for Nether Star."); + Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text); + break; + case 9: + jewels.add(null); + jewels.add(new ItemStack(Items.diamond)); + jewels.add(new ItemStack(Items.emerald)); + jewels.add(new ItemStack(Items.nether_star)); + + if(del == 0) { values++; jValues++;} + del++; + if(del >= 300) del = 0; + if(values > JewelrycraftUtil.metal.size() - 1) values = 0; + if(jValues > jewels.size() - 1) jValues = 0; + + JewelryNBT.addMetal(item, JewelrycraftUtil.metal.get(values)); + JewelryNBT.addJewel(item, jewels.get(jValues)); + JewelryNBT.addModifier(item, new ItemStack(Items.iron_pickaxe)); + + text.add(EnumChatFormatting.DARK_GREEN + "Jewel: " + EnumChatFormatting.BLACK + "None, Diamond"); + text.add("Emerald or Nether Star"); + text.add(EnumChatFormatting.DARK_GREEN + "Modifier: " + EnumChatFormatting.BLACK + "Iron Pickaxe"); + text.add(EnumChatFormatting.DARK_GREEN + "Ingot: " + EnumChatFormatting.BLACK + "Any"); + text.add(" This ring grants you"); + text.add(EnumChatFormatting.DARK_RED + "Haste" + EnumChatFormatting.BLACK + " when activated"); + text.add("and in your inventory."); + text.add("To deactivate it simply"); + text.add("right click with it."); + text.add("Depending on the"); + text.add("jewel you used, you"); + Page.addImageTextPage(gui, gui.getLeft() + xPos, gui.getTop(), item, text, 50f, 0, -10, false, 45, 0); + break; + case 10: + text.add("get " + EnumChatFormatting.DARK_RED + "Haste" + EnumChatFormatting.BLACK + " I if you"); + text.add("haven't got any jewel,"); + text.add("II for Diamond,"); + text.add("III for Emerald and"); + text.add("VIII for Nether Star."); + Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text); + break; + case 11: + jewels.add(null); + jewels.add(new ItemStack(Items.diamond)); + jewels.add(new ItemStack(Items.emerald)); + jewels.add(new ItemStack(Items.nether_star)); + + if(del == 0) { values++; jValues++;} + del++; + if(del >= 300) del = 0; + if(values > JewelrycraftUtil.metal.size() - 1) values = 0; + if(jValues > jewels.size() - 1) jValues = 0; + + JewelryNBT.addMetal(item, JewelrycraftUtil.metal.get(values)); + JewelryNBT.addJewel(item, jewels.get(jValues)); + JewelryNBT.addModifier(item, new ItemStack(Items.feather)); + + text.add(EnumChatFormatting.DARK_GREEN + "Jewel: " + EnumChatFormatting.BLACK + "None, Diamond"); + text.add("Emerald or Nether Star"); + text.add(EnumChatFormatting.DARK_GREEN + "Modifier: " + EnumChatFormatting.BLACK + "Feather"); + text.add(EnumChatFormatting.DARK_GREEN + "Ingot: " + EnumChatFormatting.BLACK + "Any"); + text.add(" This ring grants you"); + text.add(EnumChatFormatting.DARK_RED + "Jump Boost" + EnumChatFormatting.BLACK + " when"); + text.add("activated and in your"); + text.add("inventory, as well as"); + text.add("remove any fall damage."); + text.add("To deactivate it simply"); + text.add("right click with it."); + Page.addImageTextPage(gui, gui.getLeft() + xPos, gui.getTop(), item, text, 50f, 0, -10, false, 45, 0); + break; + case 12: + text.add("Depending on the jewel"); + text.add("you used, you get"); + text.add(EnumChatFormatting.DARK_RED + "Jump Boost" + EnumChatFormatting.BLACK + " I if you"); + text.add("haven't got any jewel,"); + text.add("II for Diamond,"); + text.add("III for Emerald and"); + text.add("VIII for Nether Star."); + Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text); + break; + case 13: + jewels.add(null); + jewels.add(new ItemStack(Items.diamond)); + jewels.add(new ItemStack(Items.emerald)); + jewels.add(new ItemStack(Items.nether_star)); + + if(del == 0) { values++; jValues++;} + del++; + if(del >= 300) del = 0; + if(values > JewelrycraftUtil.metal.size() - 1) values = 0; + if(jValues > jewels.size() - 1) jValues = 0; + + JewelryNBT.addMetal(item, JewelrycraftUtil.metal.get(values)); + JewelryNBT.addJewel(item, jewels.get(jValues)); + JewelryNBT.addModifier(item, new ItemStack(Items.potionitem, 1, 8270)); + + text.add(EnumChatFormatting.DARK_GREEN + "Jewel: " + EnumChatFormatting.BLACK + "None, Diamond"); + text.add("Emerald or Nether Star"); + text.add(EnumChatFormatting.DARK_GREEN + "Modifier: " + EnumChatFormatting.BLACK + "8min Potion of"); + text.add("Invisibility"); + text.add(EnumChatFormatting.DARK_GREEN + "Ingot: " + EnumChatFormatting.BLACK + "Any"); + text.add(" This ring grants you"); + text.add(EnumChatFormatting.DARK_RED + "Invisibility" + EnumChatFormatting.BLACK + " when"); + text.add("activated and in your"); + text.add("inventory, as well as"); + text.add("remove any fall damage."); + text.add("To deactivate it simply"); + Page.addImageTextPage(gui, gui.getLeft() + xPos, gui.getTop(), item, text, 50f, 0, -10, false, 45, 0); + break; + case 14: + text.add("right click with it."); + text.add("Depending on the jewel"); + text.add("you used, you get"); + text.add(EnumChatFormatting.DARK_RED + "Invisibility" + EnumChatFormatting.BLACK + " I if you"); + text.add("haven't got any jewel,"); + text.add("II for Diamond,"); + text.add("III for Emerald and"); + text.add("VIII for Nether Star."); + Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text); + break; + case 15: + if(del == 0) values++; + del++; + if(del >= 300) del = 0; + if(values > JewelrycraftUtil.metal.size() - 1) values = 0; + + JewelryNBT.addMetal(item, JewelrycraftUtil.metal.get(values)); + JewelryNBT.addJewel(item, new ItemStack(Items.nether_star)); + JewelryNBT.addModifier(item, new ItemStack(Items.book)); + + text.add(EnumChatFormatting.DARK_GREEN + "Jewel: " + EnumChatFormatting.BLACK + "Nether Star"); + text.add(EnumChatFormatting.DARK_GREEN + "Modifier: " + EnumChatFormatting.BLACK + "Book"); + text.add(EnumChatFormatting.DARK_GREEN + "Ingot: " + EnumChatFormatting.BLACK + "Any"); + text.add(" This has the power"); + text.add("to " + EnumChatFormatting.DARK_PURPLE + "Enchant" + EnumChatFormatting.BLACK + ", " + EnumChatFormatting.DARK_PURPLE + "Disenchant" + EnumChatFormatting.BLACK + ""); + text.add("or even" + EnumChatFormatting.DARK_PURPLE + " Transfer"); + text.add(EnumChatFormatting.DARK_PURPLE + "Enchantments" + EnumChatFormatting.BLACK + ". To"); + text.add("change its mode simply"); + text.add("right click it. However,"); + text.add("this ring only works"); + text.add("when it is being held."); + Page.addImageTextPage(gui, gui.getLeft() + xPos, gui.getTop(), item, text, 50f, 0, -10, false, 45, 0); + break; + case 16: + text.add(EnumChatFormatting.DARK_PURPLE + "\u00a7nDisenchanting" + EnumChatFormatting.BLACK + ""); + text.add(" If the ring is held"); + text.add("and an enchanted item"); + text.add("is placed beside it in"); + text.add("the hotbar, the ring"); + text.add("will remove all the"); + text.add("enchantments from the"); + text.add("item and store them in"); + text.add("enchanted books, which"); + text.add("are placed in your"); + text.add("inventory. Be careful"); + text.add("however, because if"); + Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text); + break; + case 17: + text.add("there is no room in"); + text.add("your inventory for the"); + text.add("books, the enchantments"); + text.add("will go in the void with"); + text.add("no way of recovering"); + text.add("them. Unfortunately,"); + text.add("disenchanting is not"); + text.add("free. It requires 2"); + text.add("levels of experience"); + text.add("per ench and some of"); + text.add("your blood. It will also"); + text.add("damage the item a bit."); + Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text); + break; + case 18: + text.add(EnumChatFormatting.DARK_PURPLE + "\u00a7nEnchanting" + EnumChatFormatting.BLACK + ""); + text.add(" This mode allows you"); + text.add("to give a random"); + text.add("enchantment to an item"); + text.add("that can hold"); + text.add("enchantments in the"); + text.add("first place. However,"); + text.add("each enchanting comes"); + text.add("with a cost. The player"); + text.add("is required to have at"); + text.add("least 1 level of xp."); + text.add("The higher the number"); + Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text); + break; + case 19: + text.add("the better, as the level"); + text.add("of the enchantment will"); + text.add("be equal with the amount"); + text.add("of levels, but this value"); + text.add("can never go over 6."); + text.add("This gives allows people"); + text.add("to get an enchantment"); + text.add("of a higher value than"); + text.add("normal (5 being the"); + text.add("limit normally)."); + Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text); + break; + case 20: + text.add(EnumChatFormatting.DARK_PURPLE + "\u00a7nEnchantment Transfer" + EnumChatFormatting.BLACK + ""); + text.add(" This mode is very"); + text.add("special as it lets you"); + text.add("transfer enchantments"); + text.add("from an item or block to"); + text.add("another, not caring if"); + text.add("the item/block can"); + text.add("actually hold enchants."); + text.add("Just place the ench"); + text.add("item on the left of the"); + text.add("ring and to the right of"); + text.add("the ring, the item you"); + Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text); + break; + case 21: + text.add("want to transfer the"); + text.add("enchs to. The ring can"); + text.add("only transfer an ench"); + text.add("at a time, after each"); + text.add("transfer it requiring a"); + text.add("cooldown."); + text.add(EnumChatFormatting.DARK_RED + " Again, this ring only"); + text.add(EnumChatFormatting.DARK_RED + "works when it is in the"); + text.add(EnumChatFormatting.DARK_RED + "players hotbar and"); + text.add(EnumChatFormatting.DARK_RED + "being held!"); + Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text); + break; + case 22: + if(del == 0) values++; + del++; + if(del >= 300) del = 0; + if(values > JewelrycraftUtil.metal.size() - 1) values = 0; + + JewelryNBT.addMetal(item, JewelrycraftUtil.metal.get(values)); + JewelryNBT.addJewel(item, new ItemStack(Items.ender_pearl)); + JewelryNBT.addModifier(item, new ItemStack(Blocks.chest)); + + text.add(EnumChatFormatting.DARK_GREEN + "Jewel: " + EnumChatFormatting.BLACK + "Ender Pearl"); + text.add(EnumChatFormatting.DARK_GREEN + "Modifier: " + EnumChatFormatting.BLACK + "Chest"); + text.add(EnumChatFormatting.DARK_GREEN + "Ingot: " + EnumChatFormatting.BLACK + "Any"); + text.add(" This ring can link"); + text.add("to any chest and"); + text.add("access its inventory."); + text.add("To link to a chest just"); + text.add("crouch and right click"); + text.add("on the one you want."); + text.add("Then right click again"); + text.add("to open that inventory."); + Page.addImageTextPage(gui, gui.getLeft() + xPos, gui.getTop(), item, text, 50f, 0, -10, false, 45, 0); + break; + case 23: + text.add("This only works if you"); + text.add("are in range to the"); + text.add("chest. You can go"); + text.add("about 128 blocks"); + text.add("before it stops"); + text.add("working. After that"); + text.add("a message will be"); + text.add("displayed saying the"); + text.add("amount of blocks you"); + text.add("need to be closer in"); + text.add("order for it to work"); + text.add("again."); + Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text); + break; + case 24: + if(del == 0) values++; + del++; + if(del >= 300) del = 0; + if(values > JewelrycraftUtil.metal.size() - 1) values = 0; + + JewelryNBT.addMetal(item, JewelrycraftUtil.metal.get(values)); + JewelryNBT.addJewel(item, new ItemStack(Blocks.obsidian)); + JewelryNBT.addModifier(item, new ItemStack(Items.ender_eye)); + + text.add(EnumChatFormatting.DARK_GREEN + "Jewel: " + EnumChatFormatting.BLACK + "Obsidian"); + text.add(EnumChatFormatting.DARK_GREEN + "Modifier: " + EnumChatFormatting.BLACK + "Eye of Ender"); + text.add(EnumChatFormatting.DARK_GREEN + "Ingot: " + EnumChatFormatting.BLACK + "Any"); + text.add(" This ring is connected"); + text.add("to your ender chest."); + text.add("Just right click it"); + text.add("anywhere to open the"); + text.add("ender chest gui."); + Page.addImageTextPage(gui, gui.getLeft() + xPos, gui.getTop(), item, text, 50f, 0, -10, false, 45, 0); + break; + case 25: + if(del == 0) values++; + del++; + if(del >= 300) del = 0; + if(values > JewelrycraftUtil.metal.size() - 1) values = 0; + + JewelryNBT.addMetal(item, JewelrycraftUtil.metal.get(values)); + JewelryNBT.addJewel(item, new ItemStack(Items.nether_star)); + JewelryNBT.addModifier(item, new ItemStack(Blocks.chest)); + + text.add(EnumChatFormatting.DARK_GREEN + "Jewel: " + EnumChatFormatting.BLACK + "Nether Star"); + text.add(EnumChatFormatting.DARK_GREEN + "Modifier: " + EnumChatFormatting.BLACK + "Chest"); + text.add(EnumChatFormatting.DARK_GREEN + "Ingot: " + EnumChatFormatting.BLACK + "Any"); + text.add(" This ring can store"); + text.add("any entity in it. To do"); + text.add("that right click an"); + text.add("to store it in the ring"); + text.add("(crouch and right click"); + text.add("if right clicking the"); + text.add("entity opens a GUI,"); + text.add("such as villagers)."); + Page.addImageTextPage(gui, gui.getLeft() + xPos, gui.getTop(), item, text, 50f, 0, -10, false, 45, 0); + break; + case 26: + text.add("Right click again on the"); + text.add("ground to release the"); + text.add("entity in that spot."); + Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text); + break; + case 27: + if(del == 0){values++; jValues++;} + del++; + if(del >= 300) del = 0; + if(values > JewelrycraftUtil.metal.size() - 1) values = 0; + if(jValues > JewelrycraftUtil.jewel.size() - 1) jValues = 0; + + JewelryNBT.addMetal(item, JewelrycraftUtil.metal.get(values)); + JewelryNBT.addJewel(item, JewelrycraftUtil.jewel.get(jValues)); + JewelryNBT.addModifier(item, new ItemStack(Items.dye, 1, 15)); + + text.add(EnumChatFormatting.DARK_GREEN + "Jewel: " + EnumChatFormatting.BLACK + "Any"); + text.add(EnumChatFormatting.DARK_GREEN + "Modifier: " + EnumChatFormatting.BLACK + "Bone Meal"); + text.add(EnumChatFormatting.DARK_GREEN + "Ingot: " + EnumChatFormatting.BLACK + "Any"); + text.add(" While having it in"); + text.add("the inventory it will"); + text.add("hydrate any farmland"); + text.add("you step on. If you"); + text.add("right click with this"); + text.add("on a plant, it will"); + text.add("speed up the growth a"); + text.add("bit. Better keep right"); + Page.addImageTextPage(gui, gui.getLeft() + xPos, gui.getTop(), item, text, 50f, 0, -10, false, 45, 0); + break; + case 28: + text.add("clicking if you want to"); + text.add("see an actual effect."); + text.add(EnumChatFormatting.DARK_RED + "\u00a7nAltar Effect"); + text.add(" In the altar, the ring"); + text.add("has the ability to"); + text.add("hydrate any tilted land"); + text.add("and speed up the"); + text.add("growth of plants in a"); + text.add("3x3x3 area."); + Page.addTextPage(gui, gui.getLeft() + xPos, gui.getTop(), text); + break; + case 29: + if(del == 0) values++; + del++; + if(del >= 300) del = 0; + if(values > JewelrycraftUtil.metal.size() - 1) values = 0; + + JewelryNBT.addMetal(item, JewelrycraftUtil.metal.get(values)); + JewelryNBT.addJewel(item, new ItemStack(Items.ender_pearl)); + JewelryNBT.addModifier(item, new ItemStack(Items.diamond_pickaxe)); + + text.add(EnumChatFormatting.DARK_GREEN + "Jewel: " + EnumChatFormatting.BLACK + "Ender Pearl"); + text.add(EnumChatFormatting.DARK_GREEN + "Modifier: " + EnumChatFormatting.BLACK + "Diamond Pick"); + text.add(EnumChatFormatting.DARK_GREEN + "Ingot: " + EnumChatFormatting.BLACK + "Any"); + text.add(" You can right click"); + text.add("any block (or crouch"); + text.add("right click) to store"); + text.add("that block inside it."); + text.add("Right click on the"); + text.add("ground to place it"); + text.add("there. It can also"); + text.add("create golems/withers."); + Page.addImageTextPage(gui, gui.getLeft() + xPos, gui.getTop(), item, text, 50f, 0, -10, false, 45, 0); + break; + case 30: + JewelryNBT.addMetal(item, new ItemStack(ItemList.shadowIngot)); + JewelryNBT.addJewel(item, new ItemStack(Items.nether_star)); + JewelryNBT.addModifier(item, new ItemStack(Items.diamond_pickaxe)); + + text.add(EnumChatFormatting.DARK_GREEN + "Jewel: " + EnumChatFormatting.BLACK + "Nether Star"); + text.add(EnumChatFormatting.DARK_GREEN + "Modifier: " + EnumChatFormatting.BLACK + "Diamond Pick"); + text.add(EnumChatFormatting.DARK_GREEN + "Ingot: " + EnumChatFormatting.BLACK + "Shadow Ingot"); + text.add(" Right clicking with"); + text.add("this on any block will"); + text.add("cause that block to"); + text.add("break instantly."); + Page.addImageTextPage(gui, gui.getLeft() + xPos, gui.getTop(), item, text, 50f, 0, -10, false, 45, 0); + break; + default:; + } + } + + public int getMaxPages() + { + return 30; + } + + @Override + public void drawForeground(GuiGuide gui, int x, int y, int page) + { + } + +} diff --git a/src/main/java/darkknight/jewelrycraft/container/Page.java b/src/main/java/darkknight/jewelrycraft/container/Page.java new file mode 100644 index 0000000..da12663 --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/container/Page.java @@ -0,0 +1,172 @@ +package darkknight.jewelrycraft.container; + +import java.util.ArrayList; + +import org.lwjgl.opengl.GL11; + +import net.minecraft.client.Minecraft; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.ResourceLocation; +import darkknight.jewelrycraft.client.GuiGuide; + +public class Page +{ + public static void addCraftingRecipeTextPage(GuiGuide gui, int x, int y, boolean isSmall, ArrayList<String> text, ArrayList<ItemStack> items, int mouseX, int mouseY) + { + y+=5; + gui.getFont().drawString(EnumChatFormatting.DARK_BLUE + "\u00a7n" + items.get(0).getDisplayName(), x + Math.abs(70 - gui.getFont().getStringWidth(items.get(0).getDisplayName())/2) - 10, y - 2, 0); + GL11.glColor4f(1, 1, 1, 1); + Minecraft.getMinecraft().getTextureManager().bindTexture(new ResourceLocation("jewelrycraft", "textures/gui/guidePageFlip.png")); + ArrayList<String> name = new ArrayList<String>(); + if(isSmall){ + gui.drawTexturedModalRect(x, y + 10, 145, 54, 111, 46); + gui.renderItem(items.get(0), x + 89, y + 22 + 10, 30f); +// gui.drawRect(x, y + 10, x + 111, y + 46, 325325); + if(items.size() > 1 && items.get(1) != null){ + gui.renderItem(items.get(1), x + 8, y + 16 + 10, 30f); + if(x - gui.getLeft() >= x + 8) gui.drawHoverString(text, x, y); + name.add(items.get(1).getDisplayName()); + if(mouseX >= x && mouseX <= x + 16 && mouseY >= y + 10 && mouseY <= y + 26) gui.drawHoverString(name, x - 8, y + 10); + name.removeAll(name); + GL11.glDisable(GL11.GL_LIGHTING); + } + if(items.size() > 2 && items.get(2) != null){ + gui.renderItem(items.get(2), x + 30, y + 16 + 10, 30f); + name.add(items.get(2).getDisplayName()); + if(mouseX >= x + 20 && mouseX <= x + 16 + 20 && mouseY >= y + 10 && mouseY <= y + 26) gui.drawHoverString(name, x + 15, y + 10); + name.removeAll(name); + GL11.glDisable(GL11.GL_LIGHTING); + } + if(items.size() > 3 && items.get(3) != null){ + gui.renderItem(items.get(3), x + 8, y + 40 + 10, 30f); + name.add(items.get(3).getDisplayName()); + if(mouseX >= x && mouseX <= x + 16 && mouseY >= y + 36 && mouseY <= y + 36 + 16) gui.drawHoverString(name, x - 8, y + 35); + name.removeAll(name); + GL11.glDisable(GL11.GL_LIGHTING); + } + if(items.size() > 4 && items.get(4) != null){ + gui.renderItem(items.get(4), x + 30, y + 40 + 10, 30f); + name.add(items.get(4).getDisplayName()); + if(mouseX >= x + 20 && mouseX <= x + 16 + 20 && mouseY >= y + 36 && mouseY <= y + 36 + 16) gui.drawHoverString(name, x + 15, y + 35); + name.removeAll(name); + GL11.glDisable(GL11.GL_LIGHTING); + } + for(int i = 0; i < text.size(); i++) gui.getFont().drawString(text.get(i), x, y + 55 + i*12, 0); + } + else{ + gui.drawTexturedModalRect(x, y + 10, 145, 0, 111, 54); + gui.renderItem(items.get(0), x + 91, y + 28 + 10, 30f); + if(items.size() > 1 && items.get(1) != null){ + gui.renderItem(items.get(1), x + 8, y + 20, 30f); + name.add(items.get(1).getDisplayName()); + if(mouseX >= x && mouseX <= x + 16 && mouseY >= y + 10 && mouseY <= y + 26) gui.drawHoverString(name, x + 8, y + 10); + name.removeAll(name); + GL11.glDisable(GL11.GL_LIGHTING); + } + if(items.size() > 2 && items.get(2) != null){ + gui.renderItem(items.get(2), x + 28, y + 20, 30f); + name.add(items.get(2).getDisplayName()); + if(mouseX >= x + 20 && mouseX <= x + 16 + 20 && mouseY >= y + 10 && mouseY <= y + 26) gui.drawHoverString(name, x + 28, y + 10); + name.removeAll(name); + GL11.glDisable(GL11.GL_LIGHTING); + } + if(items.size() > 3 && items.get(3) != null){ + gui.renderItem(items.get(3), x + 45, y + 20, 30f); + name.add(items.get(3).getDisplayName()); + if(mouseX >= x + 40 && mouseX <= x + 16 + 40 && mouseY >= y + 10 && mouseY <= y + 26) gui.drawHoverString(name, x + 45, y + 10); + name.removeAll(name); + GL11.glDisable(GL11.GL_LIGHTING); + } + if(items.size() > 4 && items.get(4) != null){ + gui.renderItem(items.get(4), x + 8, y + 37, 30f); + name.add(items.get(4).getDisplayName()); + if(mouseX >= x && mouseX <= x + 16 && mouseY >= y + 27 && mouseY <= y + 27 + 16) gui.drawHoverString(name, x + 8, y + 27); + name.removeAll(name); + GL11.glDisable(GL11.GL_LIGHTING); + } + if(items.size() > 5 && items.get(5) != null){ + gui.renderItem(items.get(5), x + 28, y + 37, 30f); + name.add(items.get(5).getDisplayName()); + if(mouseX >= x + 20 && mouseX <= x + 16 + 20 && mouseY >= y + 27 && mouseY <= y + 27 + 16) gui.drawHoverString(name, x + 28, y + 27); + name.removeAll(name); + GL11.glDisable(GL11.GL_LIGHTING); + } + if(items.size() > 6 && items.get(6) != null){ + gui.renderItem(items.get(6), x + 45, y + 37, 30f); + name.add(items.get(6).getDisplayName()); + if(mouseX >= x + 40 && mouseX <= x + 16 + 40 && mouseY >= y + 27 && mouseY <= y + 27 + 16) gui.drawHoverString(name, x + 45, y + 27); + name.removeAll(name); + GL11.glDisable(GL11.GL_LIGHTING); + } + if(items.size() > 7 && items.get(7) != null){ + gui.renderItem(items.get(7), x + 8, y + 57, 30f); + name.add(items.get(7).getDisplayName()); + if(mouseX >= x && mouseX <= x + 16 && mouseY >= y + 47 && mouseY <= y + 47 + 16) gui.drawHoverString(name, x + 8, y + 47); + name.removeAll(name); + GL11.glDisable(GL11.GL_LIGHTING); + } + if(items.size() > 8 && items.get(8) != null){ + gui.renderItem(items.get(8), x + 28, y + 57, 30f); + name.add(items.get(8).getDisplayName()); + if(mouseX >= x + 20 && mouseX <= x + 16 + 20 && mouseY >= y + 47 && mouseY <= y + 47 + 16) gui.drawHoverString(name, x + 28, y + 47); + name.removeAll(name); + GL11.glDisable(GL11.GL_LIGHTING); + } + if(items.size() > 9 && items.get(9) != null){ + gui.renderItem(items.get(9), x + 45, y + 57, 30f); + name.add(items.get(9).getDisplayName()); + if(mouseX >= x + 40 && mouseX <= x + 16 + 40 && mouseY >= y + 47 && mouseY <= y + 47 + 16) gui.drawHoverString(name, x + 45, y + 47); + name.removeAll(name); + GL11.glDisable(GL11.GL_LIGHTING); + } + for(int i = 0; i < text.size(); i++) gui.getFont().drawString(text.get(i), x, y + 62 + i*12, 0); + GL11.glColor4f(1, 1, 1, 1); + } + } + + public static void addSmeltingRecipeTextPage(GuiGuide gui, int x, int y, ArrayList<String> text, ArrayList<ItemStack> items, int mouseX, int mouseY) + { + ArrayList<String> name = new ArrayList<String>(); + gui.getFont().drawString(EnumChatFormatting.DARK_BLUE + "\u00a7n" + items.get(1).getDisplayName(), x + Math.abs(70 - gui.getFont().getStringWidth(items.get(0).getDisplayName())/2), y + 2, 0); + GL11.glColor4f(1, 1, 1, 1); + Minecraft.getMinecraft().getTextureManager().bindTexture(new ResourceLocation("jewelrycraft", "textures/gui/guidePageFlip" + ".png")); + gui.drawTexturedModalRect(x, y + 10, 145, 100, 111, 46); + + gui.renderItem(items.get(0), x + 13, y + 20 + 10, 50f); + name.add(items.get(0).getDisplayName()); + if(mouseX >= x && mouseX <= x + 20 && mouseY >= y + 20 && mouseY <= y + 20 + 16) gui.drawHoverString(name, x, y + 20); + name.removeAll(name); + GL11.glDisable(GL11.GL_LIGHTING); + + gui.renderItem(items.get(1), x + 77, y + 28 + 10, 50f); + + for(int i = 0; i < text.size(); i++) gui.getFont().drawString(text.get(i), x, y + 60 + i*12, 0); + GL11.glColor4f(1, 1, 1, 1); + } + + public static void addImageTextPage(GuiGuide gui, int x, int y, ItemStack item, ArrayList<String> text, float size) + { + y+=5; + gui.getFont().drawString(EnumChatFormatting.DARK_BLUE + "\u00a7n" + item.getDisplayName(), x + Math.abs(70 - gui.getFont().getStringWidth(item.getDisplayName())/2) - 10, y + 2, 0); + GL11.glColor4f(1, 1, 1, 1); + gui.renderItem(item, x + 13, y + 18, size); + for(int i = 0; i < text.size(); i++) gui.getFont().drawString(text.get(i), x, y + 30 + i*12, 0); + } + + public static void addImageTextPage(GuiGuide gui, int x, int y, ItemStack item, ArrayList<String> text, float size, int txtX, int txtY, boolean showName, int imgX, int imgY) + { + y+=5; + if(showName) gui.getFont().drawString(EnumChatFormatting.DARK_BLUE + "\u00a7n" + item.getDisplayName(), x + Math.abs(70 - gui.getFont().getStringWidth(item.getDisplayName())/2) - 10, y + 2, 0); + GL11.glColor4f(1, 1, 1, 1); + gui.renderItem(item, x + 13 + imgX, y + 18 + imgY, size); + for(int i = 0; i < text.size(); i++) gui.getFont().drawString(text.get(i), x + txtX, y + 30 + txtY + i*12, 0); + } + + public static void addTextPage(GuiGuide gui, int x, int y, ArrayList<String> text) + { + y-=25; + for(int i = 0; i < text.size(); i++) gui.getFont().drawString(text.get(i), x, y + 30 + i*12, 0); + GL11.glColor4f(1, 1, 1, 1); + } +} diff --git a/src/main/java/darkknight/jewelrycraft/container/SlotRingChest.java b/src/main/java/darkknight/jewelrycraft/container/SlotRingChest.java new file mode 100644 index 0000000..576dee7 --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/container/SlotRingChest.java @@ -0,0 +1,39 @@ +package darkknight.jewelrycraft.container; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; + +public class SlotRingChest extends Slot +{ + public boolean locked = false; + + public SlotRingChest(IInventory tile, int slotID, int x, int y, boolean locked) + { + super(tile, slotID, x, y); + this.locked = locked; + } + + @Override + public boolean isItemValid(ItemStack stack) + { + return !locked; + } + + @Override + public ItemStack decrStackSize(int amount) + { + if (!locked) + { + return super.decrStackSize(amount); + } + return null; + } + + @Override + public boolean canTakeStack(EntityPlayer player) + { + return !locked; + } +} diff --git a/src/main/java/darkknight/jewelrycraft/events/BucketHandler.java b/src/main/java/darkknight/jewelrycraft/events/BucketHandler.java new file mode 100644 index 0000000..64a02c3 --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/events/BucketHandler.java @@ -0,0 +1,55 @@ +/** + * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public License + * 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ +package darkknight.jewelrycraft.events; + +import java.util.HashMap; +import java.util.Map; + +import net.minecraft.block.Block; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.world.World; +import net.minecraftforge.event.entity.player.FillBucketEvent; +import cpw.mods.fml.common.eventhandler.Event.Result; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; + +public class BucketHandler { + + public static BucketHandler INSTANCE = new BucketHandler(); + public Map<Block, Item> buckets = new HashMap<Block, Item>(); + + private BucketHandler() { + } + + @SubscribeEvent + public void onBucketFill(FillBucketEvent event) { + + ItemStack result = fillCustomBucket(event.world, event.target); + + if (result == null) + return; + + event.result = result; + event.setResult(Result.ALLOW); + } + + + private ItemStack fillCustomBucket(World world, MovingObjectPosition pos) { + + Block block = world.getBlock(pos.blockX, pos.blockY, pos.blockZ); + + Item bucket = buckets.get(block); + if (bucket != null && world.getBlockMetadata(pos.blockX, pos.blockY, pos.blockZ) == 0) { + world.setBlockToAir(pos.blockX, pos.blockY, pos.blockZ); + return new ItemStack(bucket); + } else + return null; + + } +}
\ No newline at end of file diff --git a/src/main/java/darkknight/jewelrycraft/events/EntityEventHandler.java b/src/main/java/darkknight/jewelrycraft/events/EntityEventHandler.java new file mode 100644 index 0000000..d8d49a2 --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/events/EntityEventHandler.java @@ -0,0 +1,55 @@ +package darkknight.jewelrycraft.events; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.CompressedStreamTools; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.WorldServer; +import net.minecraftforge.event.entity.EntityJoinWorldEvent; +import net.minecraftforge.event.world.WorldEvent; +import darkknight.jewelrycraft.JewelrycraftMod; +import darkknight.jewelrycraft.item.ItemList; +import darkknight.jewelrycraft.util.BlockUtils; +import darkknight.jewelrycraft.util.PlayerUtils; +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; + +/** + * Code taken from OpenBlocks + */ +public class EntityEventHandler +{ + public static final String OPENBLOCKS_PERSIST_TAG = "Jewelrycraft"; + public static final String GIVEN_GUIDE_TAG = "givenGuive"; + + @SubscribeEvent + public void onEntityJoinWorld(EntityJoinWorldEvent event) + { + final Entity entity = event.entity; + /** + * If the player hasn't been given a manual, we'll give him one! (or + * throw it on the floor..) + */ + if (!event.world.isRemote && entity instanceof EntityPlayer) + { + EntityPlayer player = (EntityPlayer)entity; + NBTTagCompound persistTag = PlayerUtils.getModPlayerPersistTag(player, "Jewelrycraft"); + + boolean shouldGiveManual = ItemList.guide != null && !persistTag.getBoolean(GIVEN_GUIDE_TAG); + if (shouldGiveManual) + { + ItemStack manual = new ItemStack(ItemList.guide); + if (!player.inventory.addItemStackToInventory(manual)) + { + BlockUtils.dropItemStackInWorld(player.worldObj, player.posX, player.posY, player.posZ, manual); + } + persistTag.setBoolean(GIVEN_GUIDE_TAG, true); + } + } + } +}
\ No newline at end of file diff --git a/src/main/java/darkknight/jewelrycraft/item/ItemClayMolds.java b/src/main/java/darkknight/jewelrycraft/item/ItemClayMolds.java new file mode 100644 index 0000000..323a298 --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/item/ItemClayMolds.java @@ -0,0 +1,72 @@ +package darkknight.jewelrycraft.item; + +import java.util.List; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.util.MathHelper; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class ItemClayMolds extends Item +{ + /** List of molds color names */ + public static final String[] moldsItemNames = new String[] { "clayIngot", "clayRing", "clayNecklace" }; + @SideOnly(Side.CLIENT) + private IIcon[] moldsIcons; + + public ItemClayMolds() + { + super(); + this.setHasSubtypes(true); + this.setMaxDamage(0); + this.setMaxStackSize(1); + } + + @SideOnly(Side.CLIENT) + /** + * Gets an icon index based on an item's damage value + */ + public IIcon getIconFromDamage(int par1) + { + int j = MathHelper.clamp_int(par1, 0, moldsItemNames.length - 1); + return this.moldsIcons[j]; + } + + /** + * Returns the unlocalized name of this item. This version accepts an ItemStack so different stacks can have different names based on + * their damage or NBT. + */ + public String getUnlocalizedNameInefficiently(ItemStack par1ItemStack) + { + int i = MathHelper.clamp_int(par1ItemStack.getItemDamage(), 0, moldsItemNames.length - 1); + return super.getUnlocalizedName() + "." + moldsItemNames[i]; + } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + @SideOnly(Side.CLIENT) + /** + * returns a list of items with the same ID, but different meta (eg: molds returns 16 items) + */ + public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) + { + for (int j = 0; j < moldsItemNames.length; ++j) + { + par3List.add(new ItemStack(par1, 1, j)); + } + } + + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister par1IconRegister) + { + this.moldsIcons = new IIcon[moldsItemNames.length]; + + for (int i = 0; i < moldsItemNames.length; ++i) + { + this.moldsIcons[i] = par1IconRegister.registerIcon("jewelrycraft:" + moldsItemNames[i] + this.getIconString()); + } + } +} diff --git a/src/main/java/darkknight/jewelrycraft/item/ItemCrystal.java b/src/main/java/darkknight/jewelrycraft/item/ItemCrystal.java new file mode 100644 index 0000000..2009309 --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/item/ItemCrystal.java @@ -0,0 +1,58 @@ +package darkknight.jewelrycraft.item; + +import java.util.List; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class ItemCrystal extends Item +{ + public IIcon 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() + { + super(); + this.setHasSubtypes(true); + this.setMaxDamage(0); + } + + public void registerIcons(IIconRegister 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 IIcon getIcon(ItemStack stack, int pass) + { + return pass == 0 ? itemIcon : overlay; + } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) + { + for (int j = 0; j < 16; ++j) + { + par3List.add(new ItemStack(par1, 1, j)); + } + } + +} diff --git a/src/main/java/darkknight/jewelrycraft/item/ItemGuide.java b/src/main/java/darkknight/jewelrycraft/item/ItemGuide.java new file mode 100644 index 0000000..b4d300d --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/item/ItemGuide.java @@ -0,0 +1,26 @@ +package darkknight.jewelrycraft.item; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; +import darkknight.jewelrycraft.JewelrycraftMod; + +public class ItemGuide extends Item +{ + public ItemGuide() + { + super(); + } + + @Override + public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) + { + if (world.isRemote) + { + player.openGui(JewelrycraftMod.instance, 1, player.worldObj, 0, 0, 0); + } + + return stack; + } +}
\ No newline at end of file diff --git a/src/main/java/darkknight/jewelrycraft/item/ItemList.java b/src/main/java/darkknight/jewelrycraft/item/ItemList.java new file mode 100644 index 0000000..3a91c7b --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/item/ItemList.java @@ -0,0 +1,55 @@ +package darkknight.jewelrycraft.item; + +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidContainerRegistry; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; +import cpw.mods.fml.common.event.FMLPreInitializationEvent; +import cpw.mods.fml.common.registry.GameRegistry; +import darkknight.jewelrycraft.JewelrycraftMod; +import darkknight.jewelrycraft.block.BlockList; + +public class ItemList +{ + public static Item thiefGloves; + public static Item shadowIngot; + public static Item molds; + public static Item clayMolds; + public static Item crystal; + public static ItemRing ring; + public static ItemNecklace necklace; + public static Item guide; + public static ItemMoltenMetalBucket bucket; + + private static boolean isInitialized = false; + + public static void preInit(FMLPreInitializationEvent e) + { + if (!isInitialized) + { + thiefGloves = new ItemThiefGloves().setUnlocalizedName("Jewelrycraft.thiefGloves").setTextureName("jewelrycraft:thiefGloves").setCreativeTab(JewelrycraftMod.jewelrycraft); + shadowIngot = new Item().setUnlocalizedName("Jewelrycraft.ingotShadow").setTextureName("jewelrycraft:ingotShadow").setCreativeTab(JewelrycraftMod.jewelrycraft); + molds = new ItemMolds().setUnlocalizedName("Jewelrycraft.mold").setTextureName("Mold").setCreativeTab(JewelrycraftMod.jewelrycraft); + clayMolds = new ItemClayMolds().setUnlocalizedName("Jewelrycraft.mold").setTextureName("Mold").setCreativeTab(JewelrycraftMod.jewelrycraft); + ring = (ItemRing) new ItemRing().setUnlocalizedName("Jewelrycraft.ring").setTextureName("jewelrycraft:ring"); + crystal = new ItemCrystal().setUnlocalizedName("Jewelrycraft.crystal").setTextureName("jewelrycraft:crystal").setCreativeTab(JewelrycraftMod.jewelrycraft); + necklace = (ItemNecklace) new ItemNecklace().setUnlocalizedName("Jewelrycraft.necklace").setTextureName("jewelrycraft:necklace"); + guide = new ItemGuide().setUnlocalizedName("Jewelrycraft.guide").setTextureName("jewelrycraft:guide").setCreativeTab(JewelrycraftMod.jewelrycraft); + bucket = (ItemMoltenMetalBucket) new ItemMoltenMetalBucket().setUnlocalizedName("Jewelrycraft.bucket"); + + GameRegistry.registerItem(thiefGloves, "thiefGloves"); + GameRegistry.registerItem(shadowIngot, "shadowIngot"); + GameRegistry.registerItem(molds, "molds"); + GameRegistry.registerItem(clayMolds, "clayMolds"); + GameRegistry.registerItem(ring, "ring"); + GameRegistry.registerItem(necklace, "necklace"); + GameRegistry.registerItem(crystal, "crystal"); + GameRegistry.registerItem(guide, "guide"); + GameRegistry.registerItem(bucket, "moltenMetalBucket"); + + isInitialized = true; + } + } +} diff --git a/src/main/java/darkknight/jewelrycraft/item/ItemMolds.java b/src/main/java/darkknight/jewelrycraft/item/ItemMolds.java new file mode 100644 index 0000000..0ebb5d1 --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/item/ItemMolds.java @@ -0,0 +1,72 @@ +package darkknight.jewelrycraft.item; + +import java.util.List; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.util.MathHelper; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class ItemMolds extends Item +{ + /** List of molds color names */ + public static final String[] moldsItemNames = new String[] { "ingot", "ring", "necklace" }; + @SideOnly(Side.CLIENT) + private IIcon[] moldsIcons; + + public ItemMolds() + { + super(); + this.setHasSubtypes(true); + this.setMaxDamage(0); + this.setMaxStackSize(1); + } + + @SideOnly(Side.CLIENT) + /** + * Gets an icon index based on an item's damage value + */ + public IIcon getIconFromDamage(int par1) + { + int j = MathHelper.clamp_int(par1, 0, moldsItemNames.length - 1); + return this.moldsIcons[j]; + } + + /** + * Returns the unlocalized name of this item. This version accepts an ItemStack so different stacks can have different names based on + * their damage or NBT. + */ + public String getUnlocalizedName(ItemStack par1ItemStack) + { + int i = MathHelper.clamp_int(par1ItemStack.getItemDamage(), 0, moldsItemNames.length - 1); + return super.getUnlocalizedName() + "." + moldsItemNames[i]; + } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + @SideOnly(Side.CLIENT) + /** + * returns a list of items with the same ID, but different meta (eg: molds returns 16 items) + */ + public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) + { + for (int j = 0; j < moldsItemNames.length; ++j) + { + par3List.add(new ItemStack(par1, 1, j)); + } + } + + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister par1IconRegister) + { + this.moldsIcons = new IIcon[moldsItemNames.length]; + + for (int i = 0; i < moldsItemNames.length; ++i) + { + this.moldsIcons[i] = par1IconRegister.registerIcon("jewelrycraft:" + moldsItemNames[i] + this.getIconString()); + } + } +} diff --git a/src/main/java/darkknight/jewelrycraft/item/ItemMoltenMetalBucket.java b/src/main/java/darkknight/jewelrycraft/item/ItemMoltenMetalBucket.java new file mode 100644 index 0000000..18a17ad --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/item/ItemMoltenMetalBucket.java @@ -0,0 +1,309 @@ +package darkknight.jewelrycraft.item; + +import java.awt.image.BufferedImage; +import java.io.BufferedOutputStream; +import java.io.BufferedWriter; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.io.OutputStreamWriter; +import java.nio.file.Files; +import java.nio.file.StandardOpenOption; + +import javax.imageio.ImageIO; + +import net.minecraft.block.material.Material; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.client.resources.IResourceManager; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.CompressedStreamTools; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.IIcon; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.StatCollector; +import net.minecraft.world.World; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.entity.player.FillBucketEvent; +import cpw.mods.fml.common.eventhandler.Event; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import darkknight.jewelrycraft.JewelrycraftMod; +import darkknight.jewelrycraft.block.BlockList; +import darkknight.jewelrycraft.util.JewelryNBT; +import darkknight.jewelrycraft.util.JewelrycraftUtil; + +public class ItemMoltenMetalBucket extends Item +{ + public IIcon liquid; + public ItemMoltenMetalBucket() + { + this.maxStackSize = 1; + } + + /** + * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer + */ + public ItemStack onItemRightClick(ItemStack stack, World par2World, EntityPlayer par3EntityPlayer) + { + boolean flag = BlockList.moltenMetal == Blocks.air; + MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(par2World, par3EntityPlayer, flag); + + if (movingobjectposition == null) + { + return stack; + } + else + { + FillBucketEvent event = new FillBucketEvent(par3EntityPlayer, stack, par2World, movingobjectposition); + if (MinecraftForge.EVENT_BUS.post(event)) + { + return stack; + } + + if (event.getResult() == Event.Result.ALLOW) + { + if (par3EntityPlayer.capabilities.isCreativeMode) + { + return stack; + } + + if (--stack.stackSize <= 0) + { + return event.result; + } + + if (!par3EntityPlayer.inventory.addItemStackToInventory(event.result)) + { + par3EntityPlayer.dropPlayerItemWithRandomChoice(event.result, false); + } + + return stack; + } + if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) + { + int i = movingobjectposition.blockX; + int j = movingobjectposition.blockY; + int k = movingobjectposition.blockZ; + + if (!par2World.canMineBlock(par3EntityPlayer, i, j, k)) + { + return stack; + } + + if (flag) + { + if (!par3EntityPlayer.canPlayerEdit(i, j, k, movingobjectposition.sideHit, stack)) + { + return stack; + } + + Material material = par2World.getBlock(i, j, k).getMaterial(); + int l = par2World.getBlockMetadata(i, j, k); + par2World.setBlockToAir(i, j, k); + return this.func_150910_a(stack, par3EntityPlayer, ItemList.bucket); + } + else + { + if (BlockList.moltenMetal == Blocks.air) + { + return new ItemStack(Items.bucket); + } + + if (movingobjectposition.sideHit == 0) + { + --j; + } + + if (movingobjectposition.sideHit == 1) + { + ++j; + } + + if (movingobjectposition.sideHit == 2) + { + --k; + } + + if (movingobjectposition.sideHit == 3) + { + ++k; + } + + if (movingobjectposition.sideHit == 4) + { + --i; + } + + if (movingobjectposition.sideHit == 5) + { + ++i; + } + + if (!par3EntityPlayer.canPlayerEdit(i, j, k, movingobjectposition.sideHit, stack)) + { + return stack; + } + + try { + if (this.tryPlaceContainedLiquid(par2World, i, j, k, stack) && !par3EntityPlayer.capabilities.isCreativeMode) + { + return new ItemStack(Items.bucket); + } + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + + return stack; + } + } + + private ItemStack func_150910_a(ItemStack p_150910_1_, EntityPlayer p_150910_2_, Item p_150910_3_) + { + if (p_150910_2_.capabilities.isCreativeMode) + { + return p_150910_1_; + } + else if (--p_150910_1_.stackSize <= 0) + { + return new ItemStack(p_150910_3_); + } + else + { + if (!p_150910_2_.inventory.addItemStackToInventory(new ItemStack(p_150910_3_))) + { + p_150910_2_.dropPlayerItemWithRandomChoice(new ItemStack(p_150910_3_, 1, 0), false); + } + + return p_150910_1_; + } + } + + /** + * Attempts to place the liquid contained inside the bucket. + * @throws IOException + */ + public boolean tryPlaceContainedLiquid(World par1World, int par2, int par3, int par4, ItemStack stack) throws IOException + { + if (BlockList.moltenMetal == Blocks.air) + { + return false; + } + else + { + Material material = par1World.getBlock(par2, par3, par4).getMaterial(); + boolean flag = !material.isSolid(); + + if (!par1World.isAirBlock(par2, par3, par4) && !flag) return false; + else + { + if (!par1World.isRemote && flag && !material.isLiquid()) par1World.func_147480_a(par2, par3, par4, true); + JewelrycraftUtil.liquids.put(String.valueOf(par2) + " " + String.valueOf(par3) + " " + String.valueOf(par4), JewelryNBT.ingot(stack).getItem()); + JewelrycraftMod.saveData = new NBTTagCompound(); + JewelrycraftMod.saveData.setString("coords", String.valueOf(par2) + " " + String.valueOf(par3) + " " + String.valueOf(par4)); + JewelrycraftMod.saveData.setInteger("item", Item.getIdFromItem(JewelryNBT.ingot(stack).getItem())); + CompressedStreamTools.writeCompressed(JewelrycraftMod.saveData, new FileOutputStream(JewelrycraftMod.liquidsConf)); + System.out.println(JewelrycraftMod.saveData.getString("coords")); + par1World.setBlock(par2, par3, par4, BlockList.moltenMetal, 0, 3); + return true; + } + } + } + + public void registerIcons(IIconRegister iconRegister) + { + itemIcon = iconRegister.registerIcon("bucket_empty"); + liquid = iconRegister.registerIcon("jewelrycraft:bucketOverlay"); + } + + @SideOnly(Side.CLIENT) + public int getColorFromItemStack(ItemStack stack, int pass) + { + try + { + return color(stack, pass); + } + catch (IOException e) + { + e.printStackTrace(); + } + return 16777215; + } + + @Override + public boolean requiresMultipleRenderPasses() + { + return true; + } + + public IIcon getIcon(ItemStack stack, int pass) + { + if(pass == 0) return itemIcon; + if(pass == 1) return liquid; + return itemIcon; + } + + public static int color(ItemStack stack, int pass) throws IOException + { + String domain = "", texture; + IResourceManager rm = Minecraft.getMinecraft().getResourceManager(); + BufferedImage icon; + int x=0, y=0, ok = 0, red, green, blue; + if (pass == 1 && JewelryNBT.ingot(stack) != null && JewelryNBT.ingot(stack).getIconIndex() != null && JewelryNBT.ingotColor(stack) == 16777215) + { + String ingotIconName = JewelryNBT.ingot(stack).getIconIndex().getIconName(); + + if (ingotIconName.substring(0, ingotIconName.indexOf(":") + 1) != "") domain = ingotIconName.substring(0, ingotIconName.indexOf(":") + 1).replace(":", " ").trim(); + else domain = "minecraft"; + + texture = ingotIconName.substring(ingotIconName.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); + + icon = ImageIO.read(rm.getResource(ingot).getInputStream()); + while(ok == 0) + { + red = (icon.getRGB(x, y) >> 16) & 0xFF; + green = (icon.getRGB(x, y) >> 8) & 0xFF; + blue = icon.getRGB(x, y) & 0xFF; + if((red <= 80 && green <= 80 && blue <= 80) || (red >= 180 && green >= 180 && blue >= 180)) + { + if(x<icon.getTileWidth()-1) x++; + if(x>=icon.getTileWidth()-1 && y<icon.getTileWidth()-1) + { + x=0; + y++; + } + if(x == icon.getTileWidth()-1 && y==icon.getTileWidth()-1) ok=1; + } + else ok=1; + } + JewelryNBT.addIngotColor(stack, icon.getRGB(x, y)); + } + if(JewelryNBT.ingot(stack) != null && pass == 1) return JewelryNBT.ingotColor(stack); + return 16777215; + } + + public ItemStack getModifiedItemStack(ItemStack ingot) + { + ItemStack itemstack = new ItemStack(this); + JewelryNBT.addMetal(itemstack, ingot); + return itemstack; + } + + public String getItemStackDisplayName(ItemStack stack) + { + if(JewelryNBT.ingot(stack) != null) return (StatCollector.translateToLocal(this.getUnlocalizedNameInefficiently(stack) + ".name")).trim() + " " + JewelryNBT.ingot(stack).getDisplayName().replace("Ingot", " ").trim() ; + return ("" + StatCollector.translateToLocal(this.getUnlocalizedNameInefficiently(stack) + ".name")).trim() + " Metal"; + } +} diff --git a/src/main/java/darkknight/jewelrycraft/item/ItemNecklace.java b/src/main/java/darkknight/jewelrycraft/item/ItemNecklace.java new file mode 100644 index 0000000..71af0a0 --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/item/ItemNecklace.java @@ -0,0 +1,272 @@ +package darkknight.jewelrycraft.item; + +import java.io.IOException; +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.potion.Potion; +import net.minecraft.potion.PotionEffect; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.IIcon; +import net.minecraft.util.StatCollector; +import net.minecraft.world.World; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import darkknight.jewelrycraft.util.JewelryNBT; + +public class ItemNecklace extends Item +{ + public IIcon jewel; + private double amplifier; + int index = 0; + + public ItemNecklace() + { + super(); + this.setMaxStackSize(1); + } + + public void registerIcons(IIconRegister iconRegister) + { + itemIcon = iconRegister.registerIcon("jewelrycraft:necklace"); + jewel = iconRegister.registerIcon("jewelrycraft:jewelNecklace"); + } + + @Override + public boolean requiresMultipleRenderPasses() + { + return true; + } + + @SideOnly(Side.CLIENT) + public int getColorFromItemStack(ItemStack stack, int pass) + { + try + { + return ItemRing.color(stack, pass); + } + catch (IOException e) + { + e.printStackTrace(); + } + return 16777215; + } + + public IIcon getIcon(ItemStack stack, int pass) + { + if(pass == 0) return itemIcon; + if(pass == 1 && JewelryNBT.jewel(stack) != null) return jewel; + return itemIcon; + } + + public String getItemStackDisplayName(ItemStack stack) + { + if(JewelryNBT.ingot(stack) != null) return JewelryNBT.ingot(stack).getDisplayName().replace("Ingot", " ").trim() + " " + ("" + StatCollector.translateToLocal(this.getUnlocalizedNameInefficiently(stack) + ".name")).trim(); + return ("" + StatCollector.translateToLocal(this.getUnlocalizedNameInefficiently(stack) + ".name")).trim(); + } + + @SuppressWarnings({ "rawtypes" }) + public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) + { + if (!world.isRemote) + { + List entities = world.getEntitiesWithinAABB(EntityLivingBase.class, AxisAlignedBB.getBoundingBox(player.posX - 1.5D, player.posY, player.posZ - 1.5D, player.posX + 1.5D, player.posY + 2D, player.posZ + 1.5D)); + if (JewelryNBT.playerPosX(stack) != -1 && JewelryNBT.playerPosY(stack) != -1 && JewelryNBT.playerPosZ(stack) != -1) + { + double posX = JewelryNBT.playerPosX(stack), posY = JewelryNBT.playerPosY(stack), posZ = JewelryNBT.playerPosZ(stack); + if (JewelryNBT.isJewelX(stack, new ItemStack(Items.ender_pearl)) && JewelryNBT.isModifierX(stack, new ItemStack(Items.bed)) && JewelryNBT.dimension(stack) != -2 && JewelryNBT.dimName(stack) != null) + { + int dimension = JewelryNBT.dimension(stack); + for (int i = 1; i <= 20; i++) world.spawnParticle("largesmoke", player.posX - 0.5D + Math.random(), player.posY - 1.5D + Math.random(), player.posZ - 0.5D + Math.random(), 0.0D, 0.0D, 0.0D); + if (!JewelryNBT.isDimensionX(stack, player.dimension)) player.travelToDimension(dimension); + for (int i = 0; i < entities.size(); i++) ((EntityLivingBase)entities.get(i)).setPositionAndUpdate(posX, posY, posZ); + for (int i = 1; i <= 300; i++) world.spawnParticle("portal", posX - 0.5D + Math.random(), posY + Math.random(), posZ - 0.5D + Math.random(), 0.0D, 0.0D, 0.0D); + } + else if(JewelryNBT.isDimensionX(stack, player.dimension)) + { + for (int i = 1; i <= 20; i++) world.spawnParticle("largesmoke", player.posX - 0.5D + Math.random(), player.posY - 1.5D + Math.random(), player.posZ - 0.5D + Math.random(), 0.0D, 0.0D, 0.0D); + for (int i = 0; i < entities.size(); i++) ((EntityLivingBase)entities.get(i)).setPositionAndUpdate(posX, posY, posZ); + for (int i = 1; i <= 300; i++) world.spawnParticle("portal", posX - 0.5D + Math.random(), posY + Math.random(), posZ - 0.5D + Math.random(), 0.0D, 0.0D, 0.0D); + } + else player.addChatMessage(new ChatComponentText("You can't teleport to these coordonates! You need to be in the same dimension they were set!")); + } + else if(JewelryNBT.isJewelX(stack, new ItemStack(Items.ender_pearl)) && JewelryNBT.isModifierX(stack, new ItemStack(Items.bed)) && JewelryNBT.dimension(stack) == -2 && JewelryNBT.playerPosX(stack) == -1 && JewelryNBT.playerPosY(stack) == -1 && JewelryNBT.playerPosZ(stack) == -1){ + JewelryNBT.addCoordonatesAndDimension(stack, player.posX, player.posY, player.posZ, world.provider.dimensionId, world.provider.getDimensionName()); + JewelryNBT.addFakeEnchantment(stack); + } + else if (JewelryNBT.isJewelX(stack, new ItemStack(Items.ender_pearl)) && !JewelryNBT.hasTag(stack, "modifier") && JewelryNBT.playerPosX(stack) == -1 && JewelryNBT.playerPosY(stack) == -1 && JewelryNBT.playerPosZ(stack) == -1){ + JewelryNBT.addCoordonatesAndDimension(stack, player.posX, player.posY, player.posZ, world.provider.dimensionId, world.provider.getDimensionName()); + JewelryNBT.addFakeEnchantment(stack); + } + + if(JewelryNBT.hasTag(stack, "mode")) + { + String mode = ""; + if(JewelryNBT.isModeX(stack, "Activated")) mode = "Deactivated"; + else if(JewelryNBT.isModeX(stack, "Deactivated")) mode = "Activated"; + if(mode != "") + { + player.addChatMessage(new ChatComponentText("The Necklace has been " + mode)); + JewelryNBT.addMode(stack, mode); + } + } + } + return stack; + } + +// @Override +// public boolean itemInteractionForEntity(ItemStack stack, EntityPlayer player, EntityLivingBase entity) +// { +// 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(); +// JewelryNBT.addFakeEnchantment(stack); +// } +// return true; +// } + + /** + * allows items to add custom lines of information to the mouseover + * description + */ + public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4) + { + if (stack.hasTagCompound() && Minecraft.getMinecraft().gameSettings.advancedItemTooltips) + { + ItemStack ingot = JewelryNBT.ingot(stack); + if (ingot != null) list.add("Ingot: " + EnumChatFormatting.YELLOW + ingot.getDisplayName()); + + ItemStack jewel = JewelryNBT.jewel(stack); + if (jewel != null) list.add("Jewel: " + EnumChatFormatting.BLUE + jewel.getDisplayName()); + + ItemStack modifier = JewelryNBT.modifier(stack); + if(modifier != null) list.add("Modifier: " + EnumChatFormatting.DARK_PURPLE + modifier.getDisplayName()); + + double playerPosX = JewelryNBT.playerPosX(stack), playerPosY = JewelryNBT.playerPosY(stack), playerPosZ = JewelryNBT.playerPosZ(stack); + if(playerPosX != -1 && playerPosY != -1 && playerPosZ != -1) list.add(EnumChatFormatting.YELLOW + "X: " + EnumChatFormatting.GRAY + (int) playerPosX + EnumChatFormatting.YELLOW + " Y: " + EnumChatFormatting.GRAY + (int) playerPosY + EnumChatFormatting.YELLOW + " Z: " + EnumChatFormatting.GRAY + (int) playerPosZ); + + int posX = JewelryNBT.blockCoordX(stack), posY = JewelryNBT.blockCoordY(stack), posZ = JewelryNBT.blockCoordZ(stack); + if(posX != -1 && posY != -1 && posZ != -1) list.add(EnumChatFormatting.YELLOW + "X: " + EnumChatFormatting.GRAY + (int) posX + EnumChatFormatting.YELLOW + " Y: " + EnumChatFormatting.GRAY + (int) posY + EnumChatFormatting.YELLOW + " Z: " + EnumChatFormatting.GRAY + (int) posZ); + + String name = JewelryNBT.dimName(stack); + if(name != null) list.add("Dimension: " + EnumChatFormatting.DARK_GREEN + name); + + EntityLivingBase entity = JewelryNBT.entity(stack, player); + if (entity != null) list.add("Entity: " + EnumChatFormatting.GOLD + entity.getCommandSenderName()); + + String modeN = JewelryNBT.modeName(stack); + if(modeN != null) list.add("Mode: " + modeN); + + int block = JewelryNBT.blockID(stack); + if(block != -1) list.add("Block: " + StatCollector.translateToLocalFormatted(Block.getBlockById(block).getUnlocalizedName())); + + int blockmeta = JewelryNBT.blockMetadata(stack); + if(blockmeta != -1) list.add("Block Metadata: " + blockmeta); + + TileEntity tile = JewelryNBT.tileEntity(stack); + if(tile != null) list.add(EnumChatFormatting.RED + "Contains a tile entity"); + + int blockX = JewelryNBT.blockCoordX(stack); + if(blockX != -1) list.add("Block Coords X: " + blockX); + + int blockY = JewelryNBT.blockCoordY(stack); + if(blockY != -1) list.add("Block Coords Y: " + blockY); + + int blockZ = JewelryNBT.blockCoordZ(stack); + if(blockZ != -1) list.add("Block Coords Z: " + blockZ); + + // 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); + } + } + + public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int i, int j, int k, int side, float par8, float par9, float par10) + { + amplifier = 0; + if (JewelryNBT.isJewelX(stack, new ItemStack(Items.diamond))) amplifier = 1D; + else if (JewelryNBT.isJewelX(stack, new ItemStack(Items.emerald))) amplifier = 2D; + else if (JewelryNBT.isJewelX(stack, new ItemStack(Items.nether_star))) amplifier = 5D; + + if (!world.isRemote) + { + onItemRightClick(stack, world, player); + if(JewelryNBT.isModifierX(stack, new ItemStack(Items.dye, 1, 15))) + for(int x = (int) - amplifier; x <= amplifier; x++) + for(int z = (int) - amplifier; z <= amplifier; z++) + world.scheduleBlockUpdate(i + x, j, k + z, world.getBlock(i + x, j, k + z), 7 - (int)amplifier); + + for(int x = (int) - 1; x <= 1; x++) + for(int z = (int) - 1; z <= 1; z++) + if(JewelryNBT.isModifierX(stack, new ItemStack(Items.diamond_pickaxe)) && JewelryNBT.isJewelX(stack, new ItemStack(Items.nether_star)) && JewelryNBT.isIngotX(stack, new ItemStack(ItemList.shadowIngot))) + if((side == 0 || side == 1) && j > 0 && world.getBlock(i + x, j, k + z) != Blocks.bedrock) world.func_147480_a(i + x, j, k + z, true); + else if((side == 2 || side == 3) && j + x > 0 && world.getBlock(i + z, j + x, k) != Blocks.bedrock) world.func_147480_a(i + z, j + x, k, true); + else if((side == 4 || side == 5) && j + x > 0 && world.getBlock(i, j + x, k + z) != Blocks.bedrock) world.func_147480_a(i, j + x, k + z, true); + } + return true; + } + + public void onUpdate(ItemStack stack, World world, Entity entity, int par4, boolean par5) + { + amplifier = 0D; + if (!world.isRemote) + { + EntityPlayer entityplayer = (EntityPlayer) entity; + int posX = (int)Math.floor(entityplayer.posX), posY = (int)Math.floor(entityplayer.posY), posZ = (int)Math.floor(entityplayer.posZ); + + if (JewelryNBT.isJewelX(stack, new ItemStack(Items.diamond))) amplifier = 1D; + else if (JewelryNBT.isJewelX(stack, new ItemStack(Items.emerald))) amplifier = 2D; + else if (JewelryNBT.isJewelX(stack, new ItemStack(Items.nether_star))) amplifier = 5D; + + if(JewelryNBT.isModifierX(stack, new ItemStack(Items.dye, 1, 15)) && world.getBlock(posX, posY - 1, posZ) == Blocks.farmland) + for(int i = (int) - amplifier; i <= amplifier; i++) + for(int j = (int) - amplifier; j <= amplifier; j++) + world.setBlockMetadataWithNotify(posX + i, posY - 1, posZ + j, 1, 7); + + List entities = world.getEntitiesWithinAABB(EntityLivingBase.class, AxisAlignedBB.getBoundingBox(entityplayer.posX - amplifier, entityplayer.posY - amplifier, entityplayer.posZ - amplifier, entityplayer.posX + amplifier, entityplayer.posY + 2*amplifier, entityplayer.posZ + amplifier)); + if(JewelryNBT.isModeX(stack, "Activated")) + { + for(int i = 0; i < entities.size(); i++) + { + if (JewelryNBT.isModifierX(stack, new ItemStack(Items.blaze_powder))) ((EntityLivingBase) entities.get(i)).addPotionEffect(new PotionEffect(Potion.fireResistance.id, 4, 0, true)); + else if (JewelryNBT.isModifierX(stack, new ItemStack(Items.sugar))) ((EntityLivingBase) entities.get(i)).addPotionEffect(new PotionEffect(Potion.moveSpeed.id, 4, 0, true)); + else if (JewelryNBT.isModifierX(stack, new ItemStack(Items.iron_pickaxe)) && !JewelryNBT.isJewelX(stack, new ItemStack(Items.ender_pearl))) ((EntityLivingBase) entities.get(i)).addPotionEffect(new PotionEffect(Potion.digSpeed.id, 4, 0, true)); + else if (JewelryNBT.isModifierX(stack, new ItemStack(Items.feather))) + { + ((EntityLivingBase) entities.get(i)).addPotionEffect(new PotionEffect(Potion.jump.id, 4, 0, true)); + entityplayer.fallDistance = 0; + } + else if (JewelryNBT.isModifierX(stack, new ItemStack(Items.potionitem, 1, 8270))) ((EntityLivingBase) entities.get(i)).addPotionEffect(new PotionEffect(Potion.invisibility.id, 4, 0, true)); + } + } + } + } + + 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.isJewelX(itemstack, new ItemStack(Items.ender_pearl)) && JewelryNBT.isModifierX(itemstack, new ItemStack(Items.iron_pickaxe)))) JewelryNBT.addMode(itemstack, "Activated"); + if(JewelryNBT.isJewelX(itemstack, new ItemStack(Items.nether_star)) && JewelryNBT.isModifierX(itemstack, new ItemStack(Items.book))) + JewelryNBT.addMode(itemstack, "Disenchant"); + return itemstack; + } +} diff --git a/src/main/java/darkknight/jewelrycraft/item/ItemRing.java b/src/main/java/darkknight/jewelrycraft/item/ItemRing.java new file mode 100644 index 0000000..fff9120 --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/item/ItemRing.java @@ -0,0 +1,599 @@ +package darkknight.jewelrycraft.item; + +import java.awt.image.BufferedImage; +import java.io.IOException; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Random; + +import javax.imageio.ImageIO; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockChest; +import net.minecraft.block.BlockSkull; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.client.resources.IResourceManager; +import net.minecraft.enchantment.Enchantment; +import net.minecraft.enchantment.EnchantmentHelper; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.monster.EntityIronGolem; +import net.minecraft.entity.monster.EntitySnowman; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.inventory.InventoryEnderChest; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.potion.Potion; +import net.minecraft.potion.PotionEffect; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.tileentity.TileEntityChest; +import net.minecraft.tileentity.TileEntitySkull; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.IIcon; +import net.minecraft.util.MathHelper; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.StatCollector; +import net.minecraft.world.World; +import cpw.mods.fml.common.network.internal.FMLNetworkHandler; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import darkknight.jewelrycraft.JewelrycraftMod; +import darkknight.jewelrycraft.block.BlockList; +import darkknight.jewelrycraft.util.JewelryNBT; + +public class ItemRing extends Item +{ + public IIcon jewel; + private int amplifier, cooldown = 0; + int index = 0; + + public ItemRing() + { + super(); + this.setMaxStackSize(1); + } + + public void registerIcons(IIconRegister iconRegister) + { + itemIcon = iconRegister.registerIcon("jewelrycraft:ring"); + jewel = iconRegister.registerIcon("jewelrycraft:jewelRing"); + } + + @Override + public boolean requiresMultipleRenderPasses() + { + return true; + } + + @SideOnly(Side.CLIENT) + public int getColorFromItemStack(ItemStack stack, int pass) + { + try + { + return color(stack, pass); + } + catch (IOException e) + { + e.printStackTrace(); + } + return 16777215; + } + + public IIcon getIcon(ItemStack stack, int pass) + { + if(pass == 0) return itemIcon; + if(pass == 1 && JewelryNBT.jewel(stack) != null) return jewel; + return itemIcon; + } + + public static int color(ItemStack stack, int pass) throws IOException + { + String domain = "", texture; + IResourceManager rm = Minecraft.getMinecraft().getResourceManager(); + BufferedImage icon; + int x=0, y=0, ok = 0, red, green, blue; + if (pass == 0 && JewelryNBT.ingot(stack) != null && JewelryNBT.ingot(stack).getIconIndex() != null && JewelryNBT.ingotColor(stack) == 16777215) + { + String ingotIconName = JewelryNBT.ingot(stack).getIconIndex().getIconName(); + + if (ingotIconName.substring(0, ingotIconName.indexOf(":") + 1) != "") domain = ingotIconName.substring(0, ingotIconName.indexOf(":") + 1).replace(":", " ").trim(); + else domain = "minecraft"; + + texture = ingotIconName.substring(ingotIconName.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); + + icon = ImageIO.read(rm.getResource(ingot).getInputStream()); + while(ok == 0) + { + red = (icon.getRGB(x, y) >> 16) & 0xFF; + green = (icon.getRGB(x, y) >> 8) & 0xFF; + blue = icon.getRGB(x, y) & 0xFF; + if((red <= 80 && green <= 80 && blue <= 80) || (red >= 180 && green >= 180 && blue >= 180)) + { + if(x<icon.getTileWidth()-1) x++; + if(x>=icon.getTileWidth()-1 && y<icon.getTileWidth()-1) + { + x=0; + y++; + } + if(x == icon.getTileWidth()-1 && y==icon.getTileWidth()-1) ok=1; + } + else ok=1; + } + JewelryNBT.addIngotColor(stack, icon.getRGB(x, y)); + } + else if (pass == 1 && JewelryNBT.jewel(stack) != null && JewelryNBT.jewel(stack).getIconIndex() != null && JewelryNBT.jewelColor(stack) == 16777215) + { + x = 0; y = 0; ok=0; + String jewelIconName = JewelryNBT.jewel(stack).getIconIndex().getIconName(); + + if (jewelIconName.substring(0, jewelIconName.indexOf(":") + 1) != "") domain = jewelIconName.substring(0, jewelIconName.indexOf(":") + 1).replace(":", " ").trim(); + else domain = "minecraft"; + + texture = jewelIconName.substring(jewelIconName.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); + + icon = ImageIO.read(rm.getResource(jewelLoc).getInputStream()); + while(ok == 0) + { + red = (icon.getRGB(x, y) >> 16) & 0xFF; + green = (icon.getRGB(x, y) >> 8) & 0xFF; + blue = icon.getRGB(x, y) & 0xFF; + if((red <= 95 && green <= 95 && blue <= 95) || (red >= 180 && green >= 180 && blue >= 180)) + { + if(x<icon.getTileWidth()-1) x++; + if(x>=icon.getTileWidth()-1 && y<icon.getTileWidth()-1) + { + x=0; + y++; + } + if(x == icon.getTileWidth()-1 && y==icon.getTileWidth()-1) ok=1; + } + else ok=1; + } + if(JewelryNBT.jewel(stack).getItem().getColorFromItemStack(JewelryNBT.jewel(stack), 1) == 16777215) JewelryNBT.addJewelColor(stack, icon.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; + } + + public String getItemStackDisplayName(ItemStack stack) + { + if (JewelryNBT.ingot(stack) != null && JewelryNBT.jewel(stack) != null && JewelryNBT.modifier(stack) == null && JewelryNBT.isJewelX(stack, new ItemStack(Items.diamond)) && JewelryNBT.isIngotX(stack, new ItemStack(Items.gold_ingot))) return "Wedding Ring"; + else if(JewelryNBT.ingot(stack) != null) return JewelryNBT.ingot(stack).getDisplayName().replace("Ingot", " ").trim() + " " + ("" + StatCollector.translateToLocal(this.getUnlocalizedNameInefficiently(stack) + ".name")).trim(); + return ("" + StatCollector.translateToLocal(this.getUnlocalizedNameInefficiently(stack) + ".name")).trim(); + } + + public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) + { + if (!world.isRemote){ + if (JewelryNBT.playerPosX(stack) != -1 && JewelryNBT.playerPosY(stack) != -1 && JewelryNBT.playerPosZ(stack) != -1) + { + double posX = JewelryNBT.playerPosX(stack), posY = JewelryNBT.playerPosY(stack), posZ = JewelryNBT.playerPosZ(stack); + if (JewelryNBT.isJewelX(stack, new ItemStack(Items.ender_pearl)) && JewelryNBT.isModifierX(stack, new ItemStack(Items.bed)) && JewelryNBT.dimension(stack) != -2 && JewelryNBT.dimName(stack) != null) + { + int dimension = JewelryNBT.dimension(stack); + for (int i = 1; i <= 20; i++) world.spawnParticle("largesmoke", player.posX - 0.5D + Math.random(), player.posY - 1.5D + Math.random(), player.posZ - 0.5D + Math.random(), 0.0D, 0.0D, 0.0D); + if (!JewelryNBT.isDimensionX(stack, player.dimension)) player.travelToDimension(dimension); + player.setPositionAndUpdate(posX, posY, posZ); + for (int i = 1; i <= 300; i++) world.spawnParticle("portal", posX - 0.5D + Math.random(), posY + Math.random(), posZ - 0.5D + Math.random(), 0.0D, 0.0D, 0.0D); + } + else if(JewelryNBT.isDimensionX(stack, player.dimension)) + { + for (int i = 1; i <= 20; i++) world.spawnParticle("largesmoke", player.posX - 0.5D + Math.random(), player.posY - 1.5D + Math.random(), player.posZ - 0.5D + Math.random(), 0.0D, 0.0D, 0.0D); + player.setPositionAndUpdate(posX, posY, posZ); + for (int i = 1; i <= 300; i++) world.spawnParticle("portal", posX - 0.5D + Math.random(), posY + Math.random(), posZ - 0.5D + Math.random(), 0.0D, 0.0D, 0.0D); + } + else player.addChatMessage(new ChatComponentText("You can't teleport to these coordonates! You need to be in the same dimension they were set!")); + } + else if(JewelryNBT.isJewelX(stack, new ItemStack(Items.ender_pearl)) && JewelryNBT.isModifierX(stack, new ItemStack(Items.bed)) && JewelryNBT.dimension(stack) == -2 && JewelryNBT.playerPosX(stack) == -1 && JewelryNBT.playerPosY(stack) == -1 && JewelryNBT.playerPosZ(stack) == -1){ + JewelryNBT.addCoordonatesAndDimension(stack, player.posX, player.posY, player.posZ, world.provider.dimensionId, world.provider.getDimensionName()); + JewelryNBT.addFakeEnchantment(stack); + } + else if (JewelryNBT.isJewelX(stack, new ItemStack(Blocks.obsidian)) && JewelryNBT.isModifierX(stack, new ItemStack(Items.ender_eye))) + { + InventoryEnderChest inventoryenderchest = player.getInventoryEnderChest(); + player.displayGUIChest(inventoryenderchest); + } + else if (JewelryNBT.isJewelX(stack, new ItemStack(Items.ender_pearl)) && JewelryNBT.isModifierX(stack, new ItemStack(Blocks.chest))){ + int i = JewelryNBT.blockCoordX(stack), j = JewelryNBT.blockCoordY(stack), k = JewelryNBT.blockCoordZ(stack); + if (player.getDistance(i + 0.5F, j + 0.5F, k + 0.5F) <= 128 && i != -1 && j != -1 && k != -1){ + Block block = world.getBlock(i, j, k); + if (!block.isAir(world, i, j, k) && block instanceof BlockChest){ + TileEntity tile = world.getTileEntity(i, j, k); + if (tile != null && tile instanceof TileEntityChest) FMLNetworkHandler.openGui(player, JewelrycraftMod.instance, 0, world, i, j, k); + } + } + else if(i != -1 && j != -1 && k != -1) player.addChatMessage(new ChatComponentText("Chest out of range! You need to be " + ((int)player.getDistance(i + 0.5F, j + 0.5F, k + 0.5F) - 127) + " blocks closer.")); + else player.addChatMessage(new ChatComponentText("You need to link the ring with a chest first, before using it!")); + } + else if (JewelryNBT.isJewelX(stack, new ItemStack(Items.ender_pearl)) && !JewelryNBT.hasTag(stack, "modifier") && JewelryNBT.playerPosX(stack) == -1 && JewelryNBT.playerPosY(stack) == -1 && JewelryNBT.playerPosZ(stack) == -1){ + JewelryNBT.addCoordonatesAndDimension(stack, player.posX, player.posY, player.posZ, world.provider.dimensionId, world.provider.getDimensionName()); + JewelryNBT.addFakeEnchantment(stack); + } + + if(JewelryNBT.hasTag(stack, "mode")) + { + String mode = ""; + if(JewelryNBT.isModeX(stack, "Disenchant")) mode = "Transfer"; + else if(JewelryNBT.isModeX(stack, "Transfer")) mode = "Enchant"; + else if(JewelryNBT.isModeX(stack, "Enchant")) mode = "Disenchant"; + if(mode != "") + { + player.addChatMessage(new ChatComponentText("Switched to " + mode + " mode")); + JewelryNBT.addMode(stack, mode); + } + if(JewelryNBT.isModeX(stack, "Activated")) mode = "Deactivated"; + else if(JewelryNBT.isModeX(stack, "Deactivated")) mode = "Activated"; + if(mode != "" && mode != "Transfer" && mode != "Enchant" && mode != "Disenchant") + { + player.addChatMessage(new ChatComponentText("The Ring has been " + mode)); + JewelryNBT.addMode(stack, mode); + } + } + } + return stack; + } + + @Override + public boolean itemInteractionForEntity(ItemStack stack, EntityPlayer player, EntityLivingBase entity) + { + if (!player.worldObj.isRemote && entity instanceof EntityLivingBase && JewelryNBT.isJewelX(stack, new ItemStack(Items.nether_star)) && JewelryNBT.isModifierX(stack, new ItemStack(Blocks.chest)) && JewelryNBT.entity(stack, player) == null){ + JewelryNBT.addEntity(stack, entity); + JewelryNBT.addEntityID(stack, entity); + entity.setDead(); + JewelryNBT.addFakeEnchantment(stack); + } + return true; + } + + /** + * allows items to add custom lines of information to the mouseover + * description + */ + public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4) + { + if (stack.hasTagCompound() && stack.getDisplayName() != "Wedding Ring" && Minecraft.getMinecraft().gameSettings.advancedItemTooltips) + { + ItemStack ingot = JewelryNBT.ingot(stack); + if (ingot != null) list.add("Ingot: " + EnumChatFormatting.YELLOW + ingot.getDisplayName()); + + ItemStack jewel = JewelryNBT.jewel(stack); + if (jewel != null) list.add("Jewel: " + EnumChatFormatting.BLUE + jewel.getDisplayName()); + + ItemStack modifier = JewelryNBT.modifier(stack); + if(modifier != null) list.add("Modifier: " + EnumChatFormatting.DARK_PURPLE + modifier.getDisplayName()); + + double playerPosX = JewelryNBT.playerPosX(stack), playerPosY = JewelryNBT.playerPosY(stack), playerPosZ = JewelryNBT.playerPosZ(stack); + if(playerPosX != -1 && playerPosY != -1 && playerPosZ != -1) list.add(EnumChatFormatting.YELLOW + "X: " + EnumChatFormatting.GRAY + (int) playerPosX + EnumChatFormatting.YELLOW + " Y: " + EnumChatFormatting.GRAY + (int) playerPosY + EnumChatFormatting.YELLOW + " Z: " + EnumChatFormatting.GRAY + (int) playerPosZ); + + int posX = JewelryNBT.blockCoordX(stack), posY = JewelryNBT.blockCoordY(stack), posZ = JewelryNBT.blockCoordZ(stack); + if(posX != -1 && posY != -1 && posZ != -1) list.add(EnumChatFormatting.YELLOW + "X: " + EnumChatFormatting.GRAY + (int) posX + EnumChatFormatting.YELLOW + " Y: " + EnumChatFormatting.GRAY + (int) posY + EnumChatFormatting.YELLOW + " Z: " + EnumChatFormatting.GRAY + (int) posZ); + + String name = JewelryNBT.dimName(stack); + if(name != null) list.add("Dimension: " + EnumChatFormatting.DARK_GREEN + name); + + EntityLivingBase entity = JewelryNBT.entity(stack, player); + if (entity != null) list.add("Entity: " + EnumChatFormatting.GOLD + entity.getCommandSenderName()); + + String modeN = JewelryNBT.modeName(stack); + if(modeN != null) list.add("Mode: " + modeN); + + int block = JewelryNBT.blockID(stack); + if(block != -1) list.add("Block: " + StatCollector.translateToLocalFormatted(Block.getBlockById(block).getUnlocalizedName())); + + int blockmeta = JewelryNBT.blockMetadata(stack); + if(blockmeta != -1) list.add("Block Metadata: " + blockmeta); + + TileEntity tile = JewelryNBT.tileEntity(stack); + if(tile != null) list.add(EnumChatFormatting.RED + "Contains a tile entity"); + + int blockX = JewelryNBT.blockCoordX(stack); + if(blockX != -1) list.add("Block Coords X: " + blockX); + + int blockY = JewelryNBT.blockCoordY(stack); + if(blockY != -1) list.add("Block Coords Y: " + blockY); + + int blockZ = JewelryNBT.blockCoordZ(stack); + if(blockZ != -1) list.add("Block Coords Z: " + blockZ); + + // 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); + } + } + + public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int i, int j, int k, int side, float par8, float par9, float par10) + { + amplifier = 0; + if (JewelryNBT.isJewelX(stack, new ItemStack(Items.diamond))) amplifier = 1; + else if (JewelryNBT.isJewelX(stack, new ItemStack(Items.emerald))) amplifier = 2; + else if (JewelryNBT.isJewelX(stack, new ItemStack(Items.nether_star))) amplifier = 7; + + if (!world.isRemote) + { + EntityLivingBase entity = JewelryNBT.entity(stack, player); + boolean used = false; + 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); + } + if (JewelryNBT.isJewelX(stack, new ItemStack(Items.ender_pearl)) && JewelryNBT.isModifierX(stack, new ItemStack(Blocks.chest)) && world.getBlock(i, j, k) == Blocks.chest) JewelryNBT.addBlockCoordonates(stack, i, j, k); + onItemRightClick(stack, world, player); + if(JewelryNBT.isModifierX(stack, new ItemStack(Items.dye, 1, 15))) world.scheduleBlockUpdate(i, j, k, world.getBlock(i, j, k), 7 - amplifier); + if(JewelryNBT.isModifierX(stack, new ItemStack(Items.diamond_pickaxe)) && JewelryNBT.isJewelX(stack, new ItemStack(Items.ender_pearl))) + { + if(JewelryNBT.hasTag(stack, "blockID") && !used) + { + int shiftX = 0, shiftY = 0, shiftZ = 0; + if(side == 0) shiftY = -1; + else if(side == 1) shiftY = 1; + else if(side == 2) shiftZ = -1; + else if(side == 3) shiftZ = 1; + else if(side == 4) shiftX = -1; + else if(side == 5) shiftX = 1; + world.setBlock(i + shiftX, j + shiftY, k + shiftZ, Block.getBlockById(JewelryNBT.blockID(stack))); + world.setBlockMetadataWithNotify(i + shiftX, j + shiftY, k + shiftZ, JewelryNBT.blockMetadata(stack), 2); + if(JewelryNBT.hasTag(stack, "tile")) world.setTileEntity(i + shiftX, j + shiftY, k + shiftZ, JewelryNBT.tileEntity(stack)); + if(JewelryNBT.tileEntity(stack) instanceof TileEntitySkull) ((BlockSkull)Blocks.skull).func_149965_a(world, i + shiftX, j + shiftY, k + shiftZ, (TileEntitySkull)JewelryNBT.tileEntity(stack)); + if(Block.getBlockById(JewelryNBT.blockID(stack)) == Blocks.pumpkin || Block.getBlockById(JewelryNBT.blockID(stack)) == Blocks.lit_pumpkin) createGolems(world, i + shiftX, j + shiftY, k + shiftZ); + JewelryNBT.removeBlock(stack); + used = true; + } + + if(!JewelryNBT.hasTag(stack, "tile") && world.getTileEntity(i, j, k) != null && !used){ + JewelryNBT.addTileEntityBlock(stack, world, i, j, k); + world.removeTileEntity(i, j, k); + world.setBlock(i, j, k, Block.getBlockById(0)); + } + else if(!JewelryNBT.hasTag(stack, "blockID") && !used){ + JewelryNBT.addBlock(stack, Block.getIdFromBlock(world.getBlock(i, j, k)), world.getBlockMetadata(i, j, k)); + JewelryNBT.addBlockCoordonates(stack, i, j, k); + world.setBlock(i, j, k, Block.getBlockById(0)); + } + } + if(JewelryNBT.isModifierX(stack, new ItemStack(Items.diamond_pickaxe)) && JewelryNBT.isJewelX(stack, new ItemStack(Items.nether_star)) && JewelryNBT.isIngotX(stack, new ItemStack(ItemList.shadowIngot)) && j > 0 && world.getBlock(i, j, k) != Blocks.bedrock) + world.func_147480_a(i, j, k, true); + } + return true; + } + + public boolean canDisenchant(EntityPlayer player) + { + if(player.capabilities.isCreativeMode) return true; + else if(player.experienceLevel >= 2) return true; + return false; + } + + public void dynamicLight(World world, EntityPlayer player) + { + world.setBlock((int)player.prevPosX, (int)player.prevPosY, (int)player.prevPosZ, Block.getBlockById(0)); + world.setBlock((int)player.posX, (int)player.posY, (int)player.posZ, BlockList.glow); + } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + @Override + public void onUpdate(ItemStack stack, World world, Entity entity, int par4, boolean par5) + { + amplifier = 0; + if(cooldown > 0) cooldown--; + if (!world.isRemote){ + EntityPlayer entityplayer = (EntityPlayer) entity; + int posX = (int)Math.floor(entityplayer.posX), posY = (int)Math.floor(entityplayer.posY), posZ = (int)Math.floor(entityplayer.posZ); + + if (JewelryNBT.isJewelX(stack, new ItemStack(Items.diamond))) amplifier = 1; + else if (JewelryNBT.isJewelX(stack, new ItemStack(Items.emerald))) amplifier = 2; + else if (JewelryNBT.isJewelX(stack, new ItemStack(Items.nether_star))) amplifier = 7; + + if(JewelryNBT.isModifierX(stack, new ItemStack(Items.dye, 1, 15)) && world.getBlock(posX, posY - 1, posZ) == Blocks.farmland) + world.setBlockMetadataWithNotify(posX, posY - 1, posZ, 1, 7); + + if(JewelryNBT.isModeX(stack, "Activated")) + { + if (JewelryNBT.isModifierX(stack, new ItemStack(Items.blaze_powder)) && entityplayer != null) + entityplayer.addPotionEffect(new PotionEffect(Potion.fireResistance.id, 4, amplifier, true)); + else if (JewelryNBT.isModifierX(stack, new ItemStack(Items.sugar)) && entityplayer != null) + { + entityplayer.addPotionEffect(new PotionEffect(Potion.moveSpeed.id, 4, amplifier, true)); + entityplayer.addExhaustion(0.05f*amplifier); + } + else if (JewelryNBT.isModifierX(stack, new ItemStack(Items.iron_pickaxe)) && entityplayer != null && !JewelryNBT.isJewelX(stack, new ItemStack(Items.ender_pearl))) + entityplayer.addPotionEffect(new PotionEffect(Potion.digSpeed.id, 4, amplifier, true)); + else if (JewelryNBT.isModifierX(stack, new ItemStack(Items.feather)) && entityplayer != null) + { + entityplayer.addPotionEffect(new PotionEffect(Potion.jump.id, 4, amplifier, true)); + if(entityplayer.inventory.armorInventory[0] != null) + { + int damage = entityplayer.inventory.armorInventory[0].getMaxDamage() - entityplayer.inventory.armorInventory[0].getItemDamage(); + if(damage - entityplayer.fallDistance > 0){ + entityplayer.inventory.armorInventory[0].damageItem((int)entityplayer.fallDistance, entityplayer); + entityplayer.fallDistance = 0; + } + else + { + --entityplayer.inventory.armorInventory[0].stackSize; + entityplayer.fallDistance -= damage; + } + } + } + else if (JewelryNBT.isModifierX(stack, new ItemStack(Items.potionitem, 1, 8270)) && entityplayer != null) entityplayer.addPotionEffect(new PotionEffect(Potion.invisibility.id, 4, amplifier, true)); + } + if(entityplayer.inventory.getCurrentItem() != null && JewelryNBT.isJewelX(stack, new ItemStack(Items.nether_star)) && JewelryNBT.isModifierX(stack, new ItemStack(Items.book)) && entityplayer.inventory.getCurrentItem().getItem() == stack.getItem()) + { + ItemStack item = null; + if(entityplayer.inventory.currentItem + 1 <= 8 && entityplayer.inventory.getStackInSlot(entityplayer.inventory.currentItem + 1) != null && entityplayer.inventory.getStackInSlot(entityplayer.inventory.currentItem + 1).isItemEnchanted()) item = entityplayer.inventory.getStackInSlot(entityplayer.inventory.currentItem + 1); + if(entityplayer.inventory.currentItem - 1 >= 0 && entityplayer.inventory.getStackInSlot(entityplayer.inventory.currentItem - 1) != null && entityplayer.inventory.getStackInSlot(entityplayer.inventory.currentItem - 1).isItemEnchanted()) item = entityplayer.inventory.getStackInSlot(entityplayer.inventory.currentItem - 1); + if(item != null && JewelryNBT.isModeX(stack, "Disenchant")) + { + ItemStack enchBook = new ItemStack(Items.enchanted_book); + Map enchItem = EnchantmentHelper.getEnchantments(item); + Map book = EnchantmentHelper.getEnchantments(enchBook); + Iterator iterator = enchItem.keySet().iterator(); + int e; + + if (iterator.hasNext() && canDisenchant(entityplayer)) + { + e = ((Integer)iterator.next()).intValue(); + book.put(Integer.valueOf(e), Integer.valueOf(((Integer)enchItem.get(Integer.valueOf(e))).intValue())); + EnchantmentHelper.setEnchantments(book, enchBook); + if(entityplayer.inventory.addItemStackToInventory(enchBook)) + { + if(!entityplayer.capabilities.isCreativeMode) + { + entityplayer.addExperienceLevel(-2); + entityplayer.heal(-1f); + } + enchItem.remove(Integer.valueOf(e)); + if(item.isItemStackDamageable() && (item.getMaxDamage() - item.getItemDamage())/3 > 0) item.damageItem((item.getMaxDamage() - item.getItemDamage())/3, entityplayer); + EnchantmentHelper.setEnchantments(enchItem, item); + } + } + } + if(entityplayer.inventory.currentItem + 1 <= 8 && entityplayer.inventory.getStackInSlot(entityplayer.inventory.currentItem + 1) != null && entityplayer.inventory.currentItem - 1 >= 0 && entityplayer.inventory.getStackInSlot(entityplayer.inventory.currentItem - 1) != null && JewelryNBT.isModeX(stack, "Transfer")) + { + if(cooldown > 0) entityplayer.addChatMessage(new ChatComponentText("Ring is currently cooling down!")); + ItemStack enchantedItem = null, enchantableItem = null; + if(entityplayer.inventory.getStackInSlot(entityplayer.inventory.currentItem - 1).isItemEnchanted() && entityplayer.inventory.getStackInSlot(entityplayer.inventory.currentItem + 1) != null) + { + enchantedItem = entityplayer.inventory.getStackInSlot(entityplayer.inventory.currentItem - 1); + enchantableItem = entityplayer.inventory.getStackInSlot(entityplayer.inventory.currentItem + 1); + + } + if(enchantedItem != null && enchantableItem != null) + { + Map enchItem = EnchantmentHelper.getEnchantments(enchantedItem); + Map resultItem = EnchantmentHelper.getEnchantments(enchantableItem); + Iterator iterator = enchItem.keySet().iterator(); + int e; + + if (iterator.hasNext() && cooldown == 0) + { + e = ((Integer)iterator.next()).intValue(); + if(!EnchantmentHelper.getEnchantments(enchantableItem).containsKey(Integer.valueOf(e))) + { + resultItem.put(Integer.valueOf(e), Integer.valueOf(((Integer)enchItem.get(Integer.valueOf(e))).intValue())); + EnchantmentHelper.setEnchantments(resultItem, enchantableItem); + enchItem.remove(Integer.valueOf(e)); + EnchantmentHelper.setEnchantments(enchItem, enchantedItem); + cooldown = 50000; + } + } + } + } + if(entityplayer.inventory.currentItem + 1 <= 8 && entityplayer.inventory.getStackInSlot(entityplayer.inventory.currentItem + 1) != null) item = entityplayer.inventory.getStackInSlot(entityplayer.inventory.currentItem + 1); + else if(entityplayer.inventory.currentItem - 1 >= 0 && entityplayer.inventory.getStackInSlot(entityplayer.inventory.currentItem - 1) != null) item = entityplayer.inventory.getStackInSlot(entityplayer.inventory.currentItem - 1); + if(item != null && !item.isItemEnchanted() && item.isItemEnchantable() && entityplayer.experienceLevel > 0 && JewelryNBT.isModeX(stack, "Enchant")) + { + Map enchItem = EnchantmentHelper.getEnchantments(item); + int level = entityplayer.experienceLevel; + if(entityplayer.experienceLevel > 6) level = 6; + if(!entityplayer.capabilities.isCreativeMode) entityplayer.addExperienceLevel(-level); + enchItem.put(Enchantment.enchantmentsBookList[new Random().nextInt(Enchantment.enchantmentsBookList.length)].effectId, level); + EnchantmentHelper.setEnchantments(enchItem, 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.isJewelX(itemstack, new ItemStack(Items.ender_pearl)) && JewelryNBT.isModifierX(itemstack, new ItemStack(Items.iron_pickaxe)))) JewelryNBT.addMode(itemstack, "Activated"); + if(JewelryNBT.isJewelX(itemstack, new ItemStack(Items.nether_star)) && JewelryNBT.isModifierX(itemstack, new ItemStack(Items.book))) + JewelryNBT.addMode(itemstack, "Disenchant"); + return itemstack; + } + + public void createGolems(World world, int i, int j, int k) + { + if (world.getBlock(i, j - 1, k) == Blocks.snow && world.getBlock(i, j - 2, k) == Blocks.snow) + { + if (!world.isRemote) + { + world.setBlock(i, j, k, Block.getBlockById(0), 0, 2); + world.setBlock(i, j - 1, k, Block.getBlockById(0), 0, 2); + world.setBlock(i, j - 2, k, Block.getBlockById(0), 0, 2); + EntitySnowman entitysnowman = new EntitySnowman(world); + entitysnowman.setLocationAndAngles((double)i + 0.5D, (double)j - 1.95D, (double)k + 0.5D, 0.0F, 0.0F); + world.spawnEntityInWorld(entitysnowman); + world.notifyBlockChange(i, j, k, Block.getBlockById(0)); + world.notifyBlockChange(i, j - 1, k, Block.getBlockById(0)); + world.notifyBlockChange(i, j - 2, k, Block.getBlockById(0)); + } + + for (int l = 0; l < 120; ++l) + { + world.spawnParticle("snowshovel", (double)i + world.rand.nextDouble(), (double)(j - 2) + world.rand.nextDouble() * 2.5D, (double)k + world.rand.nextDouble(), 0.0D, 0.0D, 0.0D); + } + } + else if (world.getBlock(i, j - 1, k) == Blocks.iron_block && world.getBlock(i, j - 2, k) == Blocks.iron_block) + { + boolean flag = world.getBlock(i - 1, j - 1, k) == Blocks.iron_block && world.getBlock(i + 1, j - 1, k) == Blocks.iron_block; + boolean flag1 = world.getBlock(i, j - 1, k - 1) == Blocks.iron_block && world.getBlock(i, j - 1, k + 1) == Blocks.iron_block; + + if (flag || flag1) + { + world.setBlock(i, j, k, Block.getBlockById(0), 0, 2); + world.setBlock(i, j - 1, k, Block.getBlockById(0), 0, 2); + world.setBlock(i, j - 2, k, Block.getBlockById(0), 0, 2); + + if (flag) + { + world.setBlock(i - 1, j - 1, k, Block.getBlockById(0), 0, 2); + world.setBlock(i + 1, j - 1, k, Block.getBlockById(0), 0, 2); + } + else + { + world.setBlock(i, j - 1, k - 1, Block.getBlockById(0), 0, 2); + world.setBlock(i, j - 1, k + 1, Block.getBlockById(0), 0, 2); + } + + EntityIronGolem entityirongolem = new EntityIronGolem(world); + entityirongolem.setPlayerCreated(true); + entityirongolem.setLocationAndAngles((double)i + 0.5D, (double)j - 1.95D, (double)k + 0.5D, 0.0F, 0.0F); + world.spawnEntityInWorld(entityirongolem); + + for (int i1 = 0; i1 < 120; ++i1) + { + world.spawnParticle("snowballpoof", (double)i + world.rand.nextDouble(), (double)(j - 2) + world.rand.nextDouble() * 3.9D, (double)k + world.rand.nextDouble(), 0.0D, 0.0D, 0.0D); + } + + world.notifyBlockChange(i, j, k, Block.getBlockById(0)); + world.notifyBlockChange(i, j - 1, k, Block.getBlockById(0)); + world.notifyBlockChange(i, j - 2, k, Block.getBlockById(0)); + + if (flag) + { + world.notifyBlockChange(i - 1, j - 1, k, Block.getBlockById(0)); + world.notifyBlockChange(i + 1, j - 1, k, Block.getBlockById(0)); + } + else + { + world.notifyBlockChange(i, j - 1, k - 1, Block.getBlockById(0)); + world.notifyBlockChange(i, j - 1, k + 1, Block.getBlockById(0)); + } + } + } + } +} diff --git a/src/main/java/darkknight/jewelrycraft/item/ItemThiefGloves.java b/src/main/java/darkknight/jewelrycraft/item/ItemThiefGloves.java new file mode 100644 index 0000000..f61085a --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/item/ItemThiefGloves.java @@ -0,0 +1,113 @@ +package darkknight.jewelrycraft.item; + +import java.util.Iterator; +import java.util.List; +import java.util.Random; + +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.passive.EntityVillager; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.village.MerchantRecipe; +import net.minecraft.village.MerchantRecipeList; + +import org.lwjgl.input.Keyboard; + +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.relauncher.ReflectionHelper; +import cpw.mods.fml.relauncher.Side; + +public class ItemThiefGloves extends Item +{ + public Random rand; + + public ItemThiefGloves() + { + super(); + this.setCreativeTab(CreativeTabs.tabTools); + this.setMaxStackSize(1); + this.setMaxDamage(10); + } + + @Override + public boolean itemInteractionForEntity(ItemStack stack, EntityPlayer par2EntityPlayer, EntityLivingBase par3EntityLivingBase) + { + if (par3EntityLivingBase instanceof EntityVillager) + { + EntityVillager villager = (EntityVillager) par3EntityLivingBase; + int wealth = (Integer) ReflectionHelper.getPrivateValue(EntityVillager.class, villager, "wealth", "field_70956_bz"); + MerchantRecipeList buyingList = (MerchantRecipeList) ReflectionHelper.getPrivateValue(EntityVillager.class, villager, "buyingList", "field_70963_i"); + if (buyingList != null) + { + Iterator<?> iterator = buyingList.iterator(); + while (iterator.hasNext()) + { + MerchantRecipe recipe = (MerchantRecipe) iterator.next(); + int toolUses = (Integer) ReflectionHelper.getPrivateValue(MerchantRecipe.class, recipe, "toolUses", "field_77400_d"); + int quantity; + if (recipe.getItemToSell().isStackable()) + quantity = recipe.getItemToSell().stackSize * (7 - toolUses); + else + quantity = 1; + ItemStack s = new ItemStack(recipe.getItemToSell().getItem(), quantity, recipe.getItemToSell().getItemDamage()); + s.setTagCompound(recipe.getItemToSell().getTagCompound()); + if (par2EntityPlayer.inventory.addItemStackToInventory(s)) + ; + else + villager.entityDropItem(s, 0); + par2EntityPlayer.addChatMessage(new ChatComponentText("Villager #" + villager.getProfession() + ": Hmmm... I seem to have lost my " + s.getDisplayName() + "!")); + stack.damageItem(1, par2EntityPlayer); + } + buyingList.clear(); + ReflectionHelper.setPrivateValue(EntityVillager.class, villager, 300, "timeUntilReset", "field_70961_j"); + ReflectionHelper.setPrivateValue(EntityVillager.class, villager, true, "needsInitilization", "field_70959_by"); + } + + villager.dropItem(Items.emerald, wealth); + ReflectionHelper.setPrivateValue(EntityVillager.class, villager, 0, "wealth", "field_70956_bz"); + return true; + } + else + { + return super.itemInteractionForEntity(stack, par2EntityPlayer, par3EntityLivingBase); + } + } + + @Override + @SuppressWarnings("unchecked") + public void addInformation(ItemStack stack, EntityPlayer player, @SuppressWarnings("rawtypes") List list, boolean par4) + { + if (!shouldAddAdditionalInfo()) + list.add(EnumChatFormatting.GRAY + additionalInfoInstructions()); + else + { + list.add(EnumChatFormatting.GRAY + "Right click with the gloves,"); + list.add(EnumChatFormatting.GRAY + "while sneaking, on a villager"); + list.add(EnumChatFormatting.GRAY + "to steal his stuff."); + } + } + + public static boolean shouldAddAdditionalInfo() + { + if (FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT) + { + if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) + { + return true; + } + } + return false; + } + + public static String additionalInfoInstructions() + { + String message = "\247oPress \247b<SHIFT>\2477\247o for more information."; + return message; + } + +} diff --git a/src/main/java/darkknight/jewelrycraft/lib/Reference.java b/src/main/java/darkknight/jewelrycraft/lib/Reference.java new file mode 100644 index 0000000..a01a77a --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/lib/Reference.java @@ -0,0 +1,9 @@ +package darkknight.jewelrycraft.lib; + +public class Reference +{ + public static final String MODID = "Jewelrycraft"; + public static final String MODNAME = "Jewelrycraft"; + public static final String VERSION = "1.3.2"; + public static final String PACKET_CHANNEL = "Jewelrycraft"; +} diff --git a/src/main/java/darkknight/jewelrycraft/model/ModelDisplayer.java b/src/main/java/darkknight/jewelrycraft/model/ModelDisplayer.java new file mode 100644 index 0000000..9764ca0 --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/model/ModelDisplayer.java @@ -0,0 +1,241 @@ +package darkknight.jewelrycraft.model; + +import org.lwjgl.opengl.GL11; + +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelRenderer; +import net.minecraft.entity.Entity; + +public class ModelDisplayer extends ModelBase +{ + //fields + ModelRenderer Base; + ModelRenderer Ring11; + ModelRenderer Ring12; + ModelRenderer Ring13; + ModelRenderer Ring14; + ModelRenderer Ring31; + ModelRenderer Ring21; + ModelRenderer Ring32; + ModelRenderer Ring22; + ModelRenderer Ring33; + ModelRenderer Ring23; + ModelRenderer Ring34; + ModelRenderer Ring24; + ModelRenderer Ring25; + ModelRenderer Ring26; + ModelRenderer Ring27; + ModelRenderer Ring28; + ModelRenderer Ring35; + ModelRenderer Ring36; + ModelRenderer Ring37; + ModelRenderer Ring38; + ModelRenderer Ring39; + ModelRenderer Ring310; + ModelRenderer Ring311; + ModelRenderer Ring312; + + public ModelDisplayer() + { + textureWidth = 64; + textureHeight = 32; + + Base = new ModelRenderer(this, 0, 0); + Base.addBox(0F, 0F, 0F, 16, 3, 16); + Base.setRotationPoint(-8F, 21F, -8F); + Base.setTextureSize(64, 32); + Base.mirror = true; + setRotation(Base, 0F, 0F, 0F); + Ring11 = new ModelRenderer(this, 0, 26); + Ring11.addBox(-2F, 0F, 2F, 4, 1, 1); + Ring11.setRotationPoint(0F, 19F, 0F); + Ring11.setTextureSize(64, 32); + Ring11.mirror = true; + setRotation(Ring11, 0F, 0F, 0F); + Ring12 = new ModelRenderer(this, 0, 20); + Ring12.addBox(-3F, 0F, -2F, 1, 1, 4); + Ring12.setRotationPoint(0F, 19F, 0F); + Ring12.setTextureSize(64, 32); + Ring12.mirror = true; + setRotation(Ring12, 0F, 0F, 0F); + Ring13 = new ModelRenderer(this, 0, 20); + Ring13.addBox(2F, 0F, -2F, 1, 1, 4); + Ring13.setRotationPoint(0F, 19F, 0F); + Ring13.setTextureSize(64, 32); + Ring13.mirror = true; + setRotation(Ring13, 0F, 0F, 0F); + Ring14 = new ModelRenderer(this, 0, 26); + Ring14.addBox(-2F, 0F, -3F, 4, 1, 1); + Ring14.setRotationPoint(0F, 19F, 0F); + Ring14.setTextureSize(64, 32); + Ring14.mirror = true; + setRotation(Ring14, 0F, 0F, 0F); + Ring21 = new ModelRenderer(this, 0, 29); + Ring21.addBox(-4F, 0F, 3F, 1, 1, 1); + Ring21.setRotationPoint(0F, 19F, 0F); + Ring21.setTextureSize(64, 32); + Ring21.mirror = true; + setRotation(Ring21, 0F, 0F, 0F); + Ring22 = new ModelRenderer(this, 0, 29); + Ring22.addBox(-4F, 0F, -4F, 1, 1, 1); + Ring22.setRotationPoint(0F, 19F, 0F); + Ring22.setTextureSize(64, 32); + Ring22.mirror = true; + setRotation(Ring22, 0F, 0F, 0F); + Ring23 = new ModelRenderer(this, 0, 29); + Ring23.addBox(3F, 0F, -4F, 1, 1, 1); + Ring23.setRotationPoint(0F, 19F, 0F); + Ring23.setTextureSize(64, 32); + Ring23.mirror = true; + setRotation(Ring23, 0F, 0F, 0F); + Ring34 = new ModelRenderer(this, 26, 20); + Ring34.addBox(6F, 0F, -4F, 1, 1, 8); + Ring34.setRotationPoint(0F, 19F, 0F); + Ring34.setTextureSize(64, 32); + Ring34.mirror = true; + setRotation(Ring34, 0F, 0F, 0F); + Ring24 = new ModelRenderer(this, 0, 29); + Ring24.addBox(3F, 0F, 3F, 1, 1, 1); + Ring24.setRotationPoint(0F, 19F, 0F); + Ring24.setTextureSize(64, 32); + Ring24.mirror = true; + setRotation(Ring24, 0F, 0F, 0F); + Ring25 = new ModelRenderer(this, 11, 20); + Ring25.addBox(4F, 0F, -3F, 1, 1, 6); + Ring25.setRotationPoint(0F, 19F, 0F); + Ring25.setTextureSize(64, 32); + Ring25.mirror = true; + setRotation(Ring25, 0F, 0F, 0F); + Ring26 = new ModelRenderer(this, 11, 28); + Ring26.addBox(-3F, 0F, -5F, 6, 1, 1); + Ring26.setRotationPoint(0F, 19F, 0F); + Ring26.setTextureSize(64, 32); + Ring26.mirror = true; + setRotation(Ring26, 0F, 0F, 0F); + Ring27 = new ModelRenderer(this, 11, 20); + Ring27.addBox(-5F, 0F, -3F, 1, 1, 6); + Ring27.setRotationPoint(0F, 19F, 0F); + Ring27.setTextureSize(64, 32); + Ring27.mirror = true; + setRotation(Ring27, 0F, 0F, 0F); + Ring28 = new ModelRenderer(this, 11, 28); + Ring28.addBox(-3F, 0F, 4F, 6, 1, 1); + Ring28.setRotationPoint(0F, 19F, 0F); + Ring28.setTextureSize(64, 32); + Ring28.mirror = true; + setRotation(Ring28, 0F, 0F, 0F); + Ring31 = new ModelRenderer(this, 0, 29); + Ring31.addBox(-6F, 0F, 4F, 1, 1, 1); + Ring31.setRotationPoint(0F, 19F, 0F); + Ring31.setTextureSize(64, 32); + Ring31.mirror = true; + setRotation(Ring31, 0F, 0F, 0F); + Ring32 = new ModelRenderer(this, 26, 20); + Ring32.addBox(-7F, 0F, -4F, 1, 1, 8); + Ring32.setRotationPoint(0F, 19F, 0F); + Ring32.setTextureSize(64, 32); + Ring32.mirror = true; + setRotation(Ring32, 0F, 0F, 0F); + Ring33 = new ModelRenderer(this, 26, 30); + Ring33.addBox(-4F, 0F, -7F, 8, 1, 1); + Ring33.setRotationPoint(0F, 19F, 0F); + Ring33.setTextureSize(64, 32); + Ring33.mirror = true; + setRotation(Ring33, 0F, 0F, 0F); + Ring35 = new ModelRenderer(this, 26, 30); + Ring35.addBox(-4F, 0F, 6F, 8, 1, 1); + Ring35.setRotationPoint(0F, 19F, 0F); + Ring35.setTextureSize(64, 32); + Ring35.mirror = true; + setRotation(Ring35, 0F, 0F, 0F); + Ring36 = new ModelRenderer(this, 0, 29); + Ring36.addBox(-5F, 0F, 5F, 1, 1, 1); + Ring36.setRotationPoint(0F, 19F, 0F); + Ring36.setTextureSize(64, 32); + Ring36.mirror = true; + setRotation(Ring36, 0F, 0F, 0F); + Ring37 = new ModelRenderer(this, 0, 29); + Ring37.addBox(5F, 0F, 4F, 1, 1, 1); + Ring37.setRotationPoint(0F, 19F, 0F); + Ring37.setTextureSize(64, 32); + Ring37.mirror = true; + setRotation(Ring37, 0F, 0F, 0F); + Ring38 = new ModelRenderer(this, 0, 29); + Ring38.addBox(4F, 0F, 5F, 1, 1, 1); + Ring38.setRotationPoint(0F, 19F, 0F); + Ring38.setTextureSize(64, 32); + Ring38.mirror = true; + setRotation(Ring38, 0F, 0F, 0F); + Ring39 = new ModelRenderer(this, 0, 29); + Ring39.addBox(4F, 0F, -6F, 1, 1, 1); + Ring39.setRotationPoint(0F, 19F, 0F); + Ring39.setTextureSize(64, 32); + Ring39.mirror = true; + setRotation(Ring39, 0F, 0F, 0F); + Ring310 = new ModelRenderer(this, 0, 29); + Ring310.addBox(5F, 0F, -5F, 1, 1, 1); + Ring310.setRotationPoint(0F, 19F, 0F); + Ring310.setTextureSize(64, 32); + Ring310.mirror = true; + setRotation(Ring310, 0F, 0F, 0F); + Ring311 = new ModelRenderer(this, 0, 29); + Ring311.addBox(-6F, 0F, -5F, 1, 1, 1); + Ring311.setRotationPoint(0F, 19F, 0F); + Ring311.setTextureSize(64, 32); + Ring311.mirror = true; + setRotation(Ring311, 0F, 0F, 0F); + Ring312 = new ModelRenderer(this, 0, 29); + Ring312.addBox(-5F, 0F, -6F, 1, 1, 1); + Ring312.setRotationPoint(0F, 19F, 0F); + Ring312.setTextureSize(64, 32); + Ring312.mirror = true; + setRotation(Ring312, 0F, 0F, 0F); + } + + public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) + { + GL11.glPushMatrix(); + Base.render(f5); + GL11.glTranslatef(0.0F, 0F - f, 0.0F); + Ring11.render(f5); + Ring12.render(f5); + Ring13.render(f5); + Ring14.render(f5); + GL11.glTranslatef(0.0F, 0F + f - f1, 0.0F); + Ring21.render(f5); + Ring22.render(f5); + Ring23.render(f5); + Ring24.render(f5); + Ring25.render(f5); + Ring26.render(f5); + Ring27.render(f5); + Ring28.render(f5); + GL11.glTranslatef(0.0F, 0F + f1 - f2, 0.0F); + Ring31.render(f5); + Ring32.render(f5); + Ring33.render(f5); + Ring34.render(f5); + Ring35.render(f5); + Ring36.render(f5); + Ring37.render(f5); + Ring38.render(f5); + Ring39.render(f5); + Ring310.render(f5); + Ring311.render(f5); + Ring312.render(f5); + GL11.glPopMatrix(); + } + + private void setRotation(ModelRenderer model, float x, float y, float z) + { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } + + public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5) + { + super.setRotationAngles(f, f1, f2, f3, f4, f5, null); + } + +} diff --git a/src/main/java/darkknight/jewelrycraft/model/ModelJewlersCraftingBench.java b/src/main/java/darkknight/jewelrycraft/model/ModelJewlersCraftingBench.java new file mode 100644 index 0000000..1cc3f72 --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/model/ModelJewlersCraftingBench.java @@ -0,0 +1,140 @@ +package darkknight.jewelrycraft.model; + +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelRenderer; +import net.minecraft.entity.Entity; + +public class ModelJewlersCraftingBench extends ModelBase +{ + //fields + ModelRenderer Leg1; + ModelRenderer Leg2; + ModelRenderer Leg3; + ModelRenderer Leg4; + ModelRenderer Top; + ModelRenderer Support1; + ModelRenderer Support2; + ModelRenderer Support3; + ModelRenderer Support4; + ModelRenderer Support5; + ModelRenderer Support6; + ModelRenderer Support7; + ModelRenderer Support8; + + public ModelJewlersCraftingBench() + { + textureWidth = 64; + textureHeight = 32; + + Leg1 = new ModelRenderer(this, 0, 0); + Leg1.addBox(0F, 0F, 0F, 2, 10, 2); + Leg1.setRotationPoint(-6F, 14F, 4F); + Leg1.setTextureSize(64, 32); + Leg1.mirror = true; + setRotation(Leg1, 0F, 0F, 0F); + Leg2 = new ModelRenderer(this, 0, 0); + Leg2.addBox(0F, 0F, 0F, 2, 10, 2); + Leg2.setRotationPoint(-6F, 14F, -6F); + Leg2.setTextureSize(64, 32); + Leg2.mirror = true; + setRotation(Leg2, 0F, 0F, 0F); + Leg3 = new ModelRenderer(this, 0, 0); + Leg3.addBox(0F, 0F, 0F, 2, 10, 2); + Leg3.setRotationPoint(4F, 14F, -6F); + Leg3.setTextureSize(64, 32); + Leg3.mirror = true; + setRotation(Leg3, 0F, 0F, 0F); + Leg4 = new ModelRenderer(this, 0, 0); + Leg4.addBox(0F, 0F, 0F, 2, 10, 2); + Leg4.setRotationPoint(4F, 14F, 4F); + Leg4.setTextureSize(64, 32); + Leg4.mirror = true; + setRotation(Leg4, 0F, 0F, 0F); + Top = new ModelRenderer(this, 0, 13); + Top.addBox(0F, 0F, 0F, 16, 1, 16); + Top.setRotationPoint(-8F, 13F, -8F); + Top.setTextureSize(64, 32); + Top.mirror = true; + setRotation(Top, 0F, 0F, 0F); + Support1 = new ModelRenderer(this, 0, 0); + Support1.addBox(0F, 0F, 0F, 3, 1, 1); + Support1.setRotationPoint(3F, 12F, 5F); + Support1.setTextureSize(64, 32); + Support1.mirror = true; + setRotation(Support1, 0F, 0F, 0F); + Support2 = new ModelRenderer(this, 0, 0); + Support2.addBox(0F, 0F, 0F, 1, 1, 3); + Support2.setRotationPoint(2F, 12F, 2F); + Support2.setTextureSize(64, 32); + Support2.mirror = true; + setRotation(Support2, 0F, 0F, 0F); + Support3 = new ModelRenderer(this, 0, 0); + Support3.addBox(0F, 0F, 0F, 1, 1, 3); + Support3.setRotationPoint(6F, 12F, 2F); + Support3.setTextureSize(64, 32); + Support3.mirror = true; + setRotation(Support3, 0F, 0F, 0F); + Support4 = new ModelRenderer(this, 0, 0); + Support4.addBox(0F, 0F, 0F, 3, 1, 1); + Support4.setRotationPoint(3F, 12F, 1F); + Support4.setTextureSize(64, 32); + Support4.mirror = true; + setRotation(Support4, 0F, 0F, 0F); + Support5 = new ModelRenderer(this, 0, 0); + Support5.addBox(0F, 0F, 0F, 1, 1, 3); + Support5.setRotationPoint(-3F, 12F, 2F); + Support5.setTextureSize(64, 32); + Support5.mirror = true; + setRotation(Support5, 0F, 0F, 0F); + Support6 = new ModelRenderer(this, 0, 0); + Support6.addBox(0F, 0F, 0F, 3, 1, 1); + Support6.setRotationPoint(-6F, 12F, 5F); + Support6.setTextureSize(64, 32); + Support6.mirror = true; + setRotation(Support6, 0F, 0F, 0F); + Support7 = new ModelRenderer(this, 0, 0); + Support7.addBox(0F, 0F, 0F, 1, 1, 3); + Support7.setRotationPoint(-7F, 12F, 2F); + Support7.setTextureSize(64, 32); + Support7.mirror = true; + setRotation(Support7, 0F, 0F, 0F); + Support8 = new ModelRenderer(this, 0, 0); + Support8.addBox(0F, 0F, 0F, 3, 1, 1); + Support8.setRotationPoint(-6F, 12F, 1F); + Support8.setTextureSize(64, 32); + Support8.mirror = true; + setRotation(Support8, 0F, 0F, 0F); + } + + public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) + { + super.render(entity, f, f1, f2, f3, f4, f5); + setRotationAngles(f, f1, f2, f3, f4, f5); + Leg1.render(f5); + Leg2.render(f5); + Leg3.render(f5); + Leg4.render(f5); + Top.render(f5); + Support1.render(f5); + Support2.render(f5); + Support3.render(f5); + Support4.render(f5); + Support5.render(f5); + Support6.render(f5); + Support7.render(f5); + Support8.render(f5); + } + + private void setRotation(ModelRenderer model, float x, float y, float z) + { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } + + public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5) + { + super.setRotationAngles(f, f1, f2, f3, f4, f5, null); + } + +} diff --git a/src/main/java/darkknight/jewelrycraft/model/ModelMolder.java b/src/main/java/darkknight/jewelrycraft/model/ModelMolder.java new file mode 100644 index 0000000..374b218 --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/model/ModelMolder.java @@ -0,0 +1,76 @@ +package darkknight.jewelrycraft.model; + +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelRenderer; +import net.minecraft.entity.Entity; + +public class ModelMolder extends ModelBase +{ + //fields + ModelRenderer Base; + ModelRenderer Side; + ModelRenderer Side1; + ModelRenderer Side2; + ModelRenderer Side3; + + public ModelMolder() + { + textureWidth = 64; + textureHeight = 32; + + Base = new ModelRenderer(this, 0, 0); + Base.addBox(0F, 0F, 0F, 10, 1, 10); + Base.setRotationPoint(-5F, 23F, -5F); + Base.setTextureSize(64, 32); + Base.mirror = true; + setRotation(Base, 0F, 0F, 0F); + Side = new ModelRenderer(this, 0, 13); + Side.addBox(0F, 0F, 0F, 10, 2, 1); + Side.setRotationPoint(-5F, 21F, 5F); + Side.setTextureSize(64, 32); + Side.mirror = true; + setRotation(Side, 0F, 0F, 0F); + Side1 = new ModelRenderer(this, 0, 13); + Side1.addBox(0F, 0F, 0F, 10, 2, 1); + Side1.setRotationPoint(-5F, 21F, -6F); + Side1.setTextureSize(64, 32); + Side1.mirror = true; + setRotation(Side1, 0F, 0F, 0F); + Side2 = new ModelRenderer(this, 41, 0); + Side2.addBox(0F, 0F, 0F, 1, 2, 10); + Side2.setRotationPoint(-6F, 21F, -5F); + Side2.setTextureSize(64, 32); + Side2.mirror = true; + setRotation(Side2, 0F, 0F, 0F); + Side3 = new ModelRenderer(this, 41, 0); + Side3.addBox(0F, 0F, 0F, 1, 2, 10); + Side3.setRotationPoint(5F, 21F, -5F); + Side3.setTextureSize(64, 32); + Side3.mirror = true; + setRotation(Side3, 0F, 0F, 0F); + } + + public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) + { + super.render(entity, f, f1, f2, f3, f4, f5); + setRotationAngles(f, f1, f2, f3, f4, f5); + Base.render(f5); + Side.render(f5); + Side1.render(f5); + Side2.render(f5); + Side3.render(f5); + } + + private void setRotation(ModelRenderer model, float x, float y, float z) + { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } + + public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5) + { + super.setRotationAngles(f, f1, f2, f3, f4, f5, null); + } + +} diff --git a/src/main/java/darkknight/jewelrycraft/model/ModelSmelter.java b/src/main/java/darkknight/jewelrycraft/model/ModelSmelter.java new file mode 100644 index 0000000..afb3b09 --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/model/ModelSmelter.java @@ -0,0 +1,276 @@ +package darkknight.jewelrycraft.model; + +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelRenderer; +import net.minecraft.entity.Entity; + +public class ModelSmelter extends ModelBase +{ + //fields + ModelRenderer Support1; + ModelRenderer Support2; + ModelRenderer Hold1; + ModelRenderer Hold2; + ModelRenderer SmelterBase; + ModelRenderer SmelterSide1; + ModelRenderer SmelterSide2; + ModelRenderer SmelterSide3; + ModelRenderer SmelterSide4; + ModelRenderer SmelterSide5; + ModelRenderer SmelterSide6; + ModelRenderer SmelterSide7; + ModelRenderer SmelterSide8; + ModelRenderer SmelterSide9; + ModelRenderer SmelterSide10; + ModelRenderer SmelterSide11; + ModelRenderer SmelterSide12; + ModelRenderer HeatSourceSide1; + ModelRenderer HeatSourceSide2; + ModelRenderer HeatSourceSide3; + ModelRenderer HeatSourceSide4; + ModelRenderer HeatSourceSide5; + ModelRenderer HeatSourceBase; + ModelRenderer HeatSourceSide6; + ModelRenderer HeatSourceSide7; + ModelRenderer HeatSourceSide8; + ModelRenderer HeatSourceSide9; + ModelRenderer HeatSourceSide10; + ModelRenderer HeatSourceSide11; + ModelRenderer HeatSourceSide12; + + public ModelSmelter() + { + textureWidth = 64; + textureHeight = 32; + + Support1 = new ModelRenderer(this, 0, 0); + Support1.addBox(0F, 0F, 0F, 2, 15, 3); + Support1.setRotationPoint(6F, 9F, -1F); + Support1.setTextureSize(64, 32); + Support1.mirror = true; + setRotation(Support1, 0F, 0F, 0F); + Support2 = new ModelRenderer(this, 0, 0); + Support2.addBox(0F, 0F, 0F, 2, 15, 3); + Support2.setRotationPoint(-8F, 9F, -1F); + Support2.setTextureSize(64, 32); + Support2.mirror = true; + setRotation(Support2, 0F, 0F, 0F); + Hold1 = new ModelRenderer(this, 0, 0); + Hold1.addBox(0F, 0F, 0F, 2, 1, 1); + Hold1.setRotationPoint(4F, 11F, 0F); + Hold1.setTextureSize(64, 32); + Hold1.mirror = true; + setRotation(Hold1, 0F, 0F, 0F); + Hold2 = new ModelRenderer(this, 0, 0); + Hold2.addBox(0F, 0F, 0F, 2, 1, 1); + Hold2.setRotationPoint(-6F, 11F, 0F); + Hold2.setTextureSize(64, 32); + Hold2.mirror = true; + setRotation(Hold2, 0F, 0F, 0F); + SmelterBase = new ModelRenderer(this, 0, 0); + SmelterBase.addBox(0F, 0F, 0F, 4, 1, 5); + SmelterBase.setRotationPoint(-2F, 18F, -2F); + SmelterBase.setTextureSize(64, 32); + SmelterBase.mirror = true; + setRotation(SmelterBase, 0F, 0F, 0F); + SmelterSide1 = new ModelRenderer(this, 0, 0); + SmelterSide1.addBox(0F, 0F, 0F, 4, 2, 1); + SmelterSide1.setRotationPoint(-2F, 16F, -3F); + SmelterSide1.setTextureSize(64, 32); + SmelterSide1.mirror = true; + setRotation(SmelterSide1, 0F, 0F, 0F); + SmelterSide2 = new ModelRenderer(this, 0, 0); + SmelterSide2.addBox(0F, 0F, 0F, 4, 2, 1); + SmelterSide2.setRotationPoint(-2F, 16F, 3F); + SmelterSide2.setTextureSize(64, 32); + SmelterSide2.mirror = true; + setRotation(SmelterSide2, 0F, 0F, 0F); + SmelterSide3 = new ModelRenderer(this, 0, 0); + SmelterSide3.addBox(0F, 0F, 0F, 1, 2, 5); + SmelterSide3.setRotationPoint(2F, 16F, -2F); + SmelterSide3.setTextureSize(64, 32); + SmelterSide3.mirror = true; + setRotation(SmelterSide3, 0F, 0F, 0F); + SmelterSide4 = new ModelRenderer(this, 0, 0); + SmelterSide4.addBox(0F, 0F, 0F, 1, 2, 5); + SmelterSide4.setRotationPoint(-3F, 16F, -2F); + SmelterSide4.setTextureSize(64, 32); + SmelterSide4.mirror = true; + setRotation(SmelterSide4, 0F, 0F, 0F); + SmelterSide5 = new ModelRenderer(this, 0, 0); + SmelterSide5.addBox(0F, 0F, 0F, 1, 7, 5); + SmelterSide5.setRotationPoint(3F, 9F, -2F); + SmelterSide5.setTextureSize(64, 32); + SmelterSide5.mirror = true; + setRotation(SmelterSide5, 0F, 0F, 0F); + SmelterSide6 = new ModelRenderer(this, 0, 0); + SmelterSide6.addBox(0F, 0F, 0F, 1, 7, 5); + SmelterSide6.setRotationPoint(-4F, 9F, -2F); + SmelterSide6.setTextureSize(64, 32); + SmelterSide6.mirror = true; + setRotation(SmelterSide6, 0F, 0F, 0F); + SmelterSide7 = new ModelRenderer(this, 0, 0); + SmelterSide7.addBox(0F, 0F, 0F, 1, 7, 1); + SmelterSide7.setRotationPoint(2F, 9F, 3F); + SmelterSide7.setTextureSize(64, 32); + SmelterSide7.mirror = true; + setRotation(SmelterSide7, 0F, 0F, 0F); + SmelterSide8 = new ModelRenderer(this, 0, 0); + SmelterSide8.addBox(0F, 0F, 0F, 1, 7, 1); + SmelterSide8.setRotationPoint(-3F, 9F, 3F); + SmelterSide8.setTextureSize(64, 32); + SmelterSide8.mirror = true; + setRotation(SmelterSide8, 0F, 0F, 0F); + SmelterSide9 = new ModelRenderer(this, 0, 0); + SmelterSide9.addBox(0F, 0F, 0F, 4, 7, 1); + SmelterSide9.setRotationPoint(-2F, 9F, 4F); + SmelterSide9.setTextureSize(64, 32); + SmelterSide9.mirror = true; + setRotation(SmelterSide9, 0F, 0F, 0F); + SmelterSide10 = new ModelRenderer(this, 0, 0); + SmelterSide10.addBox(0F, 0F, 0F, 4, 7, 1); + SmelterSide10.setRotationPoint(-2F, 9F, -4F); + SmelterSide10.setTextureSize(64, 32); + SmelterSide10.mirror = true; + setRotation(SmelterSide10, 0F, 0F, 0F); + SmelterSide11 = new ModelRenderer(this, 0, 0); + SmelterSide11.addBox(0F, 0F, 0F, 1, 7, 1); + SmelterSide11.setRotationPoint(2F, 9F, -3F); + SmelterSide11.setTextureSize(64, 32); + SmelterSide11.mirror = true; + setRotation(SmelterSide11, 0F, 0F, 0F); + SmelterSide12 = new ModelRenderer(this, 0, 0); + SmelterSide12.addBox(0F, 0F, 0F, 1, 7, 1); + SmelterSide12.setRotationPoint(-3F, 9F, -3F); + SmelterSide12.setTextureSize(64, 32); + SmelterSide12.mirror = true; + setRotation(SmelterSide12, 0F, 0F, 0F); + HeatSourceSide1 = new ModelRenderer(this, 0, 0); + HeatSourceSide1.addBox(0F, 0F, 0F, 8, 2, 1); + HeatSourceSide1.setRotationPoint(-4F, 19F, 7F); + HeatSourceSide1.setTextureSize(64, 32); + HeatSourceSide1.mirror = true; + setRotation(HeatSourceSide1, 0F, 0F, 0F); + HeatSourceSide2 = new ModelRenderer(this, 0, 0); + HeatSourceSide2.addBox(0F, 0F, 0F, 1, 2, 12); + HeatSourceSide2.setRotationPoint(-6F, 19F, -6F); + HeatSourceSide2.setTextureSize(64, 32); + HeatSourceSide2.mirror = true; + setRotation(HeatSourceSide2, 0F, 0F, 0F); + HeatSourceSide3 = new ModelRenderer(this, 0, 0); + HeatSourceSide3.addBox(0F, 0F, 0F, 1, 2, 12); + HeatSourceSide3.setRotationPoint(5F, 19F, -6F); + HeatSourceSide3.setTextureSize(64, 32); + HeatSourceSide3.mirror = true; + setRotation(HeatSourceSide3, 0F, 0F, 0F); + HeatSourceSide4 = new ModelRenderer(this, 0, 0); + HeatSourceSide4.addBox(0F, 0F, 0F, 1, 2, 12); + HeatSourceSide4.setRotationPoint(4F, 21F, -6F); + HeatSourceSide4.setTextureSize(64, 32); + HeatSourceSide4.mirror = true; + setRotation(HeatSourceSide4, 0F, 0F, 0F); + HeatSourceSide5 = new ModelRenderer(this, 0, 0); + HeatSourceSide5.addBox(0F, 0F, 0F, 1, 2, 12); + HeatSourceSide5.setRotationPoint(-5F, 21F, -6F); + HeatSourceSide5.setTextureSize(64, 32); + HeatSourceSide5.mirror = true; + setRotation(HeatSourceSide5, 0F, 0F, 0F); + HeatSourceBase = new ModelRenderer(this, 0, 0); + HeatSourceBase.addBox(0F, 0F, 0F, 8, 1, 12); + HeatSourceBase.setRotationPoint(-4F, 23F, -6F); + HeatSourceBase.setTextureSize(64, 32); + HeatSourceBase.mirror = true; + setRotation(HeatSourceBase, 0F, 0F, 0F); + HeatSourceSide6 = new ModelRenderer(this, 0, 0); + HeatSourceSide6.addBox(0F, 0F, 0F, 8, 2, 1); + HeatSourceSide6.setRotationPoint(-4F, 21F, -7F); + HeatSourceSide6.setTextureSize(64, 32); + HeatSourceSide6.mirror = true; + setRotation(HeatSourceSide6, 0F, 0F, 0F); + HeatSourceSide7 = new ModelRenderer(this, 0, 0); + HeatSourceSide7.addBox(0F, 0F, 0F, 8, 2, 1); + HeatSourceSide7.setRotationPoint(-4F, 21F, 6F); + HeatSourceSide7.setTextureSize(64, 32); + HeatSourceSide7.mirror = true; + setRotation(HeatSourceSide7, 0F, 0F, 0F); + HeatSourceSide8 = new ModelRenderer(this, 0, 0); + HeatSourceSide8.addBox(0F, 0F, 0F, 1, 2, 1); + HeatSourceSide8.setRotationPoint(-5F, 19F, 6F); + HeatSourceSide8.setTextureSize(64, 32); + HeatSourceSide8.mirror = true; + setRotation(HeatSourceSide8, 0F, 0F, 0F); + HeatSourceSide9 = new ModelRenderer(this, 0, 0); + HeatSourceSide9.addBox(0F, 0F, 0F, 1, 2, 1); + HeatSourceSide9.setRotationPoint(4F, 19F, 6F); + HeatSourceSide9.setTextureSize(64, 32); + HeatSourceSide9.mirror = true; + setRotation(HeatSourceSide9, 0F, 0F, 0F); + HeatSourceSide10 = new ModelRenderer(this, 0, 0); + HeatSourceSide10.addBox(0F, 0F, 0F, 1, 2, 1); + HeatSourceSide10.setRotationPoint(4F, 19F, -7F); + HeatSourceSide10.setTextureSize(64, 32); + HeatSourceSide10.mirror = true; + setRotation(HeatSourceSide10, 0F, 0F, 0F); + HeatSourceSide11 = new ModelRenderer(this, 0, 0); + HeatSourceSide11.addBox(0F, 0F, 0F, 1, 2, 1); + HeatSourceSide11.setRotationPoint(-5F, 19F, -7F); + HeatSourceSide11.setTextureSize(64, 32); + HeatSourceSide11.mirror = true; + setRotation(HeatSourceSide11, 0F, 0F, 0F); + HeatSourceSide12 = new ModelRenderer(this, 0, 0); + HeatSourceSide12.addBox(0F, 0F, 0F, 8, 2, 1); + HeatSourceSide12.setRotationPoint(-4F, 19F, -8F); + HeatSourceSide12.setTextureSize(64, 32); + HeatSourceSide12.mirror = true; + setRotation(HeatSourceSide12, 0F, 0F, 0F); + } + + public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) + { + super.render(entity, f, f1, f2, f3, f4, f5); + setRotationAngles(f, f1, f2, f3, f4, f5); + Support1.render(f5); + Support2.render(f5); + Hold1.render(f5); + Hold2.render(f5); + SmelterBase.render(f5); + SmelterSide1.render(f5); + SmelterSide2.render(f5); + SmelterSide3.render(f5); + SmelterSide4.render(f5); + SmelterSide5.render(f5); + SmelterSide6.render(f5); + SmelterSide7.render(f5); + SmelterSide8.render(f5); + SmelterSide9.render(f5); + SmelterSide10.render(f5); + SmelterSide11.render(f5); + SmelterSide12.render(f5); + HeatSourceSide1.render(f5); + HeatSourceSide2.render(f5); + HeatSourceSide3.render(f5); + HeatSourceSide4.render(f5); + HeatSourceSide5.render(f5); + HeatSourceBase.render(f5); + HeatSourceSide6.render(f5); + HeatSourceSide7.render(f5); + HeatSourceSide8.render(f5); + HeatSourceSide9.render(f5); + HeatSourceSide10.render(f5); + HeatSourceSide11.render(f5); + HeatSourceSide12.render(f5); + } + + private void setRotation(ModelRenderer model, float x, float y, float z) + { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } + + public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5) + { + super.setRotationAngles(f, f1, f2, f3, f4, f5, null); + } + +} diff --git a/src/main/java/darkknight/jewelrycraft/recipes/CraftingRecipes.java b/src/main/java/darkknight/jewelrycraft/recipes/CraftingRecipes.java new file mode 100644 index 0000000..8e70c8e --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/recipes/CraftingRecipes.java @@ -0,0 +1,53 @@ +package darkknight.jewelrycraft.recipes; + +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.FurnaceRecipes; +import cpw.mods.fml.common.event.FMLPreInitializationEvent; +import cpw.mods.fml.common.registry.GameRegistry; +import darkknight.jewelrycraft.block.BlockList; +import darkknight.jewelrycraft.item.ItemList; + +public class CraftingRecipes +{ + private static boolean isInitialized = false; + + public static void preInit(FMLPreInitializationEvent e) + { + if (!isInitialized) + { + //Items + GameRegistry.addRecipe(new ItemStack(ItemList.thiefGloves), "x x", "yxy", "yxy", 'x', ItemList.shadowIngot, 'y', new ItemStack(Blocks.wool, 1, 15)); + GameRegistry.addRecipe(new ItemStack(ItemList.clayMolds, 1, 0), "xx", 'x', Items.clay_ball); + GameRegistry.addRecipe(new ItemStack(ItemList.clayMolds, 1, 1), " x ", "x x", " x ", 'x', Items.clay_ball); + GameRegistry.addRecipe(new ItemStack(ItemList.clayMolds, 1, 2), "x x", "x x", " x ", 'x', Items.clay_ball); + GameRegistry.addRecipe(new ItemStack(ItemList.crystal, 1, 15), " x ", "x x", " x ", 'x', Blocks.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(Items.dye, 1, i)}); + GameRegistry.addShapelessRecipe(new ItemStack(ItemList.crystal, 1, 15), new Object[]{new ItemStack(ItemList.crystal, 1, i), new ItemStack(Items.dye, 1, 15)}); + } + GameRegistry.addShapelessRecipe(new ItemStack(ItemList.shadowIngot, 9), new Object[]{new ItemStack(BlockList.shadowBlock)}); + GameRegistry.addShapelessRecipe(new ItemStack(ItemList.guide), new Object[]{new ItemStack(Items.book), new ItemStack(ItemList.molds, 1, 0)}); + GameRegistry.addShapelessRecipe(new ItemStack(ItemList.guide), new Object[]{new ItemStack(Items.book), new ItemStack(ItemList.molds, 1, 1)}); + GameRegistry.addShapelessRecipe(new ItemStack(ItemList.guide), new Object[]{new ItemStack(Items.book), new ItemStack(ItemList.molds, 1, 2)}); + + //Blocks + GameRegistry.addRecipe(new ItemStack(BlockList.molder), "x x", "xxx", 'x', Blocks.cobblestone); + GameRegistry.addRecipe(new ItemStack(BlockList.smelter), "xyx", "x x", "xzx", 'x', Blocks.cobblestone, 'y', Items.bucket, 'z', Items.lava_bucket); + GameRegistry.addRecipe(new ItemStack(BlockList.jewelCraftingTable), "xxx", "y y", "y y", 'x', Blocks.planks, 'y', Blocks.cobblestone); + GameRegistry.addRecipe(new ItemStack(BlockList.displayer, 2), " x ", "xxx", "yyy", 'x', Items.iron_ingot, 'y', Blocks.emerald_block); + GameRegistry.addRecipe(new ItemStack(BlockList.shadowBlock, 1), "xxx", "xxx", "xxx", 'x', ItemList.shadowIngot); + GameRegistry.addRecipe(new ItemStack(BlockList.jewelAltar, 1), "sws", "bwb", "bbb", 's', Blocks.end_stone, 'w', new ItemStack(Blocks.wool, 1, 5), 'b', Blocks.nether_brick); + + //Smelting + GameRegistry.addSmelting(BlockList.shadowOre, new ItemStack(ItemList.shadowIngot), 1.5f); + GameRegistry.addSmelting(new ItemStack(ItemList.clayMolds, 0), new ItemStack(ItemList.molds, 1, 0), 0.2F); + GameRegistry.addSmelting(new ItemStack(ItemList.clayMolds, 1), new ItemStack(ItemList.molds, 1, 1), 0.2F); + GameRegistry.addSmelting(new ItemStack(ItemList.clayMolds, 2), new ItemStack(ItemList.molds, 1, 2), 0.2F); + + isInitialized = true; + } + } +} diff --git a/src/main/java/darkknight/jewelrycraft/renders/TileEntityDisplayerRender.java b/src/main/java/darkknight/jewelrycraft/renders/TileEntityDisplayerRender.java new file mode 100644 index 0000000..b7acffc --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/renders/TileEntityDisplayerRender.java @@ -0,0 +1,237 @@ +package darkknight.jewelrycraft.renders; + +import java.awt.Color; + +import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.entity.Entity; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.item.Item; +import net.minecraft.item.ItemMap; +import net.minecraft.item.ItemStack; +import net.minecraft.server.MinecraftServer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ResourceLocation; +import net.minecraft.world.World; +import net.minecraft.world.WorldServer; +import net.minecraftforge.common.util.FakePlayer; + +import org.lwjgl.opengl.GL11; + +import com.mojang.authlib.GameProfile; + +import darkknight.jewelrycraft.model.ModelDisplayer; +import darkknight.jewelrycraft.tileentity.TileEntityDisplayer; + +public class TileEntityDisplayerRender extends TileEntitySpecialRenderer +{ + ModelDisplayer displayer = new ModelDisplayer(); + String texture = "textures/tileentities/Displayer.png"; + + @Override + public void renderTileEntityAt(TileEntity te, double x, double y, double z, float scale) + { + GL11.glPushMatrix(); + GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F); + TileEntityDisplayer disp = (TileEntityDisplayer)te; + int block = disp.getBlockMetadata(); + + ResourceLocation blockTexture = new ResourceLocation("jewelrycraft", texture); + Minecraft.getMinecraft().renderEngine.bindTexture(blockTexture); + + GL11.glPushMatrix(); + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + displayer.render((Entity) null, disp.ringTranslation1, disp.ringTranslation2, disp.ringTranslation3, 0.0F, 0.0F, 0.0625F); + if(disp != null && disp.hasObject && disp.object != null && disp.object != new ItemStack(Item.getItemById(0), 0, 0)) + { + int ind = -3; + GL11.glPushMatrix(); + 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, 0F, block, disp, Color.GRAY.getRGB()); + GL11.glPopMatrix(); + ind++; + if(!(disp.object.getItem() instanceof ItemMap) && disp.object != null && disp.object != new ItemStack(Item.getItemById(0), 0, 0) && disp.object.getTooltip(te.getWorldObj().getClosestPlayer(x, y, z, 2D), true) != null) + { + for(int i = 1; i < disp.object.getTooltip(te.getWorldObj().getClosestPlayer(x, y, z, 2D), true).size(); i++) + { + if(disp.object.getTooltip(te.getWorldObj().getClosestPlayer(x, y, z, 2D), true).get(i).toString() != "") + { + GL11.glPushMatrix(); + renderLabel(disp.object.getTooltip(te.getWorldObj().getClosestPlayer(x, y, z, 2D), true).get(i).toString(), 0F, (-0.171F)*ind, 0F, block, disp, Color.GRAY.getRGB()); + GL11.glPopMatrix(); + ind++; + } + } + } + GL11.glPushMatrix(); + GL11.glDisable(GL11.GL_LIGHTING); + EntityItem entityitem = new EntityItem(te.getWorldObj(), 0.0D, 0.0D, 0.0D, disp.object); + entityitem.hoverStart = 0.0F; + disp.object.stackSize = 1; + GL11.glRotatef(180F, 1F, 0F, 0F); + GL11.glTranslatef(0.0F, -0.6F + disp.ringTranslation1/5, 0F); + GL11.glRotatef(disp.rotAngle, 0F, 1F, 0F); + if(RenderManager.instance.options.fancyGraphics) + RenderManager.instance.renderEntityWithPosYaw(entityitem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F); + else + { + GL11.glRotatef(180F, 0F, 1F, 0F); + RenderManager.instance.options.fancyGraphics = true; + RenderManager.instance.renderEntityWithPosYaw(entityitem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F); + RenderManager.instance.options.fancyGraphics = false; + } + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glPopMatrix(); + } + GL11.glPopMatrix(); + GL11.glPopMatrix(); + } + + public void adjustLightFixture(World world, int i, int j, int k, Block block) + { + Tessellator tess = Tessellator.instance; + float brightness = block.getLightOpacity(world, i, j, k); + int skyLight = world.getLightBrightnessForSkyBlocks(i, j, k, 0); + int modulousModifier = skyLight % 65536; + int divModifier = skyLight / 65536; + tess.setColorOpaque_F(brightness, brightness, brightness); + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float) modulousModifier, divModifier); + } + + protected void renderLabel(String par2Str, double x, double y, double z, int metadata, TileEntity te, int color) + { + FontRenderer fontrenderer = RenderManager.instance.getFontRenderer(); + 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); + Tessellator tessellator = Tessellator.instance; + GL11.glDisable(GL11.GL_TEXTURE_2D); + int j = fontrenderer.getStringWidth(par2Str) / 2; + tessellator.startDrawingQuads(); + tessellator.setColorRGBA_F(0.0F, 0.2F, 0.2F, 0.9F); + 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; + int red = (color >> 16) & 0xFF; + int green = (color >> 8) & 0xFF; + int blue = color & 0xFF; + GL11.glTranslatef((float)x + 1f, (float)y + 1f, (float)z); + GL11.glPushMatrix(); + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glScalef(var17*70F, 1F, 0F); + fontrenderer.drawString(par2Str.replaceFirst("§0", "§r").replaceFirst("§1", "§r").replaceFirst("§2", "§r").replaceFirst("§3", "§r").replaceFirst("§4", "§r").replaceFirst("§5", "§r").replaceFirst("§6", "§r").replaceFirst("§7", "§r").replaceFirst("§8", "§r").replaceFirst("§9", "§r").replaceFirst("§a", "§r").replaceFirst("§b", "§r").replaceFirst("§c", "§r").replaceFirst("§d", "§r").replaceFirst("§e", "§r").replaceFirst("§f", "§r"), -j, 0, 65536 * (red/2) + 256 * (green/2) + blue/2); + GL11.glPopMatrix(); + GL11.glTranslatef((float)x - 1f, (float)y - 1f, (float)z - 1F); + GL11.glScalef(var17*70F, 1F, 0F); + fontrenderer.drawString(par2Str, -j, 0, color); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_BLEND); + GL11.glPopMatrix(); + } + + public void replaceEnumEnchValues(String str, int color) + { + if(str.contains("§0")) + { + color = Color.BLACK.getRGB(); + str.replace("§0", ""); + } + if(str.contains("§1")) + { + color = 85; + str.replace("§1", ""); + } + if(str.contains("§2")) + { + color = 17920; + str.replace("§2", ""); + } + if(str.contains("§3")) + { + color = 1336183; + str.replace("§3", ""); + } + if(str.contains("§4")) + { + color = 4587520; + str.replace("§4", ""); + } + if(str.contains("§5")) + { + color = 5701759; + str.replace("§5", ""); + } + if(str.contains("§6")) + { + color = 16762880; + str.replace("§6", ""); + } + if(str.contains("§7")) + { + color = Color.GRAY.getRGB(); + str.replace("§7", ""); + } + if(str.contains("§8")) + { + color = Color.DARK_GRAY.getRGB(); + str.replace("§8", ""); + } + if(str.contains("§9")) + { + color = Color.BLUE.getRGB(); + str.replace("§9", ""); + } + if(str.contains("§a")) + { + color = Color.GREEN.getRGB(); + str.replace("§a", ""); + } + if(str.contains("§b")) + { + color = Color.CYAN.getRGB(); + str.replace("§b", ""); + } + if(str.contains("§c")) + { + color = Color.RED.getRGB(); + str.replace("§c", ""); + } + if(str.contains("§d")) + { + color = 11665663; + str.replace("§d", ""); + } + if(str.contains("§e")) + { + color = Color.YELLOW.getRGB(); + str.replace("§e", ""); + } + if(str.contains("§f")) + { + color = Color.WHITE.getRGB(); + str.replace("§f", ""); + } + } +}
\ No newline at end of file diff --git a/src/main/java/darkknight/jewelrycraft/renders/TileEntityJewelrsCraftingTableRender.java b/src/main/java/darkknight/jewelrycraft/renders/TileEntityJewelrsCraftingTableRender.java new file mode 100644 index 0000000..bfc2aac --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/renders/TileEntityJewelrsCraftingTableRender.java @@ -0,0 +1,165 @@ +package darkknight.jewelrycraft.renders; + +import org.lwjgl.opengl.GL11; + +import darkknight.jewelrycraft.model.ModelJewlersCraftingBench; +import darkknight.jewelrycraft.tileentity.TileEntityJewelrsCraftingTable; +import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.entity.Entity; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ResourceLocation; +import net.minecraft.world.World; + +public class TileEntityJewelrsCraftingTableRender extends TileEntitySpecialRenderer +{ + ModelJewlersCraftingBench modelTable = new ModelJewlersCraftingBench(); + String texture = "textures/tileentities/JewelrsCraftingBench.png"; + + @Override + public void renderTileEntityAt(TileEntity te, double x, double y, double z, float scale) + { + GL11.glPushMatrix(); + GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F); + + ResourceLocation blockTexture = new ResourceLocation("jewelrycraft", texture); + Minecraft.getMinecraft().renderEngine.bindTexture(blockTexture); + int block = te.getBlockMetadata(); + TileEntityJewelrsCraftingTable jt = (TileEntityJewelrsCraftingTable)te; + + GL11.glPushMatrix(); + if (block == 0) + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + else if (block == 1){ + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(90F, 0.0F, 1.0F, 0.0F); + } + else if (block == 2) + GL11.glRotatef(180F, 1.0F, 0.0F, 0.0F); + else if (block == 3) + GL11.glRotatef(180F, 1.0F, 0.0F, 1.0F); + + modelTable.render((Entity) null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F); + if (jt != null) + { + if (jt.hasJewelry && jt.jewelry.getIconIndex() != null && jt.jewelry.getIconIndex().getIconName() != "") + { + GL11.glPushMatrix(); + GL11.glDisable(GL11.GL_LIGHTING); + EntityItem entityitem = new EntityItem(te.getWorldObj(), 0.0D, 0.0D, 0.0D, jt.jewelry); + entityitem.getEntityItem().stackSize = 1; + entityitem.hoverStart = 0.0F; + + GL11.glRotatef(180F, 1F, 0F, 0F); + GL11.glScalef(0.5F, 0.5F, 0.5F); + GL11.glTranslatef(0.0F, -1.6F, 0.6F); + GL11.glRotatef(jt.angle, 0F, 1F, 0F); + if(RenderManager.instance.options.fancyGraphics) + RenderManager.instance.renderEntityWithPosYaw(entityitem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F); + else + { + GL11.glRotatef(180F, 0F, 1F, 0F); + RenderManager.instance.options.fancyGraphics = true; + RenderManager.instance.renderEntityWithPosYaw(entityitem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F); + RenderManager.instance.options.fancyGraphics = false; + } + + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glPopMatrix(); + } + if (jt.hasEndItem && jt.endItem.getIconIndex().getIconName() != "") + { + GL11.glPushMatrix(); + GL11.glDisable(GL11.GL_LIGHTING); + EntityItem entityitem = new EntityItem(te.getWorldObj(), 0.0D, 0.0D, 0.0D, jt.endItem); + entityitem.getEntityItem().stackSize = 1; + entityitem.hoverStart = 0.0F; + + GL11.glRotatef(180F, 1F, 0F, 0F); + GL11.glScalef(0.5F, 0.5F, 0.5F); + GL11.glTranslatef(0.0F, -1.6F, 0.6F); + GL11.glRotatef(jt.angle, 0F, 1F, 0F); + if(RenderManager.instance.options.fancyGraphics) + RenderManager.instance.renderEntityWithPosYaw(entityitem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F); + else + { + GL11.glRotatef(180F, 0F, 1F, 0F); + RenderManager.instance.options.fancyGraphics = true; + RenderManager.instance.renderEntityWithPosYaw(entityitem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F); + RenderManager.instance.options.fancyGraphics = false; + } + + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glPopMatrix(); + } + if (jt.hasModifier && jt.modifier.getIconIndex().getIconName() != "") + { + GL11.glPushMatrix(); + GL11.glDisable(GL11.GL_LIGHTING); + EntityItem entityitem = new EntityItem(te.getWorldObj(), 0.0D, 0.0D, 0.0D, jt.modifier); + entityitem.getEntityItem().stackSize = 1; + entityitem.hoverStart = 0.0F; + + GL11.glRotatef(180F, 1F, 0F, 0F); + GL11.glScalef(0.5F, 0.5F, 0.5F); + GL11.glTranslatef(0.55F, -1.5F, -0.45F); + GL11.glRotatef(jt.angle, 0F, 1F, 0F); + if(RenderManager.instance.options.fancyGraphics) + RenderManager.instance.renderEntityWithPosYaw(entityitem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F); + else + { + GL11.glRotatef(180F, 0F, 1F, 0F); + RenderManager.instance.options.fancyGraphics = true; + RenderManager.instance.renderEntityWithPosYaw(entityitem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F); + RenderManager.instance.options.fancyGraphics = false; + } + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glPopMatrix(); + } + if (jt.hasJewel && jt.jewel.getIconIndex().getIconName() != "") + { + GL11.glPushMatrix(); + GL11.glDisable(GL11.GL_LIGHTING); + EntityItem entityitem = new EntityItem(te.getWorldObj(), 0.0D, 0.0D, 0.0D, jt.jewel); + entityitem.getEntityItem().stackSize = 1; + entityitem.hoverStart = 0.0F; + + GL11.glRotatef(180F, 1F, 0F, 0F); + GL11.glScalef(0.5F, 0.5F, 0.5F); + GL11.glTranslatef(-0.55F, -1.5F, -0.45F); + GL11.glRotatef(jt.angle, 0F, 1F, 0F); + if(RenderManager.instance.options.fancyGraphics) + RenderManager.instance.renderEntityWithPosYaw(entityitem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F); + else + { + GL11.glRotatef(180F, 0F, 1F, 0F); + RenderManager.instance.options.fancyGraphics = true; + RenderManager.instance.renderEntityWithPosYaw(entityitem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F); + RenderManager.instance.options.fancyGraphics = false; + } + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glPopMatrix(); + } + } + + GL11.glPopMatrix(); + GL11.glPopMatrix(); + } + + public void adjustLightFixture(World world, int i, int j, int k, Block block) + { + Tessellator tess = Tessellator.instance; + float brightness = block.getLightOpacity(world, i, j, k); + int skyLight = world.getLightBrightnessForSkyBlocks(i, j, k, 0); + int modulousModifier = skyLight % 65536; + int divModifier = skyLight / 65536; + tess.setColorOpaque_F(brightness, brightness, brightness); + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float) modulousModifier, divModifier); + } + +} diff --git a/src/main/java/darkknight/jewelrycraft/renders/TileEntityMolderRender.java b/src/main/java/darkknight/jewelrycraft/renders/TileEntityMolderRender.java new file mode 100644 index 0000000..4dcec8c --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/renders/TileEntityMolderRender.java @@ -0,0 +1,100 @@ +package darkknight.jewelrycraft.renders; + +import org.lwjgl.opengl.GL11; + +import darkknight.jewelrycraft.model.ModelMolder; +import darkknight.jewelrycraft.tileentity.TileEntityMolder; + +import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.entity.RenderItem; +import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.entity.Entity; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ResourceLocation; +import net.minecraft.world.World; + +public class TileEntityMolderRender extends TileEntitySpecialRenderer +{ + ModelMolder modelMolder = new ModelMolder(); + String texture = "textures/tileentities/Molder.png"; + + @Override + public void renderTileEntityAt(TileEntity te, double x, double y, double z, float scale) + { + GL11.glPushMatrix(); + GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F); + TileEntityMolder me = (TileEntityMolder) te; + + ResourceLocation blockTexture = new ResourceLocation("jewelrycraft", texture); + Minecraft.getMinecraft().renderEngine.bindTexture(blockTexture); + int block = me.getBlockMetadata(); + + GL11.glPushMatrix(); + if (block == 0) + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + else if (block == 1){ + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(90F, 0.0F, 1.0F, 0.0F); + } + else if (block == 2) + GL11.glRotatef(180F, 1.0F, 0.0F, 0.0F); + else if (block == 3) + GL11.glRotatef(180F, 1.0F, 0.0F, 1.0F); + modelMolder.render((Entity) null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F); + if (me != null) + { + if (me.hasMold) + { + GL11.glPushMatrix(); + GL11.glDisable(GL11.GL_LIGHTING); + EntityItem entityitem = new EntityItem(te.getWorldObj(), 0.0D, 0.0D, 0.0D, me.mold); + entityitem.getEntityItem().stackSize = 1; + entityitem.hoverStart = 0.0F; + GL11.glTranslatef(0F, 1.312F, -0.25F); + GL11.glScalef(1.25F, 1.0F, 1.25F); + GL11.glRotatef(90F, 1F, 0F, 0f); + RenderItem.renderInFrame = true; + if(entityitem != null) RenderManager.instance.renderEntityWithPosYaw(entityitem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F); + RenderItem.renderInFrame = false; + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glPopMatrix(); + } + if (me.hasJewelBase && me.jewelBase.getIconIndex() != null && me.jewelBase.getIconIndex().getIconName() != "") + { + GL11.glPushMatrix(); + GL11.glDisable(GL11.GL_LIGHTING); + EntityItem entityitem = new EntityItem(te.getWorldObj(), 0.0D, 0.0D, 0.0D, me.jewelBase); + entityitem.getEntityItem().stackSize = 1; + entityitem.hoverStart = 0.0F; + GL11.glTranslatef(0F, 1.312F, -0.25F); + GL11.glScalef(1.25F, 1.0F, 1.25F); + GL11.glRotatef(90F, 1F, 0F, 0f); + RenderItem.renderInFrame = true; + if(entityitem != null) RenderManager.instance.renderEntityWithPosYaw(entityitem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F); + RenderItem.renderInFrame = false; + GL11.glColor4f(1, 1F, 1F, 1.0F); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glPopMatrix(); + } + } + GL11.glPopMatrix(); + GL11.glPopMatrix(); + } + + public void adjustLightFixture(World world, int i, int j, int k, Block block) + { + Tessellator tess = Tessellator.instance; + float brightness = block.getLightOpacity(world, i, j, k); + int skyLight = world.getLightBrightnessForSkyBlocks(i, j, k, 0); + int modulousModifier = skyLight % 65536; + int divModifier = skyLight / 65536; + tess.setColorOpaque_F(brightness, brightness, brightness); + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float) modulousModifier, divModifier); + } + +} diff --git a/src/main/java/darkknight/jewelrycraft/renders/TileEntitySmelterRender.java b/src/main/java/darkknight/jewelrycraft/renders/TileEntitySmelterRender.java new file mode 100644 index 0000000..0c981c6 --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/renders/TileEntitySmelterRender.java @@ -0,0 +1,140 @@ +package darkknight.jewelrycraft.renders; + +import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.entity.RenderItem; +import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.entity.Entity; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ResourceLocation; +import net.minecraft.world.World; + +import org.lwjgl.opengl.GL11; + +import darkknight.jewelrycraft.block.BlockList; +import darkknight.jewelrycraft.model.ModelSmelter; +import darkknight.jewelrycraft.tileentity.TileEntitySmelter; + +public class TileEntitySmelterRender extends TileEntitySpecialRenderer +{ + ModelSmelter modelSmelter = new ModelSmelter(); + String texture = "textures/tileentities/Smelter.png"; + + @Override + public void renderTileEntityAt(TileEntity te, double x, double y, double z, float scale) + { + GL11.glPushMatrix(); + GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F); + + ResourceLocation blockTexture = new ResourceLocation("jewelrycraft", texture); + Minecraft.getMinecraft().renderEngine.bindTexture(blockTexture); + TileEntitySmelter st = (TileEntitySmelter)te; + int block = te.getBlockMetadata(); + + GL11.glPushMatrix(); + if (block == 0) + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + else if (block == 1){ + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(90F, 0.0F, 1.0F, 0.0F); + } + else if (block == 2) + GL11.glRotatef(180F, 1.0F, 0.0F, 0.0F); + else if (block == 3) + GL11.glRotatef(180F, 1.0F, 0.0F, 1.0F); + + modelSmelter.render((Entity) null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F); + + GL11.glPushMatrix(); + GL11.glDisable(GL11.GL_LIGHTING); + EntityItem entityitem = new EntityItem(te.getWorldObj(), 0.0D, 0.0D, 0.0D, new ItemStack(Blocks.lava)); + entityitem.getEntityItem().stackSize = 1; + entityitem.hoverStart = 0.0F; + + GL11.glTranslatef(-0F, 1.25F, -0.3F); + GL11.glScalef(1.25F, 1.0F, 1.47F); + GL11.glRotatef(90F, 1F, 0F, 0f); + RenderItem.renderInFrame = true; + RenderManager.instance.renderEntityWithPosYaw(entityitem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F); + RenderItem.renderInFrame = false; + + GL11.glTranslatef(0F, 0.46F, 0.0F); + GL11.glScalef(0.8F, 0.1F, 0F); + RenderItem.renderInFrame = true; + RenderManager.instance.renderEntityWithPosYaw(entityitem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F); + RenderItem.renderInFrame = false; + + GL11.glTranslatef(0F, -5.6F, 0.0F); + RenderItem.renderInFrame = true; + RenderManager.instance.renderEntityWithPosYaw(entityitem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F); + RenderItem.renderInFrame = false; + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glPopMatrix(); + if (st != null) + { + if (st.hasMetal && st.metal != null && st.metal.getIconIndex() != null && st.metal.getIconIndex().getIconName() != "") + { + GL11.glPushMatrix(); + GL11.glDisable(GL11.GL_LIGHTING); + EntityItem metal = new EntityItem(te.getWorldObj(), 0.0D, 0.0D, 0.0D, st.metal); + metal.getEntityItem().stackSize = 1; + metal.hoverStart = 0.0F; + + GL11.glRotatef(-50F, 1F, 0F, 0F); + GL11.glRotatef(-50F, 0F, 0F, 1F); + GL11.glRotatef(180F, 1F, 0F, 0F); + GL11.glScalef(0.5F, 0.5F, 0.5F); + GL11.glTranslatef(-0.9F, -0.9F, -1.6F); + if(RenderManager.instance.options.fancyGraphics) RenderManager.instance.renderEntityWithPosYaw(metal, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F); + else + { + RenderManager.instance.options.fancyGraphics = true; + RenderManager.instance.renderEntityWithPosYaw(metal, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F); + RenderManager.instance.options.fancyGraphics = false; + } + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glPopMatrix(); + } +// if(st.hasMoltenMetal && st.moltenMetal != null) +// { +// +// GL11.glPushMatrix(); +// GL11.glDisable(GL11.GL_LIGHTING); +// EntityItem moltenMetal = new EntityItem(te.getWorldObj(), 0.0D, 0.0D, 0.0D, new ItemStack(BlockList.moltenMetal)); +// moltenMetal.getEntityItem().stackSize = 1; +// moltenMetal.hoverStart = 0.0F; +// +// GL11.glColor4f(0f, 0f, 1f, 1f); +// GL11.glTranslatef(-0F, 0.75F, -0.3F); +// GL11.glScalef(1.25F, 1.0F, 1.47F); +// GL11.glRotatef(90F, 1F, 0F, 0f); +// RenderItem.renderInFrame = true; +// RenderManager.instance.renderEntityWithPosYaw(moltenMetal, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F); +// RenderItem.renderInFrame = false; +// GL11.glEnable(GL11.GL_LIGHTING); +// GL11.glPopMatrix(); +// } + } + + GL11.glPopMatrix(); + GL11.glPopMatrix(); + } + + public void adjustLightFixture(World world, int i, int j, int k, Block block) + { + Tessellator tess = Tessellator.instance; + float brightness = block.getLightOpacity(world, i, j, k); + int skyLight = world.getLightBrightnessForSkyBlocks(i, j, k, 0); + int modulousModifier = skyLight % 65536; + int divModifier = skyLight / 65536; + tess.setColorOpaque_F(brightness, brightness, brightness); + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float) modulousModifier, divModifier); + } + +} diff --git a/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityAltar.java b/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityAltar.java new file mode 100644 index 0000000..62ef646 --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityAltar.java @@ -0,0 +1,144 @@ +package darkknight.jewelrycraft.tileentity; + +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.NetworkManager; +import net.minecraft.network.Packet; +import net.minecraft.network.play.server.S35PacketUpdateTileEntity; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.AxisAlignedBB; +import darkknight.jewelrycraft.util.JewelryNBT; + +public class TileEntityAltar extends TileEntity +{ + public ItemStack object; + public boolean isDirty, hasObject; + public String playerName; + + public TileEntityAltar() + { + this.hasObject = false; + this.object = new ItemStack(Item.getItemById(0), 0, 0); + this.isDirty = false; + this.playerName = ""; + } + + @Override + public void writeToNBT(NBTTagCompound nbt) + { + super.writeToNBT(nbt); + NBTTagCompound tag = new NBTTagCompound(); + this.object.writeToNBT(tag); + nbt.setTag("object", tag); + nbt.setBoolean("hasObject", hasObject); + nbt.setString("playerName", playerName); + } + + @Override + public void readFromNBT(NBTTagCompound nbt) + { + super.readFromNBT(nbt); + this.object = new ItemStack(Item.getItemById(0), 0, 0); + this.object.readFromNBT(nbt.getCompoundTag("object")); + this.hasObject = nbt.getBoolean("hasObject"); + this.playerName = nbt.getString("playerName"); + } + + @SuppressWarnings("rawtypes") + @Override + public void updateEntity() + { + super.updateEntity(); + + if(isDirty) + { + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + isDirty = false; + } + if(hasObject && playerName != "") + { + //int playerPosX = (int)player.posX, playerPosY = (int)player.posY, playerPosZ = (int)player.posZ; + List entitiesR = worldObj.getEntitiesWithinAABB(EntityLivingBase.class, AxisAlignedBB.getBoundingBox(xCoord, yCoord + 1D, zCoord, xCoord + 0.5D, yCoord + 2D, zCoord + 0.5D)); + List entitiesN = worldObj.getEntitiesWithinAABB(EntityLivingBase.class, AxisAlignedBB.getBoundingBox(xCoord - 0.5D, yCoord + 1D, zCoord - 0.5D, xCoord + 1.5D, yCoord + 2D, zCoord + 1.5D)); + if(object.getUnlocalizedName().contains("ring")) + { + if (JewelryNBT.isJewelX(object, new ItemStack(Items.ender_pearl)) && JewelryNBT.dimension(object) != -2 && JewelryNBT.playerPosX(object) != -1 && JewelryNBT.playerPosY(object) != -1 && JewelryNBT.playerPosZ(object) != -1) + { + double posX = JewelryNBT.playerPosX(object), posY = JewelryNBT.playerPosY(object), posZ = JewelryNBT.playerPosZ(object); + int dimension = JewelryNBT.dimension(object); + for(int i = 0; i < entitiesR.size(); i++) + { + EntityLivingBase entity = (EntityLivingBase) entitiesR.get(i); + if (!JewelryNBT.isDimensionX(object, entity.dimension) && JewelryNBT.isModifierX(object, new ItemStack(Items.bed))){ + entity.travelToDimension(dimension); + entity.setPositionAndUpdate(posX, posY, posZ); + } + else if(JewelryNBT.isDimensionX(object, entity.dimension)) entity.setPositionAndUpdate(posX, posY, posZ); + } + } + if (JewelryNBT.isModifierX(object, new ItemStack(Items.dye, 1, 15))) + { + for(int i=-1; i<=1; i++) + for(int j=-1; j<=1; j++) + for(int k=-1; k<=1; k++) + { + //if(worldObj.getBlockId(xCoord + i, yCoord + j, zCoord + k) == Block.dirt.blockID && (worldObj.getBlockId(xCoord + i, yCoord + j + 1, zCoord + k) == 0 || worldObj.getBlockId(xCoord + i, yCoord + j + 1, zCoord + k) == Block.crops.blockID) || worldObj.getBlockId(xCoord + i, yCoord + j + 1, zCoord + k) == Block.potato.blockID) worldObj.setBlock(xCoord + i, yCoord + j, zCoord + k, Block.tilledField.blockID); + if(worldObj.getBlock(xCoord + i, yCoord + j, zCoord + k) == Blocks.farmland) worldObj.setBlockMetadataWithNotify(xCoord + i, yCoord + j, zCoord + k, 1, 7); + if(worldObj.getBlock(xCoord + i, yCoord + j, zCoord + k) != Blocks.farmland) worldObj.scheduleBlockUpdate(xCoord + i, yCoord + j, zCoord + k, worldObj.getBlock(xCoord + i, yCoord + j, zCoord + k), 5); + //JewelrycraftUtil.applyBonemeal(object, worldObj, xCoord + i, yCoord + j, zCoord + k, player); + } + } + } + else if(object.getUnlocalizedName().contains("necklace")) + { + if (JewelryNBT.isJewelX(object, new ItemStack(Items.ender_pearl)) && JewelryNBT.dimension(object) != -2 && JewelryNBT.playerPosX(object) != -1 && JewelryNBT.playerPosY(object) != -1 && JewelryNBT.playerPosZ(object) != -1) + { + double posX = JewelryNBT.playerPosX(object), posY = JewelryNBT.playerPosY(object), posZ = JewelryNBT.playerPosZ(object); + int dimension = JewelryNBT.dimension(object); + for(int i = 0; i < entitiesN.size(); i++) + { + EntityLivingBase entity = (EntityLivingBase) entitiesN.get(i); + if (!JewelryNBT.isDimensionX(object, entity.dimension) && JewelryNBT.isModifierX(object, new ItemStack(Items.bed))){ + entity.travelToDimension(dimension); + entity.setPositionAndUpdate(posX, posY, posZ); + } + else if(JewelryNBT.isDimensionX(object, entity.dimension)) entity.setPositionAndUpdate(posX, posY, posZ); + } + } + if (JewelryNBT.isModifierX(object, new ItemStack(Items.dye, 1, 15))) + { + for(int i=-3; i<=3; i++) + for(int j=-1; j<=1; j++) + for(int k=-3; k<=3; k++) + { + //if(worldObj.getBlockId(xCoord + i, yCoord + j, zCoord + k) == Block.dirt.blockID && (worldObj.getBlockId(xCoord + i, yCoord + j + 1, zCoord + k) == 0 || worldObj.getBlockId(xCoord + i, yCoord + j + 1, zCoord + k) == Block.crops.blockID) || worldObj.getBlockId(xCoord + i, yCoord + j + 1, zCoord + k) == Block.potato.blockID) worldObj.setBlock(xCoord + i, yCoord + j, zCoord + k, Block.tilledField.blockID); + if(worldObj.getBlock(xCoord + i, yCoord + j, zCoord + k) == Blocks.farmland) worldObj.setBlockMetadataWithNotify(xCoord + i, yCoord + j, zCoord + k, 1, 7); + if(worldObj.getBlock(xCoord + i, yCoord + j, zCoord + k) != Blocks.farmland) worldObj.scheduleBlockUpdate(xCoord + i, yCoord + j, zCoord + k, worldObj.getBlock(xCoord + i, yCoord + j, zCoord + k), 5); + //JewelrycraftUtil.applyBonemeal(object, worldObj, xCoord + i, yCoord + j, zCoord + k, player); + } + } + } + } + } + + public Packet getDescriptionPacket() + { + NBTTagCompound nbttagcompound = new NBTTagCompound(); + this.writeToNBT(nbttagcompound); + return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 1, nbttagcompound); + } + + @Override + public void onDataPacket (NetworkManager net, S35PacketUpdateTileEntity packet) + { + readFromNBT(packet.func_148857_g()); + worldObj.func_147479_m(xCoord, yCoord, zCoord); + } +} diff --git a/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityBlockShadow.java b/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityBlockShadow.java new file mode 100644 index 0000000..186f78a --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityBlockShadow.java @@ -0,0 +1,74 @@ +package darkknight.jewelrycraft.tileentity; + +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.NetworkManager; +import net.minecraft.network.Packet; +import net.minecraft.network.play.server.S35PacketUpdateTileEntity; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.MathHelper; +import net.minecraft.world.EnumSkyBlock; + +public class TileEntityBlockShadow extends TileEntity +{ + public int metadata; + + public TileEntityBlockShadow() + { + this.metadata = -1; + } + + @Override + public void writeToNBT(NBTTagCompound nbt) + { + super.writeToNBT(nbt); + nbt.setInteger("metadata", metadata); + } + + @Override + public void readFromNBT(NBTTagCompound nbt) + { + super.readFromNBT(nbt); + this.metadata = nbt.getInteger("metadata"); + } + + @Override + public void updateEntity() + { + super.updateEntity(); + int blockLight, realLight; + int lightValue = worldObj.getSavedLightValue(EnumSkyBlock.Sky, xCoord, yCoord, zCoord) - worldObj.skylightSubtracted; + float sunPosAngle = worldObj.getCelestialAngleRadians(1.0F); + + if (sunPosAngle < (float)Math.PI) sunPosAngle += (0.0F - sunPosAngle) * 0.2F; + else sunPosAngle += (((float)Math.PI * 2F) - sunPosAngle) * 0.2F; + + lightValue = Math.round((float)lightValue * MathHelper.cos(sunPosAngle)); + + if (lightValue < 0) lightValue = 0; + if (lightValue > 15) lightValue = 15; + + blockLight = worldObj.getChunkFromBlockCoords(xCoord, zCoord).getSavedLightValue(EnumSkyBlock.Block, xCoord & 15, yCoord, zCoord & 15); + realLight = worldObj.getChunkFromBlockCoords(xCoord, zCoord).getBlockLightValue(xCoord & 15, yCoord, zCoord & 15, 0); + + if((blockLight == 0 && worldObj.canBlockSeeTheSky(xCoord, yCoord, zCoord)) || (lightValue >= blockLight)) metadata = 15 - lightValue; + else if(!worldObj.canBlockSeeTheSky(xCoord, yCoord, zCoord)) metadata = 15 - realLight; + else if(lightValue < blockLight) metadata = 15 - blockLight; + + worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, metadata, 2); + worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); + } + + public Packet getDescriptionPacket() + { + NBTTagCompound nbttagcompound = new NBTTagCompound(); + this.writeToNBT(nbttagcompound); + return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 1, nbttagcompound); + } + + @Override + public void onDataPacket (NetworkManager net, S35PacketUpdateTileEntity packet) + { + readFromNBT(packet.func_148857_g()); + worldObj.func_147479_m(xCoord, yCoord, zCoord); + } +} diff --git a/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityDisplayer.java b/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityDisplayer.java new file mode 100644 index 0000000..35def5c --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityDisplayer.java @@ -0,0 +1,108 @@ +package darkknight.jewelrycraft.tileentity; + +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.NetworkManager; +import net.minecraft.network.Packet; +import net.minecraft.network.play.server.S35PacketUpdateTileEntity; +import net.minecraft.tileentity.TileEntity; + +public class TileEntityDisplayer extends TileEntity +{ + public float ringTranslation1, ringTranslation2, ringTranslation3, rotAngle; + public boolean isDescending1, isDescending2, isDescending3, isDirty, hasObject; + public ItemStack object; + public int quantity; + + public TileEntityDisplayer() + { + this.ringTranslation1 = 0; + this.ringTranslation2 = 0; + this.ringTranslation3 = 0; + this.rotAngle = 0; + this.quantity = 0; + this.isDescending1 = false; + this.isDescending2 = false; + this.isDescending3 = false; + this.isDirty = false; + this.hasObject = false; + this.object = new ItemStack(Item.getItemById(0), 0, 0); + } + + @Override + public void writeToNBT(NBTTagCompound nbt) + { + super.writeToNBT(nbt); + nbt.setFloat("translation1", ringTranslation1); + nbt.setFloat("translation2", ringTranslation2); + nbt.setFloat("translation3", ringTranslation3); + nbt.setFloat("angle", rotAngle); + nbt.setInteger("quantity", quantity); + nbt.setBoolean("descending1", isDescending1); + nbt.setBoolean("descending2", isDescending2); + nbt.setBoolean("descending3", isDescending3); + nbt.setBoolean("hasObject", hasObject); + NBTTagCompound tag = new NBTTagCompound(); + this.object.writeToNBT(tag); + nbt.setTag("object", tag); + } + + @Override + public void readFromNBT(NBTTagCompound nbt) + { + super.readFromNBT(nbt); + this.ringTranslation1 = nbt.getFloat("translation1"); + this.ringTranslation2 = nbt.getFloat("translation2"); + this.ringTranslation3 = nbt.getFloat("translation3"); + this.rotAngle = nbt.getFloat("angle"); + this.quantity = nbt.getInteger("quantity"); + this.isDescending1 = nbt.getBoolean("descending1"); + this.isDescending2 = nbt.getBoolean("descending2"); + this.isDescending3 = nbt.getBoolean("descending3"); + this.hasObject = nbt.getBoolean("hasObject"); + this.object = new ItemStack(Item.getItemById(0), 0, 0); + this.object.readFromNBT(nbt.getCompoundTag("object")); + } + + @Override + public void updateEntity() + { + super.updateEntity(); + if(isDirty) + { + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + isDirty = false; + } + if(ringTranslation1 >= 0.6) isDescending1 = true; + if(ringTranslation1 <= 0) isDescending1 = false; + if(!isDescending1) ringTranslation1 += 0.05; + if(isDescending1) ringTranslation1 -= 0.05; + + if(ringTranslation2 >= 0.6) isDescending2 = true; + if(ringTranslation2 <= 0) isDescending2 = false; + if(!isDescending2) ringTranslation2 += 0.04; + if(isDescending2) ringTranslation2 -= 0.04; + + if(ringTranslation3 >= 0.6) isDescending3 = true; + if(ringTranslation3 <= 0) isDescending3 = false; + if(!isDescending3) ringTranslation3 += 0.03; + if(isDescending3) ringTranslation3 -= 0.03; + if(rotAngle < 360F) rotAngle += 6F; + if(rotAngle>=360F) rotAngle = 0F; + } + + public Packet getDescriptionPacket() + { + NBTTagCompound nbttagcompound = new NBTTagCompound(); + this.writeToNBT(nbttagcompound); + return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 1, nbttagcompound); + } + + @Override + public void onDataPacket (NetworkManager net, S35PacketUpdateTileEntity packet) + { + readFromNBT(packet.func_148857_g()); + worldObj.func_147479_m(xCoord, yCoord, zCoord); + } +} diff --git a/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityJewelrsCraftingTable.java b/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityJewelrsCraftingTable.java new file mode 100644 index 0000000..13b689d --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityJewelrsCraftingTable.java @@ -0,0 +1,141 @@ +package darkknight.jewelrycraft.tileentity; + +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.NetworkManager; +import net.minecraft.network.Packet; +import net.minecraft.network.play.server.S35PacketUpdateTileEntity; +import net.minecraft.tileentity.TileEntity; +import darkknight.jewelrycraft.config.ConfigHandler; +import darkknight.jewelrycraft.util.JewelryNBT; + +public class TileEntityJewelrsCraftingTable extends TileEntity +{ + public boolean hasJewelry, hasModifier, hasEndItem, isDirty, hasJewel; + public ItemStack jewelry, modifier, endItem, jewel; + public int timer, effect; + public float angle; + + public TileEntityJewelrsCraftingTable() + { + this.jewelry = new ItemStack(Item.getItemById(0), 0, 0); + this.modifier = new ItemStack(Item.getItemById(0), 0, 0); + this.endItem = new ItemStack(Item.getItemById(0), 0, 0); + this.jewel = new ItemStack(Item.getItemById(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.setTag("jewelry", tag); + this.modifier.writeToNBT(tag1); + nbt.setTag("modifier", tag1); + this.endItem.writeToNBT(tag2); + nbt.setTag("endItem", tag2); + this.jewel.writeToNBT(tag3); + nbt.setTag("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(Item.getItemById(0), 0, 0); + this.jewelry.readFromNBT(nbt.getCompoundTag("jewelry")); + this.modifier = new ItemStack(Item.getItemById(0), 0, 0); + this.modifier.readFromNBT(nbt.getCompoundTag("modifier")); + this.endItem = new ItemStack(Item.getItemById(0), 0, 0); + this.endItem.readFromNBT(nbt.getCompoundTag("endItem")); + this.jewel = new ItemStack(Item.getItemById(0), 0, 0); + this.jewel.readFromNBT(nbt.getCompoundTag("jewel")); + } + + @Override + public void updateEntity() + { + super.updateEntity(); + if(isDirty){ + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + isDirty = false; + } + 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(Item.getItemById(0), 0, 0)) JewelryNBT.addModifier(endItem, modifier); + if (hasJewel && jewel != new ItemStack(Item.getItemById(0), 0, 0)) JewelryNBT.addJewel(endItem, jewel); + if (hasJewel && hasModifier && JewelryNBT.isJewelX(endItem, new ItemStack(Items.nether_star)) && JewelryNBT.isModifierX(endItem, new ItemStack(Items.book))) JewelryNBT.addMode(endItem, "Disenchant"); + if (hasModifier && JewelryNBT.isModifierEffectType(endItem)) JewelryNBT.addMode(endItem, "Activated"); + this.hasJewelry = false; + this.jewelry = new ItemStack(Item.getItemById(0), 0, 0); + this.hasModifier = false; + this.modifier = new ItemStack(Item.getItemById(0), 0, 0); + this.hasJewel = false; + this.jewel = new ItemStack(Item.getItemById(0), 0, 0); + timer = -1; + } + } + } + + public Packet getDescriptionPacket() + { + NBTTagCompound nbttagcompound = new NBTTagCompound(); + this.writeToNBT(nbttagcompound); + return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 1, nbttagcompound); + } + + @Override + public void onDataPacket (NetworkManager net, S35PacketUpdateTileEntity packet) + { + readFromNBT(packet.func_148857_g()); + worldObj.func_147479_m(xCoord, yCoord, zCoord); + } +} diff --git a/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityMolder.java b/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityMolder.java new file mode 100644 index 0000000..e985f6f --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityMolder.java @@ -0,0 +1,125 @@ +package darkknight.jewelrycraft.tileentity; + +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.NetworkManager; +import net.minecraft.network.Packet; +import net.minecraft.network.play.server.S35PacketUpdateTileEntity; +import net.minecraft.tileentity.TileEntity; +import darkknight.jewelrycraft.item.ItemList; +import darkknight.jewelrycraft.util.JewelryNBT; + +public class TileEntityMolder extends TileEntity +{ + public int cooling; + public boolean hasMoltenMetal, hasJewelBase, hasMold, isDirty; + public ItemStack mold, jewelBase, moltenMetal, ringMetal; + + public TileEntityMolder() + { + this.moltenMetal = new ItemStack(Item.getItemById(0), 0, 0); + this.jewelBase = new ItemStack(Item.getItemById(0), 0, 0); + this.mold = new ItemStack(Item.getItemById(0), 0, 0); + this.ringMetal = new ItemStack(Item.getItemById(0), 0, 0); + this.cooling = 0; + this.hasJewelBase = false; + this.hasMoltenMetal = false; + this.hasMold = false; + this.isDirty = false; + } + + @Override + public void writeToNBT(NBTTagCompound nbt) + { + super.writeToNBT(nbt); + nbt.setInteger("cooling", cooling); + nbt.setBoolean("hasJewelBase", hasJewelBase); + nbt.setBoolean("hasMoltenMetal", hasMoltenMetal); + nbt.setBoolean("hasMold", hasMold); + NBTTagCompound tag = new NBTTagCompound(); + NBTTagCompound tag1 = new NBTTagCompound(); + NBTTagCompound tag2 = new NBTTagCompound(); + NBTTagCompound tag3 = new NBTTagCompound(); + this.mold.writeToNBT(tag); + nbt.setTag("mold", tag); + this.jewelBase.writeToNBT(tag1); + nbt.setTag("jewelBase", tag1); + this.moltenMetal.writeToNBT(tag2); + nbt.setTag("moltenMetal", tag2); + this.ringMetal.writeToNBT(tag3); + nbt.setTag("ringMetal", tag3); + } + + @Override + public void readFromNBT(NBTTagCompound nbt) + { + super.readFromNBT(nbt); + this.cooling = nbt.getInteger("cooling"); + this.hasJewelBase = nbt.getBoolean("hasJewelBase"); + this.hasMoltenMetal = nbt.getBoolean("hasMoltenMetal"); + this.hasMold = nbt.getBoolean("hasMold"); + this.mold = new ItemStack(Item.getItemById(0), 0, 0); + this.mold.readFromNBT(nbt.getCompoundTag("mold")); + this.jewelBase = new ItemStack(Item.getItemById(0), 0, 0); + this.jewelBase.readFromNBT(nbt.getCompoundTag("jewelBase")); + this.moltenMetal = new ItemStack(Item.getItemById(0), 0, 0); + this.moltenMetal.readFromNBT(nbt.getCompoundTag("moltenMetal")); + this.ringMetal = new ItemStack(Item.getItemById(0), 0, 0); + this.ringMetal.readFromNBT(nbt.getCompoundTag("ringMetal")); + } + + @Override + public void updateEntity() + { + super.updateEntity(); + if(isDirty){ + this.markDirty(); + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + isDirty = false; + } + if (moltenMetal.getItem() != Item.getItemById(0)) + { + if(worldObj.rand.nextInt(20) == 0) this.worldObj.playSoundEffect(xCoord, yCoord + 0.5F, zCoord, "random.fizz", 0.5F, 1F); + for (int l = 0; l < 2; ++l) + this.worldObj.spawnParticle("reddust", xCoord + Math.random(), (double) yCoord + 0.2F, zCoord + Math.random(), 0.0D, 1.0D, 1.0D); + } + if (this.hasMoltenMetal && !this.hasJewelBase) + { + ringMetal = moltenMetal; + if (cooling > 0) + this.cooling--; + if (cooling == 0) + { + this.hasMoltenMetal = false; + if (mold.getItemDamage() == 0) + this.jewelBase = moltenMetal; + else if (mold.getItemDamage() == 1) + this.jewelBase = new ItemStack(ItemList.ring); + else + this.jewelBase = new ItemStack(ItemList.necklace); + if(mold.getItemDamage() != 0 && jewelBase != new ItemStack(Item.getItemById(0), 0, 0)) + JewelryNBT.addMetal(jewelBase, ringMetal); + this.moltenMetal = new ItemStack(Item.getItemById(0), 0, 0); + this.hasJewelBase = true; + cooling = -1; + this.isDirty = true; + this.markDirty(); + } + } + } + + public Packet getDescriptionPacket() + { + NBTTagCompound nbttagcompound = new NBTTagCompound(); + this.writeToNBT(nbttagcompound); + return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 1, nbttagcompound); + } + + @Override + public void onDataPacket (NetworkManager net, S35PacketUpdateTileEntity packet) + { + readFromNBT(packet.func_148857_g()); + worldObj.func_147479_m(xCoord, yCoord, zCoord); + } +} diff --git a/src/main/java/darkknight/jewelrycraft/tileentity/TileEntitySmelter.java b/src/main/java/darkknight/jewelrycraft/tileentity/TileEntitySmelter.java new file mode 100644 index 0000000..53a9f82 --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/tileentity/TileEntitySmelter.java @@ -0,0 +1,125 @@ +package darkknight.jewelrycraft.tileentity; + +import java.util.Random; + +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.NetworkManager; +import net.minecraft.network.Packet; +import net.minecraft.network.play.server.S35PacketUpdateTileEntity; +import net.minecraft.tileentity.TileEntity; + +public class TileEntitySmelter extends TileEntity +{ + public int melting, flow, n = 0, p = 0; + public boolean hasMetal, hasMoltenMetal, isDirty; + public ItemStack metal, moltenMetal; + + public TileEntitySmelter() + { + this.melting = 0; + this.flow = 0; + this.hasMetal = false; + this.hasMoltenMetal = false; + this.metal = new ItemStack(Item.getItemById(0), 0, 0); + this.moltenMetal = new ItemStack(Item.getItemById(0), 0, 0); + this.isDirty = false; + } + + @Override + public void writeToNBT(NBTTagCompound nbt) + { + super.writeToNBT(nbt); + nbt.setInteger("melting", melting); + nbt.setBoolean("hasMetal", hasMetal); + nbt.setBoolean("hasMoltenMetal", hasMoltenMetal); + NBTTagCompound tag = new NBTTagCompound(); + NBTTagCompound tag1 = new NBTTagCompound(); + this.metal.writeToNBT(tag); + nbt.setTag("metal", tag); + this.moltenMetal.writeToNBT(tag1); + nbt.setTag("moltenMetal", tag1); + } + + @Override + public void readFromNBT(NBTTagCompound nbt) + { + super.readFromNBT(nbt); + this.melting = nbt.getInteger("melting"); + this.hasMetal = nbt.getBoolean("hasMetal"); + this.hasMoltenMetal = nbt.getBoolean("hasMoltenMetal"); + this.metal = new ItemStack(Item.getItemById(0), 0, 0); + this.metal.readFromNBT(nbt.getCompoundTag("metal")); + this.moltenMetal = new ItemStack(Item.getItemById(0), 0, 0); + this.moltenMetal.readFromNBT(nbt.getCompoundTag("moltenMetal")); + } + + @Override + public void updateEntity() + { + super.updateEntity(); + Random rand = new Random(); + if(isDirty){ + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + isDirty = false; + } + if (p > 0) + --p; + else + p = 5; + if (n == 0 && p == 0) + { + flow += 16; + if (flow >= 16 * 20) + n = 1; + } + if (n == 1 && p == 0) + { + flow -= 16; + if (flow <= 0) + n = 0; + } + if (this.hasMetal) + { + for (int l = 0; l < 2; ++l) + this.worldObj.spawnParticle("flame", xCoord + rand.nextFloat(), (double) yCoord + 0.3F, zCoord + rand.nextFloat(), 0.0D, 0.0D, 0.0D); + } + if (rand.nextInt(65) == 0) + { + double d5 = this.xCoord + rand.nextFloat(); + double d7 = this.yCoord; + double d6 = this.zCoord + rand.nextFloat(); + this.worldObj.playSound(d5, d7, d6, "liquid.lavapop", 0.2F + rand.nextFloat() * 0.2F, 0.9F + rand.nextFloat() * 0.15F, false); + } + if (this.hasMetal) + { + if (melting > 0) + this.melting--; + if (melting == 0) + { + this.hasMetal = false; + this.moltenMetal = metal; + this.metal = new ItemStack(Item.getItemById(0), 0, 0); + this.hasMoltenMetal = true; + melting = -1; + this.isDirty = true; + this.markDirty(); + } + } + } + + public Packet getDescriptionPacket() + { + NBTTagCompound nbttagcompound = new NBTTagCompound(); + this.writeToNBT(nbttagcompound); + return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 1, nbttagcompound); + } + + @Override + public void onDataPacket (NetworkManager net, S35PacketUpdateTileEntity packet) + { + readFromNBT(packet.func_148857_g()); + worldObj.func_147479_m(xCoord, yCoord, zCoord); + } +} diff --git a/src/main/java/darkknight/jewelrycraft/util/BlockUtils.java b/src/main/java/darkknight/jewelrycraft/util/BlockUtils.java new file mode 100644 index 0000000..a5f7684 --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/util/BlockUtils.java @@ -0,0 +1,122 @@ +package darkknight.jewelrycraft.util; + + +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.MathHelper; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; + +public class BlockUtils +{ + + public static final ForgeDirection DEFAULT_BLOCK_DIRECTION = ForgeDirection.WEST; + + public static ForgeDirection get2dOrientation(EntityLivingBase entity) + { + int l = MathHelper.floor_double(entity.rotationYaw * 4.0F / 360.0F + 0.5D) & 0x3; + switch (l) { + case 0: + return ForgeDirection.SOUTH; + case 1: + return ForgeDirection.WEST; + case 2: + return ForgeDirection.NORTH; + case 3: + return ForgeDirection.EAST; + } + return ForgeDirection.SOUTH; + + } + + public static float getRotationFromDirection(ForgeDirection direction) { + switch (direction) { + case NORTH: + return 0F; + case SOUTH: + return 180F; + case WEST: + return 90F; + case EAST: + return -90F; + case DOWN: + return -90f; + case UP: + return 90f; + default: + return 0f; + } + } + + public static ForgeDirection get3dOrientation(EntityLivingBase entity) { + if (entity.rotationPitch > 45.5F) { + return ForgeDirection.DOWN; + } else if (entity.rotationPitch < -45.5F) { return ForgeDirection.UP; } + return get2dOrientation(entity); + } + + public static EntityItem dropItemStackInWorld(World worldObj, double x, double y, double z, ItemStack stack) { + float f = 0.7F; + float d0 = worldObj.rand.nextFloat() * f + (1.0F - f) * 0.5F; + float d1 = worldObj.rand.nextFloat() * f + (1.0F - f) * 0.5F; + float d2 = worldObj.rand.nextFloat() * f + (1.0F - f) * 0.5F; + EntityItem entityitem = new EntityItem(worldObj, x + d0, y + d1, z + d2, stack); + entityitem.delayBeforeCanPickup = 10; + if (stack.hasTagCompound()) { + entityitem.getEntityItem().setTagCompound((NBTTagCompound)stack.getTagCompound().copy()); + } + worldObj.spawnEntityInWorld(entityitem); + return entityitem; + } + + public static EntityItem ejectItemInDirection(World world, double x, double y, double z, ForgeDirection direction, ItemStack stack) { + EntityItem item = BlockUtils.dropItemStackInWorld(world, x, y, z, stack); + item.motionX = direction.offsetX / 5F; + item.motionY = direction.offsetY / 5F; + item.motionZ = direction.offsetZ / 5F; + return item; + } + + public static void dropInventory(IInventory inventory, World world, double x, double y, double z) { + if (inventory == null) { return; } + for (int i = 0; i < inventory.getSizeInventory(); ++i) { + ItemStack itemStack = inventory.getStackInSlot(i); + if (itemStack != null) { + dropItemStackInWorld(world, x, y, z, itemStack); + } + } + } + + public static void dropInventory(IInventory inventory, World world, int x, int y, int z) { + dropInventory(inventory, world, x + 0.5, y + 0.5, z + 0.5); + } + + public static TileEntity getTileInDirection(TileEntity tile, ForgeDirection direction) { + int targetX = tile.xCoord + direction.offsetX; + int targetY = tile.yCoord + direction.offsetY; + int targetZ = tile.zCoord + direction.offsetZ; + return tile.getWorldObj().getTileEntity(targetX, targetY, targetZ); + } + + public static int getFirstNonAirBlockFromTop(World world, int x, int z) { + int y; + for (y = world.getActualHeight(); world.isAirBlock(x, y - 1, z) && y > 0; y--) {} + return y; + } + + public static boolean isBlockHit(MovingObjectPosition mop, TileEntity tile) { + if (tile == null) return false; + return isBlockHit(mop, tile.xCoord, tile.yCoord, tile.zCoord); + } + + public static boolean isBlockHit(MovingObjectPosition mop, int x, int y, int z) { + if (mop == null) return false; + return mop.blockX == x && mop.blockY == y && mop.blockZ == z; + } + +}
\ No newline at end of file diff --git a/src/main/java/darkknight/jewelrycraft/util/JewelryNBT.java b/src/main/java/darkknight/jewelrycraft/util/JewelryNBT.java new file mode 100644 index 0000000..d76c84e --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/util/JewelryNBT.java @@ -0,0 +1,626 @@ +package darkknight.jewelrycraft.util; + +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.entity.EntityList; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; + +public class JewelryNBT +{ + //TODO NBT Tag Adding + /** + * + * @param item The item you want to add the NBT data on + * @param metal The metal you want to add on the item + */ + public static void addMetal(ItemStack item, ItemStack metal) + { + NBTTagCompound itemStackData; + if (item.hasTagCompound()) + itemStackData = item.getTagCompound(); + else + { + itemStackData = new NBTTagCompound(); + item.setTagCompound(itemStackData); + } + NBTTagCompound ingotNBT = new NBTTagCompound(); + metal.writeToNBT(ingotNBT); + itemStackData.setTag("ingot", ingotNBT); + } + + /** + * + * @param item The item you want to add the NBT data on + * @param jewel The jewel you want to add on the item + */ + public static void addJewel(ItemStack item, ItemStack jewel) + { + if(jewel != null) + { + NBTTagCompound itemStackData; + if (item.hasTagCompound()) + itemStackData = item.getTagCompound(); + else + { + itemStackData = new NBTTagCompound(); + item.setTagCompound(itemStackData); + } + NBTTagCompound jewelNBT = new NBTTagCompound(); + jewel.writeToNBT(jewelNBT); + itemStackData.setTag("jewel", jewelNBT); + } + } + + /** + * + * @param item The item you want to add the NBT data on + * @param modifier The modifier you want to add on the item + */ + public static void addModifier(ItemStack item, ItemStack modifier) + { + if(modifier != null) + { + NBTTagCompound itemStackData; + if (item.hasTagCompound()) + itemStackData = item.getTagCompound(); + else + { + itemStackData = new NBTTagCompound(); + item.setTagCompound(itemStackData); + } + NBTTagCompound modifierNBT = new NBTTagCompound(); + modifier.writeToNBT(modifierNBT); + itemStackData.setTag("modifier", modifierNBT); + } + } + + public static void addEntity(ItemStack item, EntityLivingBase entity) + { + NBTTagCompound itemStackData; + if (item.hasTagCompound()) + itemStackData = item.getTagCompound(); + else + { + itemStackData = new NBTTagCompound(); + item.setTagCompound(itemStackData); + } + NBTTagCompound entityNBT = new NBTTagCompound(); + entity.writeToNBT(entityNBT); + itemStackData.setTag("entity", entityNBT); + } + + public static void addEntityID(ItemStack item, EntityLivingBase entity) + { + NBTTagCompound itemStackData; + if (item.hasTagCompound()) + itemStackData = item.getTagCompound(); + else + { + itemStackData = new NBTTagCompound(); + item.setTagCompound(itemStackData); + } + NBTTagCompound entityNBT = new NBTTagCompound(); + int id = EntityList.getEntityID(entity); + entityNBT.setInteger("entityID", id); + itemStackData.setTag("entityID", entityNBT); + } + + public static void addCoordonates(ItemStack item, double x, double y, double z) + { + NBTTagCompound itemStackData; + if (item.hasTagCompound()) + itemStackData = item.getTagCompound(); + else + { + itemStackData = new NBTTagCompound(); + item.setTagCompound(itemStackData); + } + NBTTagCompound coords = new NBTTagCompound(); + coords.setDouble("x", x); + coords.setDouble("y", y); + coords.setDouble("z", z); + itemStackData.setTag("x", coords); + itemStackData.setTag("y", coords); + itemStackData.setTag("z", coords); + } + + public static void addTileEntityBlock(ItemStack item, World world, int x, int y, int z) + { + NBTTagCompound itemStackData; + if (item.hasTagCompound()) + itemStackData = item.getTagCompound(); + else + { + itemStackData = new NBTTagCompound(); + item.setTagCompound(itemStackData); + } + NBTTagCompound tileNBT = new NBTTagCompound(); + NBTTagCompound block = new NBTTagCompound(); + world.getTileEntity(x, y, z).writeToNBT(tileNBT); + itemStackData.setTag("tile", tileNBT); + block.setInteger("blockID", Block.getIdFromBlock(world.getBlock(x, y, z))); + block.setInteger("metadata", world.getBlockMetadata(x, y, z)); + block.setInteger("blockX", x); + block.setInteger("blockY", y); + block.setInteger("blockZ", z); + itemStackData.setTag("metadata", block); + itemStackData.setTag("blockID", block); + itemStackData.setTag("blockX", block); + itemStackData.setTag("blockY", block); + itemStackData.setTag("blockZ", block); + } + + public static void addBlock(ItemStack item, int block, int metadata) + { + NBTTagCompound itemStackData; + if (item.hasTagCompound()) + itemStackData = item.getTagCompound(); + else + { + itemStackData = new NBTTagCompound(); + item.setTagCompound(itemStackData); + } + NBTTagCompound blockNBT = new NBTTagCompound(); + blockNBT.setInteger("blockID", block); + itemStackData.setTag("blockID", blockNBT); + blockNBT.setInteger("metadata", metadata); + itemStackData.setTag("metadata", blockNBT); + } + + public static void addBlockCoordonates(ItemStack item, int x, int y, int z) + { + NBTTagCompound itemStackData; + if (item.hasTagCompound()) + itemStackData = item.getTagCompound(); + else + { + itemStackData = new NBTTagCompound(); + item.setTagCompound(itemStackData); + } + NBTTagCompound coords = new NBTTagCompound(); + coords.setInteger("blockX", x); + coords.setInteger("blockY", y); + coords.setInteger("blockZ", z); + itemStackData.setTag("blockX", coords); + itemStackData.setTag("blockY", coords); + itemStackData.setTag("blockZ", coords); + } + + public static void addCoordonatesAndDimension(ItemStack item, double x, double y, double z, int dim, String name) + { + NBTTagCompound itemStackData; + if (item.hasTagCompound()) + itemStackData = item.getTagCompound(); + else + { + itemStackData = new NBTTagCompound(); + item.setTagCompound(itemStackData); + } + NBTTagCompound coords = new NBTTagCompound(); + coords.setDouble("x", x); + coords.setDouble("y", y); + coords.setDouble("z", z); + coords.setInteger("dimension", dim); + coords.setString("dimName", name); + itemStackData.setTag("x", coords); + itemStackData.setTag("y", coords); + itemStackData.setTag("z", coords); + itemStackData.setTag("dimension", coords); + itemStackData.setTag("dimName", coords); + } + + public static void addMode(ItemStack item, String modeN) + { + NBTTagCompound itemStackData; + if (item.hasTagCompound()) + itemStackData = item.getTagCompound(); + else + { + itemStackData = new NBTTagCompound(); + item.setTagCompound(itemStackData); + } + NBTTagCompound mode = new NBTTagCompound(); + mode.setString("mode", modeN); + itemStackData.setTag("mode", mode); + } + + public static void addFakeEnchantment(ItemStack item) + { + NBTTagCompound itemStackData; + if (item.hasTagCompound()) + itemStackData = item.getTagCompound(); + else + { + itemStackData = new NBTTagCompound(); + item.setTagCompound(itemStackData); + } + itemStackData.setTag("ench", new NBTTagList()); + } + + 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 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); + } + + @SuppressWarnings("rawtypes") + public static void addEntities(ItemStack item, List list) + { + NBTTagCompound itemStackData; + if (item.hasTagCompound()) + itemStackData = item.getTagCompound(); + else + { + itemStackData = new NBTTagCompound(); + item.setTagCompound(itemStackData); + } + NBTTagCompound entityNBT = new NBTTagCompound(); + for(int i=0; i < list.size(); i++) ((EntityLivingBase) list.get(i)).writeToNBT(entityNBT); + itemStackData.setTag("entities", entityNBT); + } + + //TODO NBT Tag Removing + public static void removeNBT(ItemStack item, String tag) + { + NBTTagCompound itemStackData; + if (item.hasTagCompound()) + itemStackData = item.getTagCompound(); + else + { + itemStackData = new NBTTagCompound(); + item.setTagCompound(itemStackData); + } + itemStackData.removeTag(tag); + } + + public static void removeEntity(ItemStack item) + { + JewelryNBT.removeNBT(item, "entityID"); + JewelryNBT.removeNBT(item, "entity"); + JewelryNBT.removeNBT(item, "ench"); + } + + public static void removeBlock(ItemStack item) + { + JewelryNBT.removeNBT(item, "blockID"); + JewelryNBT.removeNBT(item, "metadata"); + JewelryNBT.removeNBT(item, "tile"); + JewelryNBT.removeNBT(item, "blockX"); + JewelryNBT.removeNBT(item, "blockY"); + JewelryNBT.removeNBT(item, "blockZ"); + } + + //TODO NTB Tag Checking + public static boolean hasTag(ItemStack item, String tag) + { + NBTTagCompound itemStackData; + if (item.hasTagCompound()) + itemStackData = item.getTagCompound(); + else + { + itemStackData = new NBTTagCompound(); + item.setTagCompound(itemStackData); + } + if(itemStackData.hasKey(tag)) return true; + return false; + } + + public static boolean isJewelX(ItemStack stack, ItemStack jewel) + { + if(jewel(stack) != null && jewel(stack).getItem() == jewel.getItem() && jewel(stack).getItemDamage() == jewel.getItemDamage()) return true; + return false; + } + + public static boolean isModifierX(ItemStack stack, ItemStack modifier) + { + if(modifier(stack) != null && modifier(stack).getItem() == modifier.getItem() && modifier(stack).getItemDamage() == modifier.getItemDamage()) return true; + return false; + } + + public static boolean isModifierEffectType(ItemStack stack) + { + if(modifier(stack) != null && (isModifierX(stack, new ItemStack(Items.blaze_powder)) || isModifierX(stack, new ItemStack(Items.sugar)) + || isModifierX(stack, new ItemStack(Items.iron_pickaxe)) || isModifierX(stack, new ItemStack(Items.feather)) + || isModifierX(stack, new ItemStack(Items.potionitem, 1, 8270)))) return true; + return false; + } + + public static boolean isIngotX(ItemStack stack, ItemStack ingot) + { + if(ingot(stack) != null && ingot(stack).getItem() == ingot.getItem() && ingot(stack).getItemDamage() == ingot.getItemDamage()) return true; + return false; + } + + public static boolean isModeX(ItemStack stack, String modeN) + { + if(modeName(stack) != null && modeName(stack).equals(modeN)) return true; + return false; + } + + public static boolean isEntityX(ItemStack stack, EntityPlayer player, EntityLivingBase entity) + { + if(entity != null && entity instanceof EntityLivingBase && entity(stack, player) != null && entity(stack, player).equals(entity)) return true; + return false; + } + + public static boolean isDimNameX(ItemStack stack, String dimName) + { + if(ingot(stack) != null && dimName(stack).equals(dimName)) return true; + return false; + } + + public static boolean isDimensionX(ItemStack stack, int dimension) + { + if(dimension(stack) != -2 && dimension(stack) == dimension) return true; + return false; + } + + //TODO Return components based on NBT + + public static ItemStack jewel(ItemStack stack) + { + if(stack != null && stack != new ItemStack(Item.getItemById(0), 0, 0) && stack.hasTagCompound() && stack.getTagCompound().hasKey("jewel")) + { + NBTTagCompound jewelNBT = (NBTTagCompound) stack.getTagCompound().getTag("jewel"); + ItemStack jewel = new ItemStack(Item.getItemById(0), 0, 0); + jewel.readFromNBT(jewelNBT); + return jewel; + } + return null; + } + + public static ItemStack modifier(ItemStack stack) + { + if(stack != null && stack != new ItemStack(Item.getItemById(0), 0, 0) && stack.hasTagCompound() && stack.getTagCompound().hasKey("modifier")) + { + NBTTagCompound modifierNBT = (NBTTagCompound) stack.getTagCompound().getTag("modifier"); + ItemStack modifier = new ItemStack(Item.getItemById(0), 0, 0); + modifier.readFromNBT(modifierNBT); + return modifier; + } + return null; + } + + public static ItemStack ingot(ItemStack stack) + { + if(stack != null && stack != new ItemStack(Item.getItemById(0), 0, 0) && stack.hasTagCompound() && stack.getTagCompound().hasKey("ingot")) + { + NBTTagCompound ingotNBT = (NBTTagCompound) stack.getTagCompound().getTag("ingot"); + ItemStack ingot = new ItemStack(Item.getItemById(0), 0, 0); + ingot.readFromNBT(ingotNBT); + return ingot; + } + return null; + } + + public static EntityLivingBase entity(ItemStack stack, EntityPlayer player) + { + if (stack != null && stack != new ItemStack(Item.getItemById(0), 0, 0) && stack.getTagCompound().hasKey("entityID") && stack.getTagCompound().hasKey("entity")) + { + NBTTagCompound enID = (NBTTagCompound) stack.getTagCompound().getTag("entityID"); + NBTTagCompound en = (NBTTagCompound) stack.getTagCompound().getTag("entity"); + int entityID = 0; + entityID = enID.getInteger("entityID"); + EntityLivingBase entity = (EntityLivingBase) EntityList.createEntityByID(entityID, player.worldObj); + if(entity != null && entity instanceof EntityLivingBase) + { + entity.readFromNBT(en); + return entity; + } + else return null; + } + return null; + } + + public static TileEntity tileEntity(ItemStack stack) + { + if (stack != null && stack != new ItemStack(Item.getItemById(0), 0, 0) && stack.getTagCompound().hasKey("tile")) + { + NBTTagCompound tileNBT = (NBTTagCompound) stack.getTagCompound().getTag("tile"); + TileEntity tile = (TileEntity) TileEntity.createAndLoadEntity(tileNBT); + if(tile != null && tile instanceof TileEntity) + { + tile.readFromNBT(tileNBT); + return tile; + } + else return null; + } + return null; + } + + public static String dimName(ItemStack stack) + { + if(stack != null && stack != new ItemStack(Item.getItemById(0), 0, 0) && stack.hasTagCompound() && stack.getTagCompound().hasKey("dimName")) + { + NBTTagCompound dim = (NBTTagCompound) stack.getTagCompound().getTag("dimName"); + String name = dim.getString("dimName"); + return name; + } + return null; + } + + public static String modeName(ItemStack stack) + { + if(stack != null && stack != new ItemStack(Item.getItemById(0), 0, 0) && stack.hasTagCompound() && stack.getTagCompound().hasKey("mode")) + { + NBTTagCompound dim = (NBTTagCompound) stack.getTagCompound().getTag("mode"); + String name = dim.getString("mode"); + return name; + } + return null; + } + + public static int dimension(ItemStack stack) + { + if(stack != null && stack != new ItemStack(Item.getItemById(0), 0, 0) && stack.hasTagCompound() && stack.getTagCompound().hasKey("dimension")) + { + NBTTagCompound dim = (NBTTagCompound) stack.getTagCompound().getTag("dimension"); + int dimension = dim.getInteger("dimension"); + return dimension; + } + return -2; + } + + public static int blockCoordX(ItemStack stack) + { + if (stack != null && stack != new ItemStack(Item.getItemById(0), 0, 0) && stack.getTagCompound().hasKey("blockX")) + { + NBTTagCompound x = (NBTTagCompound) stack.getTagCompound().getTag("blockX"); + int posX = x.getInteger("blockX"); + return posX; + } + return -1; + } + + public static int blockCoordY(ItemStack stack) + { + if (stack != null && stack != new ItemStack(Item.getItemById(0), 0, 0) && stack.getTagCompound().hasKey("blockY")) + { + NBTTagCompound y = (NBTTagCompound) stack.getTagCompound().getTag("blockY"); + int posY = y.getInteger("blockY"); + return posY; + } + return -1; + } + + public static int blockCoordZ(ItemStack stack) + { + if (stack != null && stack != new ItemStack(Item.getItemById(0), 0, 0) && stack.getTagCompound().hasKey("blockZ")) + { + NBTTagCompound z = (NBTTagCompound) stack.getTagCompound().getTag("blockZ"); + int posZ = z.getInteger("blockZ"); + return posZ; + } + return -1; + } + + public static int blockID(ItemStack stack) + { + if (stack != null && stack != new ItemStack(Item.getItemById(0), 0, 0) && stack.getTagCompound().hasKey("blockID")) + { + NBTTagCompound blockID = (NBTTagCompound) stack.getTagCompound().getTag("blockID"); + int blockId = blockID.getInteger("blockID"); + return blockId; + } + return -1; + } + + public static int blockMetadata(ItemStack stack) + { + if (stack != null && stack != new ItemStack(Item.getItemById(0), 0, 0) && stack.getTagCompound().hasKey("metadata")) + { + NBTTagCompound metadataNBT = (NBTTagCompound) stack.getTagCompound().getTag("metadata"); + int metadata = metadataNBT.getInteger("metadata"); + return metadata; + } + return -1; + } + + public static double playerPosX(ItemStack stack) + { + if (stack != null && stack != new ItemStack(Item.getItemById(0), 0, 0) && stack.getTagCompound().hasKey("x")) + { + NBTTagCompound x = (NBTTagCompound) stack.getTagCompound().getTag("x"); + double posX = x.getDouble("x"); + return posX; + } + return -1; + } + + public static double playerPosY(ItemStack stack) + { + if (stack != null && stack != new ItemStack(Item.getItemById(0), 0, 0) && stack.getTagCompound().hasKey("y")) + { + NBTTagCompound y = (NBTTagCompound) stack.getTagCompound().getTag("y"); + double posY = y.getDouble("y"); + return posY; + } + return -1; + } + + public static double playerPosZ(ItemStack stack) + { + if (stack != null && stack != new ItemStack(Item.getItemById(0), 0, 0) && stack.getTagCompound().hasKey("z")) + { + NBTTagCompound z = (NBTTagCompound) stack.getTagCompound().getTag("z"); + double posZ = z.getDouble("z"); + return posZ; + } + return -1; + } + + public static int ingotColor(ItemStack stack) + { + if(stack != null && stack != new ItemStack(Item.getItemById(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 int jewelColor(ItemStack stack) + { + if(stack != null && stack != new ItemStack(Item.getItemById(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; + } + + @SuppressWarnings({ "rawtypes", "unchecked", "null" }) + public static List entities(ItemStack stack, EntityPlayer player) + { + if (stack != null && stack != new ItemStack(Item.getItemById(0), 0, 0) && stack.getTagCompound().hasKey("entities")) + { + NBTTagCompound enID = (NBTTagCompound) stack.getTagCompound().getTag("entitiesID"); + List list = null; + int[] entityID; + EntityLivingBase entity; + entityID = enID.getIntArray("entitiesID"); + for(int i = 0; i < entityID.length; i++){ + entity = (EntityLivingBase) EntityList.createEntityByID(entityID[i], player.worldObj); + list.add(entity); + } + return list; + } + return null; + } +} diff --git a/src/main/java/darkknight/jewelrycraft/util/JewelrycraftUtil.java b/src/main/java/darkknight/jewelrycraft/util/JewelrycraftUtil.java new file mode 100644 index 0000000..271f6f9 --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/util/JewelrycraftUtil.java @@ -0,0 +1,139 @@ +package darkknight.jewelrycraft.util; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Random; + +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraftforge.oredict.OreDictionary; +import darkknight.jewelrycraft.item.ItemList; + +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<String,Item> liquids = new HashMap<String,Item>(); + public static Random rand = new Random(); + + public static void addStuff() + { + //Modifiers + modifiers.add(new ItemStack(Blocks.chest)); + modifiers.add(new ItemStack(Blocks.torch)); + modifiers.add(new ItemStack(Items.book)); + modifiers.add(new ItemStack(Items.dye, 1, 15)); + modifiers.add(new ItemStack(Items.bone)); + modifiers.add(new ItemStack(Items.sugar)); + modifiers.add(new ItemStack(Items.feather)); + modifiers.add(new ItemStack(Items.bed)); + modifiers.add(new ItemStack(Items.iron_pickaxe)); + modifiers.add(new ItemStack(Items.redstone)); + modifiers.add(new ItemStack(Items.diamond_pickaxe)); + modifiers.add(new ItemStack(Items.blaze_powder)); + modifiers.add(new ItemStack(Items.ender_eye)); + modifiers.add(new ItemStack(Items.potionitem, 1, 8270)); + + //Jewels + for(int i=0; i < 16; i++) + jewel.add(new ItemStack(ItemList.crystal, 1, i)); + jewel.add(new ItemStack(Blocks.redstone_block)); + jewel.add(new ItemStack(Blocks.lapis_block)); + jewel.add(new ItemStack(Blocks.obsidian)); + jewel.add(new ItemStack(Items.diamond)); + jewel.add(new ItemStack(Items.emerald)); + jewel.add(new ItemStack(Items.ender_pearl)); + jewel.add(new ItemStack(Items.nether_star)); + + //Jewelry + jewelry.add(new ItemStack(ItemList.ring)); + jewelry.add(new ItemStack(ItemList.necklace)); + } + + public static void jamcrafters() + { + jamcraftPlayers.add("allout58"); + jamcraftPlayers.add("ChewBaker"); + jamcraftPlayers.add("domi1819"); + jamcraftPlayers.add("founderio"); + jamcraftPlayers.add("Ironhammer354"); + jamcraftPlayers.add("isomgirls6"); + jamcraftPlayers.add("jmjmjm439"); + jamcraftPlayers.add("Joban"); + jamcraftPlayers.add("KJ4IPS"); + jamcraftPlayers.add("Mitchellbrine"); + jamcraftPlayers.add("MrComputerGhost"); + jamcraftPlayers.add("MrKol999"); + jamcraftPlayers.add("Resinresin"); + jamcraftPlayers.add("sci4me"); + jamcraftPlayers.add("sor1n"); + jamcraftPlayers.add("theminecoder"); + 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()) + { + ItemStack stack = OreDictionary.getOres(OreDictionary.getOreNames()[index]).get(index2).copy(); + if(stack.getItemDamage() == Short.MAX_VALUE) stack.setItemDamage(0); + if(stack.getUnlocalizedName().toLowerCase().contains("ingot") && !JewelrycraftUtil.metal.contains(stack)) + metal.add(OreDictionary.getOres(OreDictionary.getOreNames()[index]).get(index2)); + index2++; + } + index2 = 0; + index++; + } + if(!metal.contains(new ItemStack(Items.gold_ingot)))metal.add(new ItemStack(Items.gold_ingot)); + if(!metal.contains(new ItemStack(Items.iron_ingot)))metal.add(new ItemStack(Items.iron_ingot)); + } + + public static boolean isModifier(ItemStack item) + { + Iterator<ItemStack> i = modifiers.iterator(); + + while (i.hasNext()) + { + ItemStack temp = i.next(); + if (temp.getItem() == item.getItem() && temp.getItemDamage() == item.getItemDamage()) + return true; + } + return false; + } + + public static boolean isJewel(ItemStack item) + { + Iterator<ItemStack> i = jewel.iterator(); + + while (i.hasNext()) + { + ItemStack temp = i.next(); + if (temp.getItem() == item.getItem() && temp.getItemDamage() == item.getItemDamage()) + return true; + } + return false; + } + + public static boolean isJewelry(ItemStack item) + { + Iterator<ItemStack> i = jewelry.iterator(); + + while (i.hasNext()) + { + ItemStack temp = i.next(); + if (temp.getItem() == item.getItem() && temp.getItemDamage() == item.getItemDamage()) + return true; + } + return false; + } +} diff --git a/src/main/java/darkknight/jewelrycraft/util/PlayerUtils.java b/src/main/java/darkknight/jewelrycraft/util/PlayerUtils.java new file mode 100644 index 0000000..aa6a12b --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/util/PlayerUtils.java @@ -0,0 +1,57 @@ +package darkknight.jewelrycraft.util; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.server.MinecraftServer; +import net.minecraft.server.integrated.IntegratedServer; +import cpw.mods.fml.common.FMLCommonHandler; + +/** + * Code taken from OpenBlocks + */ +public class PlayerUtils +{ + public static boolean isPlayerOp(String username) + { + username = username.toLowerCase(); + + MinecraftServer server = FMLCommonHandler.instance().getSidedDelegate().getServer(); + + // SP and LAN + if (server.isSinglePlayer()) { + if (server instanceof IntegratedServer) return server.getServerOwner().equals(username); + return server.getConfigurationManager().getOps().contains(username); + } + + // SMP + return server.getConfigurationManager().getOps().contains(username); + } + + public static NBTTagCompound getModPlayerPersistTag(EntityPlayer player, String modName) + { + + NBTTagCompound tag = player.getEntityData(); + + NBTTagCompound persistTag = null; + if (tag.hasKey(EntityPlayer.PERSISTED_NBT_TAG)) + { + persistTag = tag.getCompoundTag(EntityPlayer.PERSISTED_NBT_TAG); + } else + { + persistTag = new NBTTagCompound(); + tag.setTag(EntityPlayer.PERSISTED_NBT_TAG, persistTag); + } + + NBTTagCompound modTag = null; + if (persistTag.hasKey(modName)) + { + modTag = persistTag.getCompoundTag(modName); + } else + { + modTag = new NBTTagCompound(); + persistTag.setTag(modName, modTag); + } + + return modTag; + } +}
\ No newline at end of file diff --git a/src/main/java/darkknight/jewelrycraft/worldGen/Generation.java b/src/main/java/darkknight/jewelrycraft/worldGen/Generation.java new file mode 100644 index 0000000..f484c0b --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/worldGen/Generation.java @@ -0,0 +1,46 @@ +package darkknight.jewelrycraft.worldGen; + +import java.util.Random; + +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 +{ + @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); + world.setBlock(x, y, z, BlockList.shadowOre); + if(random.nextInt(3) == 0) world.setBlock(x + random.nextInt(2), y + random.nextInt(1), z + random.nextInt(2), BlockList.shadowOre); + } + } + + private void generateNether(World world, Random random, int i, int j) + {} +} diff --git a/src/main/java/darkknight/jewelrycraft/worldGen/village/ComponentJewelry.java b/src/main/java/darkknight/jewelrycraft/worldGen/village/ComponentJewelry.java new file mode 100644 index 0000000..6924940 --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/worldGen/village/ComponentJewelry.java @@ -0,0 +1,355 @@ +package darkknight.jewelrycraft.worldGen.village; + +import java.util.List; +import java.util.Random; + +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntityChest; +import net.minecraft.tileentity.TileEntityFurnace; +import net.minecraft.world.World; +import net.minecraft.world.gen.structure.StructureBoundingBox; +import net.minecraft.world.gen.structure.StructureComponent; +import net.minecraft.world.gen.structure.StructureVillagePieces; +import net.minecraft.world.gen.structure.StructureVillagePieces.Start; +import darkknight.jewelrycraft.block.BlockList; +import darkknight.jewelrycraft.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; + +public class ComponentJewelry extends StructureVillagePieces.House1 +{ + private int averageGroundLevel = -1; + + public ComponentJewelry() + { + } + + public ComponentJewelry(Start par1ComponentVillageStartPiece, int par2, Random par3Random, StructureBoundingBox par4StructureBoundingBox, int par5) + { + super(); + this.coordBaseMode = par5; + this.boundingBox = par4StructureBoundingBox; + } + + @SuppressWarnings("rawtypes") + public static ComponentJewelry buildComponent (Start villagePiece, List pieces, Random random, int p1, int p2, int p3, int p4, int p5) + { + StructureBoundingBox structureboundingbox = StructureBoundingBox.getComponentToAddBoundingBox(p1, p2, p3, 0, 0, 0, 11, 5, 12, p4); + return canVillageGoDeeper(structureboundingbox) && StructureComponent.findIntersecting(pieces, structureboundingbox) == null ? new ComponentJewelry(villagePiece, p5, random, + structureboundingbox, p4) : null; + } + + /** + * second Part of Structure generating, this for example places Spiderwebs, Mob Spawners, it closes Mineshafts at + * the end, it adds Fences... + */ + 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, 6, 10, 5, 11, Block.getBlockById(0), Block.getBlockById(0), false); + this.fillWithBlocks(world, sbb, 2, 0, 0, 8, 5, 5, Block.getBlockById(0), Block.getBlockById(0), false); + //Pillars + this.fillWithBlocks(world, sbb, 2, 0, 0, 2, 3, 0, Blocks.log, Blocks.log, false); + this.fillWithBlocks(world, sbb, 2, 0, 3, 2, 3, 3, Blocks.log, Blocks.log, false); + this.fillWithBlocks(world, sbb, 8, 0, 0, 8, 3, 0, Blocks.log, Blocks.log, false); + this.fillWithBlocks(world, sbb, 8, 0, 3, 8, 3, 3, Blocks.log, Blocks.log, false); + + //Walls + this.fillWithBlocks(world, sbb, 2, 0, 1, 2, 3, 2, Blocks.planks, Blocks.planks, false); + this.fillWithBlocks(world, sbb, 2, 0, 4, 2, 3, 5, Blocks.planks, Blocks.planks, false); + this.fillWithBlocks(world, sbb, 8, 0, 1, 8, 3, 2, Blocks.planks, Blocks.planks, false); + this.fillWithBlocks(world, sbb, 8, 0, 4, 8, 3, 5, Blocks.planks, Blocks.planks, false); + this.fillWithBlocks(world, sbb, 3, 0, 0, 7, 3, 0, Blocks.planks, Blocks.planks, false); + + this.fillWithBlocks(world, sbb, 0, 0, 6, 10, 3, 6, Blocks.cobblestone, Blocks.cobblestone, false); + this.fillWithBlocks(world, sbb, 0, 0, 11, 10, 3, 11, Blocks.cobblestone, Blocks.cobblestone, false); + this.fillWithBlocks(world, sbb, 0, 0, 6, 0, 3, 11, Blocks.cobblestone, Blocks.cobblestone, false); + this.fillWithBlocks(world, sbb, 10, 0, 6, 10, 3, 11, Blocks.cobblestone, Blocks.cobblestone, false); + + //Roof + for(int i = 3; i <= 7; i++) + for(int j = 1; j <= 5; j++) + this.placeBlockAtCurrentPosition(world, Blocks.wooden_slab, 2, i, 4, j, sbb); + + for(int i = 3; i <= 7; i++) + for(int j = 6; j <= 6; j++) + this.placeBlockAtCurrentPosition(world, Blocks.stone_slab, 0, i, 4, j, sbb); + + for(int i = 1; i <= 9; i++) + for(int j = 7; j <= 10; j++) + this.placeBlockAtCurrentPosition(world, Blocks.stone_slab, 3, i, 4, j, sbb); + + for(int i = 2; i <= 8; i++) + this.placeBlockAtCurrentPosition(world, Blocks.double_wooden_slab, 2, i, 4, 0, sbb); + + for(int i = 1; i <= 5; i++){ + this.placeBlockAtCurrentPosition(world, Blocks.double_wooden_slab, 2, 2, 4, i, sbb); + this.placeBlockAtCurrentPosition(world, Blocks.double_wooden_slab, 2, 8, 4, i, sbb); + } + + for(int i = 0; i <= 2; i++){ + this.placeBlockAtCurrentPosition(world, Blocks.double_stone_slab, 0, i, 4, 6, sbb); + this.placeBlockAtCurrentPosition(world, Blocks.double_stone_slab, 0, i + 8, 4, 6, sbb); + } + + for(int i = 7; i <= 11; i++){ + this.placeBlockAtCurrentPosition(world, Blocks.double_stone_slab, 0, 0, 4, i, sbb); + this.placeBlockAtCurrentPosition(world, Blocks.double_stone_slab, 0, 10, 4, i, sbb); + } + + for(int i = 0; i <= 10; i++) + this.placeBlockAtCurrentPosition(world, Blocks.double_stone_slab, 0, i, 4, 11, sbb); + + //Base + for(int i = 2; i <= 8; i++) + for(int j = 0; j <= 5; j++) + this.placeBlockAtCurrentPosition(world, Blocks.planks, 1, i, 0, j, sbb); + this.fillWithBlocks(world, sbb, 0, 0, 6, 10, 0, 11, Blocks.stonebrick, Blocks.stonebrick, false); + + for(int i = 6; i <= 10; i++) + this.placeBlockAtCurrentPosition(world, Blocks.double_stone_slab, 0, 5, 0, i, sbb); + + for(int i = 7; i <= 10; i++){ + this.placeBlockAtCurrentPosition(world, Blocks.stonebrick, 3, 1, 0, i, sbb); + this.placeBlockAtCurrentPosition(world, Blocks.stonebrick, 3, 9, 0, i, sbb); + } + + //Decorations + this.placeDoorAtCurrentPosition(world, sbb, random, 6, 1, 0, this.getMetadataWithOffset(Blocks.wooden_door, 1)); + this.placeDoorAtCurrentPosition(world, sbb, random, 5, 1, 6, this.getMetadataWithOffset(Blocks.wooden_door, 1)); + + this.placeBlockAtCurrentPosition(world, Blocks.glass_pane, 0, 3, 2, 0, sbb); + this.placeBlockAtCurrentPosition(world, Blocks.glass_pane, 0, 4, 2, 0, sbb); + this.placeBlockAtCurrentPosition(world, Blocks.glass_pane, 0, 2, 2, 1, sbb); + this.placeBlockAtCurrentPosition(world, Blocks.glass_pane, 0, 2, 2, 2, sbb); + this.placeBlockAtCurrentPosition(world, Blocks.glass_pane, 0, 2, 2, 4, sbb); + this.placeBlockAtCurrentPosition(world, Blocks.glass_pane, 0, 2, 2, 5, sbb); + this.placeBlockAtCurrentPosition(world, Blocks.glass_pane, 0, 8, 2, 1, sbb); + this.placeBlockAtCurrentPosition(world, Blocks.glass_pane, 0, 8, 2, 2, sbb); + this.placeBlockAtCurrentPosition(world, Blocks.glass_pane, 0, 8, 2, 4, sbb); + this.placeBlockAtCurrentPosition(world, Blocks.glass_pane, 0, 8, 2, 5, sbb); + + this.placeBlockAtCurrentPosition(world, Blocks.torch, 0, 6, 3, 1, sbb); + this.placeBlockAtCurrentPosition(world, Blocks.torch, 0, 3, 3, 3, sbb); + this.placeBlockAtCurrentPosition(world, Blocks.torch, 0, 7, 3, 3, sbb); + this.placeBlockAtCurrentPosition(world, Blocks.torch, 0, 5, 3, 5, sbb); + + this.placeBlockAtCurrentPosition(world, Blocks.torch, 0, 5, 3, 7, sbb); + this.placeBlockAtCurrentPosition(world, Blocks.torch, 0, 5, 3, 10, sbb); + this.placeBlockAtCurrentPosition(world, Blocks.torch, 0, 1, 3, 8, sbb); + this.placeBlockAtCurrentPosition(world, Blocks.torch, 0, 1, 3, 9, sbb); + this.placeBlockAtCurrentPosition(world, Blocks.torch, 0, 9, 3, 8, sbb); + this.placeBlockAtCurrentPosition(world, Blocks.torch, 0, 9, 3, 9, sbb); + + int bgCarpetColor = random.nextInt(16); + + for(int i = 4; i <= 7; i++) + for(int j = 1; j <= 5; j++) + this.placeBlockAtCurrentPosition(world, Blocks.carpet, 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, (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); + + 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()); + + 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()); + + generateIngotChest(world, 9, 1, 7, 0, random, sbb, 3, 12, Blocks.chest, 5); + generateIngotChest(world, 9, 1, 8, 0, random, sbb, 5, 16, Blocks.chest, 3); + generateIngotChest(world, 9, 1, 9, 0, random, sbb, 3, 10, Blocks.trapped_chest, 2); + generateIngotChest(world, 9, 1, 10, 0, random, sbb, 3, 9, Blocks.trapped_chest, 6); + + + for (int l = 0; l < 6; ++l) + { + for (int i1 = 2; i1 < 9; ++i1) + { + this.clearCurrentPositionBlocksUpwards(world, i1, 9, l, sbb); + this.func_151554_b(world, Blocks.cobblestone, 0, i1, -1, l, sbb); + } + } + + for (int l = 6; l < 12; ++l) + { + for (int i1 = 0; i1 < 11; ++i1) + { + this.clearCurrentPositionBlocksUpwards(world, i1, 9, l, sbb); + this.func_151554_b(world, Blocks.cobblestone, 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, Blocks.chest, metadata, i, j, k, sbb); + TileEntityChest chest = (TileEntityChest)world.getTileEntity(i1, j1, k1); + while(chest != null && t > 0) + { + chest.func_145976_a("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 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, metadata, i, j, k, sbb); + TileEntityChest chest = (TileEntityChest)world.getTileEntity(i1, j1, k1); + while(chest != null && t > 0) + { + chest.func_145976_a("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); + int j1 = this.getYWithOffset(j); + int k1 = this.getZWithOffset(i, k); + int t = random.nextInt(max - min + 1) + min; + this.placeBlockAtCurrentPosition(world, Blocks.trapped_chest, metadata, i, j, k, sbb); + TileEntityChest chest = (TileEntityChest)world.getTileEntity(i1, j1, k1); + while(chest != null && t > 0) + { + chest.func_145976_a("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, metadata, i, j, k, sbb); + TileEntityDisplayer displayer = (TileEntityDisplayer)world.getTileEntity(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()))); + if(JewelryNBT.isModifierEffectType(ring)) JewelryNBT.addMode(ring, "Activated"); + if(JewelryNBT.isJewelX(ring, new ItemStack(Items.nether_star)) && JewelryNBT.isModifierX(ring, new ItemStack(Items.book))) + JewelryNBT.addMode(ring, "Disenchant"); + 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, metadata, i, j, k, sbb); + TileEntitySmelter smelter = (TileEntitySmelter)world.getTileEntity(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, metadata, i, j, k, sbb); + TileEntityMolder molder = (TileEntityMolder)world.getTileEntity(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, Blocks.furnace, metadata, i, j, k, sbb); + TileEntityFurnace furnace = (TileEntityFurnace)world.getTileEntity(i1, j1, k1); + if(furnace != null) + { + if(random.nextBoolean()) furnace.setInventorySlotContents(1, new ItemStack(Items.coal, 1 + random.nextInt(16))); + if(hasMetal){ + ItemStack metal = JewelrycraftUtil.metal.get(random.nextInt(JewelrycraftUtil.metal.size())); + furnace.setInventorySlotContents(2, new ItemStack(metal.getItem(), random.nextInt(max - min + 1) + min)); + } + } + } + + /** + * 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/src/main/java/darkknight/jewelrycraft/worldGen/village/JCTrades.java b/src/main/java/darkknight/jewelrycraft/worldGen/village/JCTrades.java new file mode 100644 index 0000000..8b5c79e --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/worldGen/village/JCTrades.java @@ -0,0 +1,151 @@ +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.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 = 5 + random.nextInt(8); + ingredient = new ItemStack(Items.emerald, 2 + random.nextInt(2)); + 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(2)); + ingredient = new ItemStack(Items.emerald, 1 + random.nextInt(1)); + if(random.nextBoolean()) ingredient2 = new ItemStack(Items.emerald, 1 + random.nextInt(2)); + break; + } + case 2: + { + result = new ItemStack(ItemList.thiefGloves); + ingredient = new ItemStack(Items.emerald, 16 + random.nextInt(8)); + if(random.nextBoolean()) ingredient2 = new ItemStack(Items.emerald, 8 + random.nextInt(4)); + break; + } + case 3: + { + result = new ItemStack(BlockList.displayer, 1 + random.nextInt(6)); + ingredient = new ItemStack(Items.emerald, 3 + random.nextInt(8)); + if(random.nextBoolean()) ingredient2 = new ItemStack(Items.emerald, 3 + random.nextInt(8)); + break; + } + case 4: + { + 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 5: + { + result = new ItemStack(BlockList.shadowOre, 1 + random.nextInt(16)); + ingredient = new ItemStack(Items.emerald, 3 + random.nextInt(4)); + if(random.nextBoolean()) ingredient2 = new ItemStack(Items.emerald, 3 + random.nextInt(4)); + break; + } + case 6: + { + result = new ItemStack(BlockList.molder, 5 + random.nextInt(5)); + ingredient = new ItemStack(Items.emerald, 1 + random.nextInt(1)); + if(random.nextBoolean()) ingredient2 = new ItemStack(Items.emerald, 1 + random.nextInt(1)); + break; + } + case 7: + { + 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 8: + { + int end = random.nextInt(JewelrycraftUtil.modifiers.size()); + result = JewelrycraftUtil.modifiers.get(end); + if(JewelrycraftUtil.modifiers.size() - 1 - end >= 3) + { + result.stackSize = 1 + random.nextInt(JewelrycraftUtil.modifiers.size() - end); + int value = end; + if(value > 64) value = 64; + ingredient = new ItemStack(Items.emerald, 3 + random.nextInt(value)); + if(random.nextBoolean()) ingredient2 = new ItemStack(Items.emerald, 4 + random.nextInt(value)); + } + else + { + result.stackSize = 1 + random.nextInt(7); + ingredient = new ItemStack(Items.emerald, result.stackSize/2 + 1 + random.nextInt(7)); + ingredient2 = new ItemStack(Items.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(JewelrycraftUtil.jewel.size() - end); + if(JewelrycraftUtil.jewel.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; + } + 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()))); + if(JewelryNBT.isModifierEffectType(result)) JewelryNBT.addMode(result, "Activated"); + if(JewelryNBT.isJewelX(result, new ItemStack(Items.nether_star)) && JewelryNBT.isModifierX(result, new ItemStack(Items.book))) + JewelryNBT.addMode(result, "Disenchant"); + ingredient = new ItemStack(Items.emerald, 16 + random.nextInt(20)); + ingredient2 = new ItemStack(Blocks.emerald_block, 5 + random.nextInt(5)); + } + } + + recipeList.addToListWithCheck(new MerchantRecipe(ingredient, ingredient2, result)); + } + } +}
\ No newline at end of file diff --git a/src/main/java/darkknight/jewelrycraft/worldGen/village/VillageJewelryHandler.java b/src/main/java/darkknight/jewelrycraft/worldGen/village/VillageJewelryHandler.java new file mode 100644 index 0000000..145c9a0 --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/worldGen/village/VillageJewelryHandler.java @@ -0,0 +1,32 @@ +package darkknight.jewelrycraft.worldGen.village; + +import java.util.List; +import java.util.Random; + +import net.minecraft.world.gen.structure.StructureVillagePieces.House1; +import net.minecraft.world.gen.structure.StructureStart; +import net.minecraft.world.gen.structure.MapGenStructureIO; +import net.minecraft.world.gen.structure.StructureVillagePieces.PieceWeight; +import net.minecraft.world.gen.structure.StructureVillagePieces.Start; +import cpw.mods.fml.common.registry.VillagerRegistry.IVillageCreationHandler; + +public class VillageJewelryHandler implements IVillageCreationHandler +{ + @Override + public PieceWeight getVillagePieceWeight (Random random, int i) + { + return new PieceWeight(ComponentJewelry.class, 30, i + random.nextInt(4)); + } + + @Override + public Class<?> getComponentClass () + { + return ComponentJewelry.class; + } + + @Override + public Object buildComponent (PieceWeight villagePiece, Start 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 |
