diff options
| author | OnyxDarkKnight <sor1n.iliutza16@gmail.com> | 2014-04-15 22:41:43 +0300 |
|---|---|---|
| committer | OnyxDarkKnight <sor1n.iliutza16@gmail.com> | 2014-04-15 22:41:43 +0300 |
| commit | 4b8b13b34d7a8fd0ee7c7b13f11be9c2bf3b5d18 (patch) | |
| tree | b49bc483d576ec3abeb2e18523e4511ecce353d3 /eclipse | |
| parent | 86398ed60db321f86e8d98f191107fdac2c93760 (diff) | |
More 1.7 stuff
Diffstat (limited to 'eclipse')
34 files changed, 971 insertions, 214 deletions
diff --git a/eclipse/Jewelrycraft/common/darkknight/jewelrycraft/CommonProxy.java b/eclipse/Jewelrycraft/common/darkknight/jewelrycraft/CommonProxy.java index 04c6a94..354f3a9 100644 --- a/eclipse/Jewelrycraft/common/darkknight/jewelrycraft/CommonProxy.java +++ b/eclipse/Jewelrycraft/common/darkknight/jewelrycraft/CommonProxy.java @@ -2,8 +2,8 @@ package darkknight.jewelrycraft; public class CommonProxy { - public void registerRenderers() - { - - } + public void registerRenderers() + { + + } } diff --git a/eclipse/Jewelrycraft/common/darkknight/jewelrycraft/CreativeTabLiquids.java b/eclipse/Jewelrycraft/common/darkknight/jewelrycraft/CreativeTabLiquids.java new file mode 100644 index 0000000..2551628 --- /dev/null +++ b/eclipse/Jewelrycraft/common/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/eclipse/Jewelrycraft/common/darkknight/jewelrycraft/JewelrycraftMod.java b/eclipse/Jewelrycraft/common/darkknight/jewelrycraft/JewelrycraftMod.java index 8565586..f6672ee 100644 --- a/eclipse/Jewelrycraft/common/darkknight/jewelrycraft/JewelrycraftMod.java +++ b/eclipse/Jewelrycraft/common/darkknight/jewelrycraft/JewelrycraftMod.java @@ -6,18 +6,22 @@ package darkknight.jewelrycraft; -import ibxm.Player; - +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.server.MinecraftServer; +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; @@ -30,11 +34,10 @@ 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 cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; 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; @@ -69,13 +72,17 @@ public class JewelrycraftMod }; 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) + public void preInit(FMLPreInitializationEvent e) throws IOException { ConfigHandler.preInit(e); - ItemList.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)); @@ -89,12 +96,13 @@ public class JewelrycraftMod } catch (Throwable e2) { - logger.severe("Error registering Jewelrycraft Structures with Vanilla Minecraft: this is expected in versions earlier than 1.6.4"); + 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(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>(); @@ -104,6 +112,9 @@ public class JewelrycraftMod 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 diff --git a/eclipse/Jewelrycraft/common/darkknight/jewelrycraft/block/BlockDisplayer.java b/eclipse/Jewelrycraft/common/darkknight/jewelrycraft/block/BlockDisplayer.java index be50e82..efdddff 100644 --- a/eclipse/Jewelrycraft/common/darkknight/jewelrycraft/block/BlockDisplayer.java +++ b/eclipse/Jewelrycraft/common/darkknight/jewelrycraft/block/BlockDisplayer.java @@ -71,6 +71,7 @@ public class BlockDisplayer extends BlockContainer 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()) { @@ -80,13 +81,15 @@ public class BlockDisplayer extends BlockContainer 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.isDirty = true; + te.markDirty(); } } } @@ -119,6 +122,7 @@ public class BlockDisplayer extends BlockContainer te.quantity = 0; } te.isDirty = true; + te.markDirty(); } else { @@ -137,6 +141,7 @@ public class BlockDisplayer extends BlockContainer te.quantity = 0; } te.isDirty = true; + te.markDirty(); } } } @@ -159,7 +164,7 @@ public class BlockDisplayer extends BlockContainer { te.object.stackSize = te.quantity; dropItem(te.getWorldObj(), (double)te.xCoord, (double)te.yCoord, (double)te.zCoord, te.object); - world.markBlockForUpdate(i, j, k); + world.removeTileEntity(i, j, k); } super.breakBlock(world, i, j, k, block, par6); diff --git a/eclipse/Jewelrycraft/common/darkknight/jewelrycraft/block/BlockJewelAltar.java b/eclipse/Jewelrycraft/common/darkknight/jewelrycraft/block/BlockJewelAltar.java index b4193f1..cbf7fef 100644 --- a/eclipse/Jewelrycraft/common/darkknight/jewelrycraft/block/BlockJewelAltar.java +++ b/eclipse/Jewelrycraft/common/darkknight/jewelrycraft/block/BlockJewelAltar.java @@ -35,7 +35,7 @@ public class BlockJewelAltar extends BlockContainer return true; } - public void registerIcons(IIconRegister par1IconRegister) + public void registerBlockIcons(IIconRegister par1IconRegister) { this.altarSide = par1IconRegister.registerIcon(this.getTextureName() + "_" + "side"); this.altarBottom = par1IconRegister.registerIcon(this.getTextureName() + "_" + "bottom"); @@ -54,12 +54,13 @@ public class BlockJewelAltar extends BlockContainer ItemStack item = entityPlayer.inventory.getCurrentItem(); if (te != null && !world.isRemote) { - if(item != null && item != new ItemStack(Item.getItemById(0), 0, 0) && (item.equals(ItemList.ring) || item.equals(ItemList.necklace)) && !te.hasObject) + 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; } @@ -69,6 +70,7 @@ public class BlockJewelAltar extends BlockContainer te.object = new ItemStack(Item.getItemById(0), 0, 0); te.playerName = ""; te.isDirty = true; + te.markDirty(); te.hasObject = false; } } @@ -103,7 +105,7 @@ public class BlockJewelAltar extends BlockContainer 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.markBlockForUpdate(i, j, k); + world.removeTileEntity(i, j, k); } super.breakBlock(world, i, j, k, block, par6); diff --git a/eclipse/Jewelrycraft/common/darkknight/jewelrycraft/block/BlockJewelrsCraftingTable.java b/eclipse/Jewelrycraft/common/darkknight/jewelrycraft/block/BlockJewelrsCraftingTable.java index b4a0f31..a701467 100644 --- a/eclipse/Jewelrycraft/common/darkknight/jewelrycraft/block/BlockJewelrsCraftingTable.java +++ b/eclipse/Jewelrycraft/common/darkknight/jewelrycraft/block/BlockJewelrsCraftingTable.java @@ -66,6 +66,7 @@ public class BlockJewelrsCraftingTable extends BlockContainer entityPlayer.inventory.markDirty(); world.setTileEntity(i, j, k, te); te.isDirty = true; + te.markDirty(); } } if (!te.hasEndItem && !te.hasModifier && item != null && JewelrycraftUtil.isModifier(item)) @@ -81,6 +82,7 @@ public class BlockJewelrsCraftingTable extends BlockContainer entityPlayer.inventory.markDirty(); world.setTileEntity(i, j, k, te); te.isDirty = true; + te.markDirty(); } } if (!te.hasEndItem && !te.hasJewel && item != null && JewelrycraftUtil.isJewel(item)) @@ -96,6 +98,7 @@ public class BlockJewelrsCraftingTable extends BlockContainer 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;} @@ -109,6 +112,7 @@ public class BlockJewelrsCraftingTable extends BlockContainer te.timer = 0; te.angle = 0F; te.isDirty = true; + te.markDirty(); world.markBlockForUpdate(i, j, k); world.setTileEntity(i, j, k, te); } @@ -120,6 +124,7 @@ public class BlockJewelrsCraftingTable extends BlockContainer te.timer = 0; te.angle = 0F; te.isDirty = true; + te.markDirty(); world.markBlockForUpdate(i, j, k); world.setTileEntity(i, j, k, te); } @@ -131,6 +136,7 @@ public class BlockJewelrsCraftingTable extends BlockContainer te.timer = 0; te.angle = 0F; te.isDirty = true; + te.markDirty(); world.markBlockForUpdate(i, j, k); world.setTileEntity(i, j, k, te); } @@ -156,7 +162,7 @@ public class BlockJewelrsCraftingTable extends BlockContainer 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.markBlockForUpdate(i, j, k); + world.removeTileEntity(i, j, k); } super.breakBlock(world, i, j, k, par5, par6); } @@ -180,6 +186,7 @@ public class BlockJewelrsCraftingTable extends BlockContainer 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); } @@ -208,7 +215,7 @@ public class BlockJewelrsCraftingTable extends BlockContainer return -1; } - public void registerIcons(IIconRegister icon) + public void registerBlockIcons(IIconRegister icon) { this.blockIcon = icon.registerIcon("jewelrycraft:jewelrsCraftingTable"); } diff --git a/eclipse/Jewelrycraft/common/darkknight/jewelrycraft/block/BlockList.java b/eclipse/Jewelrycraft/common/darkknight/jewelrycraft/block/BlockList.java index 1d91a45..60d4b96 100644 --- a/eclipse/Jewelrycraft/common/darkknight/jewelrycraft/block/BlockList.java +++ b/eclipse/Jewelrycraft/common/darkknight/jewelrycraft/block/BlockList.java @@ -1,9 +1,9 @@ package darkknight.jewelrycraft.block; import net.minecraft.block.Block; -import net.minecraft.block.BlockOre; import net.minecraft.block.material.Material; -import net.minecraft.item.ItemPickaxe; +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; @@ -16,46 +16,53 @@ 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; - - 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"); - - isInitialized = true; - } - } + 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/eclipse/Jewelrycraft/common/darkknight/jewelrycraft/block/BlockMolder.java b/eclipse/Jewelrycraft/common/darkknight/jewelrycraft/block/BlockMolder.java index bde50b5..1ed58d7 100644 --- a/eclipse/Jewelrycraft/common/darkknight/jewelrycraft/block/BlockMolder.java +++ b/eclipse/Jewelrycraft/common/darkknight/jewelrycraft/block/BlockMolder.java @@ -57,6 +57,7 @@ public class BlockMolder extends BlockContainer 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) @@ -65,6 +66,7 @@ public class BlockMolder extends BlockContainer 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"))); } @@ -88,7 +90,7 @@ public class BlockMolder extends BlockContainer { 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.markBlockForUpdate(i, j, k); + world.removeTileEntity(i, j, k); } super.breakBlock(world, i, j, k, par5, par6); @@ -115,11 +117,12 @@ public class BlockMolder extends BlockContainer } 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.equals(ItemList.molds) && !me.hasMoltenMetal) + else if (me.mold.getItem() == ItemList.molds && !me.hasMoltenMetal) player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage.Jewelrycraft.molder.moldisempty"))); - else if (!me.mold.equals(ItemList.molds)) + else if (me.mold.getItem() != ItemList.molds) player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage.Jewelrycraft.molder.moldismissing"))); me.isDirty = true; + me.markDirty(); } } @@ -141,7 +144,7 @@ public class BlockMolder extends BlockContainer return -1; } - public void registerIcons(IIconRegister icon) + public void registerBlockIcons(IIconRegister icon) { this.blockIcon = icon.registerIcon("jewelrycraft:molder"); } diff --git a/eclipse/Jewelrycraft/common/darkknight/jewelrycraft/block/BlockMoltenMetal.java b/eclipse/Jewelrycraft/common/darkknight/jewelrycraft/block/BlockMoltenMetal.java new file mode 100644 index 0000000..9adbf59 --- /dev/null +++ b/eclipse/Jewelrycraft/common/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/eclipse/Jewelrycraft/common/darkknight/jewelrycraft/block/BlockShadow.java b/eclipse/Jewelrycraft/common/darkknight/jewelrycraft/block/BlockShadow.java index 77b2051..acce92f 100644 --- a/eclipse/Jewelrycraft/common/darkknight/jewelrycraft/block/BlockShadow.java +++ b/eclipse/Jewelrycraft/common/darkknight/jewelrycraft/block/BlockShadow.java @@ -1,5 +1,7 @@ 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; @@ -17,6 +19,7 @@ import darkknight.jewelrycraft.tileentity.TileEntityBlockShadow; public class BlockShadow extends BlockContainer { private IIcon[] iconArray; + private static final String __OBFID = "CL_00000312"; public BlockShadow() { @@ -60,7 +63,7 @@ public class BlockShadow extends BlockContainer return new TileEntityBlockShadow(); } - public void registerIcons(IIconRegister par1IconRegister) + public void registerBlockIcons(IIconRegister par1IconRegister) { this.iconArray = new IIcon[16]; @@ -87,11 +90,6 @@ public class BlockShadow extends BlockContainer if (this == BlockList.shadowBlock) { - if (p_149646_1_.getBlockMetadata(p_149646_2_, p_149646_3_, p_149646_4_) != p_149646_1_.getBlockMetadata(p_149646_2_ - Facing.offsetsXForSide[p_149646_5_], p_149646_3_ - Facing.offsetsYForSide[p_149646_5_], p_149646_4_ - Facing.offsetsZForSide[p_149646_5_])) - { - return true; - } - if (block == this) { return false; @@ -110,4 +108,10 @@ public class BlockShadow extends BlockContainer { return world.getBlockMetadata(x, y, z); } + + @SideOnly(Side.CLIENT) + public IIcon getIcon(int side, int meta) + { + return this.iconArray[meta]; + } } diff --git a/eclipse/Jewelrycraft/common/darkknight/jewelrycraft/block/BlockSmelter.java b/eclipse/Jewelrycraft/common/darkknight/jewelrycraft/block/BlockSmelter.java index 95c2697..176a6f2 100644 --- a/eclipse/Jewelrycraft/common/darkknight/jewelrycraft/block/BlockSmelter.java +++ b/eclipse/Jewelrycraft/common/darkknight/jewelrycraft/block/BlockSmelter.java @@ -57,7 +57,7 @@ public class BlockSmelter extends BlockContainer 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.markBlockForUpdate(i, j, k); + world.removeTileEntity(i, j, k); } super.breakBlock(world, i, j, k, par5, par6); } @@ -80,6 +80,7 @@ public class BlockSmelter extends BlockContainer 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()))); @@ -95,6 +96,8 @@ public class BlockSmelter extends BlockContainer 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); } @@ -126,7 +129,8 @@ public class BlockSmelter extends BlockContainer me.cooling = ConfigHandler.ingotCoolingTime; te.moltenMetal = new ItemStack(Item.getItemById(0), 0, 0); te.hasMoltenMetal = false; - me.isDirty = true; + te.isDirty = true; + te.markDirty(); world.markBlockForUpdate(i, j, k); world.setTileEntity(i, j, k, te); } @@ -185,7 +189,7 @@ public class BlockSmelter extends BlockContainer return -1; } - public void registerIcons(IIconRegister icon) + public void registerBlockIcons(IIconRegister icon) { this.blockIcon = icon.registerIcon("jewelrycraft:smelter"); } diff --git a/eclipse/Jewelrycraft/common/darkknight/jewelrycraft/events/BucketHandler.java b/eclipse/Jewelrycraft/common/darkknight/jewelrycraft/events/BucketHandler.java new file mode 100644 index 0000000..64a02c3 --- /dev/null +++ b/eclipse/Jewelrycraft/common/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/eclipse/Jewelrycraft/common/darkknight/jewelrycraft/events/EntityEventHandler.java b/eclipse/Jewelrycraft/common/darkknight/jewelrycraft/events/EntityEventHandler.java index acc37cf..d8d49a2 100644 --- a/eclipse/Jewelrycraft/common/darkknight/jewelrycraft/events/EntityEventHandler.java +++ b/eclipse/Jewelrycraft/common/darkknight/jewelrycraft/events/EntityEventHandler.java @@ -1,46 +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"; - public static final String OPENBLOCKS_PERSIST_TAG = "Jewelrycraft"; - public static final String GIVEN_GUIDE_TAG = "givenGuive"; - - 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"); + @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); - } - } - } + 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/eclipse/Jewelrycraft/common/darkknight/jewelrycraft/item/ItemList.java b/eclipse/Jewelrycraft/common/darkknight/jewelrycraft/item/ItemList.java index 3ac524d..3a91c7b 100644 --- a/eclipse/Jewelrycraft/common/darkknight/jewelrycraft/item/ItemList.java +++ b/eclipse/Jewelrycraft/common/darkknight/jewelrycraft/item/ItemList.java @@ -1,47 +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.config.ConfigHandler; +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 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; + 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); + 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(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; - } - } + isInitialized = true; + } + } } diff --git a/eclipse/Jewelrycraft/common/darkknight/jewelrycraft/item/ItemMoltenMetalBucket.java b/eclipse/Jewelrycraft/common/darkknight/jewelrycraft/item/ItemMoltenMetalBucket.java new file mode 100644 index 0000000..18a17ad --- /dev/null +++ b/eclipse/Jewelrycraft/common/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/eclipse/Jewelrycraft/common/darkknight/jewelrycraft/item/ItemNecklace.java b/eclipse/Jewelrycraft/common/darkknight/jewelrycraft/item/ItemNecklace.java index 4503406..71af0a0 100644 --- a/eclipse/Jewelrycraft/common/darkknight/jewelrycraft/item/ItemNecklace.java +++ b/eclipse/Jewelrycraft/common/darkknight/jewelrycraft/item/ItemNecklace.java @@ -72,7 +72,7 @@ public class ItemNecklace extends Item return itemIcon; } - public String getItemDisplayName(ItemStack stack) + 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(); @@ -215,22 +215,12 @@ public class ItemNecklace extends Item 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) destroyBlock(world, i + x, j, k + z); - else if((side == 2 || side == 3) && j + x > 0 && world.getBlock(i + z, j + x, k) != Blocks.bedrock) destroyBlock(world, i + z, j + x, k); - else if((side == 4 || side == 5) && j + x > 0 && world.getBlock(i, j + x, k + z) != Blocks.bedrock) destroyBlock(world, i, j + x, k + z); + 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 destroyBlock(World world, int i, int j, int k) - { - EntityItem entityitem = new EntityItem(world, i + 0.5D, j + 1D, k + 0.5D, new ItemStack(world.getBlock(i, j, k))); - entityitem.motionX = 0; - entityitem.motionZ = 0; - entityitem.motionY = 0.21000000298023224D; - world.spawnEntityInWorld(entityitem); - world.setBlockToAir(i, j, k); - } public void onUpdate(ItemStack stack, World world, Entity entity, int par4, boolean par5) { diff --git a/eclipse/Jewelrycraft/common/darkknight/jewelrycraft/item/ItemRing.java b/eclipse/Jewelrycraft/common/darkknight/jewelrycraft/item/ItemRing.java index 03e4f1a..fff9120 100644 --- a/eclipse/Jewelrycraft/common/darkknight/jewelrycraft/item/ItemRing.java +++ b/eclipse/Jewelrycraft/common/darkknight/jewelrycraft/item/ItemRing.java @@ -172,7 +172,7 @@ public class ItemRing extends Item return 16777215; } - public String getItemDisplayName(ItemStack stack) + 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(); @@ -240,7 +240,7 @@ public class ItemRing extends Item } if(JewelryNBT.isModeX(stack, "Activated")) mode = "Deactivated"; else if(JewelryNBT.isModeX(stack, "Deactivated")) mode = "Activated"; - if(mode != "") + if(mode != "" && mode != "Transfer" && mode != "Enchant" && mode != "Disenchant") { player.addChatMessage(new ChatComponentText("The Ring has been " + mode)); JewelryNBT.addMode(stack, mode); @@ -371,14 +371,7 @@ public class ItemRing extends Item } } 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) - { - EntityItem entityitem = new EntityItem(world, i + 0.5D, j + 1D, k + 0.5D, new ItemStack(world.getBlock(i, j, k))); - entityitem.motionX = 0; - entityitem.motionZ = 0; - entityitem.motionY = 0.21000000298023224D; - world.spawnEntityInWorld(entityitem); - world.setBlockToAir(i, j, k); - } + world.func_147480_a(i, j, k, true); } return true; } @@ -443,7 +436,7 @@ public class ItemRing extends Item } 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().equals(stack)) + 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); diff --git a/eclipse/Jewelrycraft/common/darkknight/jewelrycraft/renders/TileEntityDisplayerRender.java b/eclipse/Jewelrycraft/common/darkknight/jewelrycraft/renders/TileEntityDisplayerRender.java index 8957ce4..b7acffc 100644 --- a/eclipse/Jewelrycraft/common/darkknight/jewelrycraft/renders/TileEntityDisplayerRender.java +++ b/eclipse/Jewelrycraft/common/darkknight/jewelrycraft/renders/TileEntityDisplayerRender.java @@ -14,6 +14,7 @@ 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; @@ -57,14 +58,14 @@ public class TileEntityDisplayerRender extends TileEntitySpecialRenderer 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(null, true) != null) + 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(new FakePlayer((WorldServer) te.getWorldObj(), new GameProfile("0", "Player")), true).size(); i++) + for(int i = 1; i < disp.object.getTooltip(te.getWorldObj().getClosestPlayer(x, y, z, 2D), true).size(); i++) { - if(disp.object.getTooltip(new FakePlayer((WorldServer) te.getWorldObj(), new GameProfile("0", "Player")), true).get(i).toString() != "") + if(disp.object.getTooltip(te.getWorldObj().getClosestPlayer(x, y, z, 2D), true).get(i).toString() != "") { GL11.glPushMatrix(); - renderLabel(disp.object.getTooltip(new FakePlayer((WorldServer) te.getWorldObj(), new GameProfile("0", "Player")), true).get(i).toString(), 0F, (-0.171F)*ind, 0F, block, disp, Color.GRAY.getRGB()); + 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++; } @@ -140,7 +141,7 @@ public class TileEntityDisplayerRender extends TileEntitySpecialRenderer 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); + 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); @@ -152,85 +153,85 @@ public class TileEntityDisplayerRender extends TileEntitySpecialRenderer public void replaceEnumEnchValues(String str, int color) { - if(str.contains("§0")) + if(str.contains("§0")) { color = Color.BLACK.getRGB(); - str.replace("§0", ""); + str.replace("§0", ""); } - if(str.contains("§1")) + if(str.contains("§1")) { color = 85; - str.replace("§1", ""); + str.replace("§1", ""); } - if(str.contains("§2")) + if(str.contains("§2")) { color = 17920; - str.replace("§2", ""); + str.replace("§2", ""); } - if(str.contains("§3")) + if(str.contains("§3")) { color = 1336183; - str.replace("§3", ""); + str.replace("§3", ""); } - if(str.contains("§4")) + if(str.contains("§4")) { color = 4587520; - str.replace("§4", ""); + str.replace("§4", ""); } - if(str.contains("§5")) + if(str.contains("§5")) { color = 5701759; - str.replace("§5", ""); + str.replace("§5", ""); } - if(str.contains("§6")) + if(str.contains("§6")) { color = 16762880; - str.replace("§6", ""); + str.replace("§6", ""); } - if(str.contains("§7")) + if(str.contains("§7")) { color = Color.GRAY.getRGB(); - str.replace("§7", ""); + str.replace("§7", ""); } - if(str.contains("§8")) + if(str.contains("§8")) { color = Color.DARK_GRAY.getRGB(); - str.replace("§8", ""); + str.replace("§8", ""); } - if(str.contains("§9")) + if(str.contains("§9")) { color = Color.BLUE.getRGB(); - str.replace("§9", ""); + str.replace("§9", ""); } - if(str.contains("§a")) + if(str.contains("§a")) { color = Color.GREEN.getRGB(); - str.replace("§a", ""); + str.replace("§a", ""); } - if(str.contains("§b")) + if(str.contains("§b")) { color = Color.CYAN.getRGB(); - str.replace("§b", ""); + str.replace("§b", ""); } - if(str.contains("§c")) + if(str.contains("§c")) { color = Color.RED.getRGB(); - str.replace("§c", ""); + str.replace("§c", ""); } - if(str.contains("§d")) + if(str.contains("§d")) { color = 11665663; - str.replace("§d", ""); + str.replace("§d", ""); } - if(str.contains("§e")) + if(str.contains("§e")) { color = Color.YELLOW.getRGB(); - str.replace("§e", ""); + str.replace("§e", ""); } - if(str.contains("§f")) + if(str.contains("§f")) { color = Color.WHITE.getRGB(); - str.replace("§f", ""); + str.replace("§f", ""); } } }
\ No newline at end of file diff --git a/eclipse/Jewelrycraft/common/darkknight/jewelrycraft/renders/TileEntitySmelterRender.java b/eclipse/Jewelrycraft/common/darkknight/jewelrycraft/renders/TileEntitySmelterRender.java index d7d5408..0c981c6 100644 --- a/eclipse/Jewelrycraft/common/darkknight/jewelrycraft/renders/TileEntitySmelterRender.java +++ b/eclipse/Jewelrycraft/common/darkknight/jewelrycraft/renders/TileEntitySmelterRender.java @@ -17,6 +17,7 @@ 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; @@ -100,6 +101,25 @@ public class TileEntitySmelterRender extends TileEntitySpecialRenderer 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(); diff --git a/eclipse/Jewelrycraft/common/darkknight/jewelrycraft/tileentity/TileEntityAltar.java b/eclipse/Jewelrycraft/common/darkknight/jewelrycraft/tileentity/TileEntityAltar.java index 3fbac17..62ef646 100644 --- a/eclipse/Jewelrycraft/common/darkknight/jewelrycraft/tileentity/TileEntityAltar.java +++ b/eclipse/Jewelrycraft/common/darkknight/jewelrycraft/tileentity/TileEntityAltar.java @@ -9,6 +9,9 @@ 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; @@ -57,7 +60,7 @@ public class TileEntityAltar extends TileEntity if(isDirty) { worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); - isDirty = true; + isDirty = false; } if(hasObject && playerName != "") { @@ -87,8 +90,8 @@ public class TileEntityAltar extends TileEntity 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).equals(Blocks.farmland)) worldObj.setBlockMetadataWithNotify(xCoord + i, yCoord + j, zCoord + k, 1, 7); - if(!worldObj.getBlock(xCoord + i, yCoord + j, zCoord + k).equals(Blocks.farmland)) worldObj.scheduleBlockUpdate(xCoord + i, yCoord + j, zCoord + k, worldObj.getBlock(xCoord + i, yCoord + j, zCoord + k), 5); + 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); } } @@ -116,12 +119,26 @@ public class TileEntityAltar extends TileEntity 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).equals(Blocks.farmland)) worldObj.setBlockMetadataWithNotify(xCoord + i, yCoord + j, zCoord + k, 1, 7); - if(!worldObj.getBlock(xCoord + i, yCoord + j, zCoord + k).equals(Blocks.farmland)) worldObj.scheduleBlockUpdate(xCoord + i, yCoord + j, zCoord + k, worldObj.getBlock(xCoord + i, yCoord + j, zCoord + k), 5); + 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/eclipse/Jewelrycraft/common/darkknight/jewelrycraft/tileentity/TileEntityBlockShadow.java b/eclipse/Jewelrycraft/common/darkknight/jewelrycraft/tileentity/TileEntityBlockShadow.java index 28f4daa..186f78a 100644 --- a/eclipse/Jewelrycraft/common/darkknight/jewelrycraft/tileentity/TileEntityBlockShadow.java +++ b/eclipse/Jewelrycraft/common/darkknight/jewelrycraft/tileentity/TileEntityBlockShadow.java @@ -1,6 +1,9 @@ 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; @@ -54,4 +57,18 @@ public class TileEntityBlockShadow extends TileEntity 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/eclipse/Jewelrycraft/common/darkknight/jewelrycraft/tileentity/TileEntityDisplayer.java b/eclipse/Jewelrycraft/common/darkknight/jewelrycraft/tileentity/TileEntityDisplayer.java index 6c0effc..35def5c 100644 --- a/eclipse/Jewelrycraft/common/darkknight/jewelrycraft/tileentity/TileEntityDisplayer.java +++ b/eclipse/Jewelrycraft/common/darkknight/jewelrycraft/tileentity/TileEntityDisplayer.java @@ -3,7 +3,9 @@ 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 @@ -89,4 +91,18 @@ public class TileEntityDisplayer extends TileEntity 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/eclipse/Jewelrycraft/common/darkknight/jewelrycraft/tileentity/TileEntityJewelrsCraftingTable.java b/eclipse/Jewelrycraft/common/darkknight/jewelrycraft/tileentity/TileEntityJewelrsCraftingTable.java index 5a883d6..13b689d 100644 --- a/eclipse/Jewelrycraft/common/darkknight/jewelrycraft/tileentity/TileEntityJewelrsCraftingTable.java +++ b/eclipse/Jewelrycraft/common/darkknight/jewelrycraft/tileentity/TileEntityJewelrsCraftingTable.java @@ -4,6 +4,9 @@ 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; @@ -86,7 +89,7 @@ public class TileEntityJewelrsCraftingTable extends TileEntity super.updateEntity(); if(isDirty){ worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); - isDirty = true; + isDirty = false; } if(angle<360F)angle+=3F; else angle=0F; @@ -121,4 +124,18 @@ public class TileEntityJewelrsCraftingTable extends TileEntity } } } + + 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/eclipse/Jewelrycraft/common/darkknight/jewelrycraft/tileentity/TileEntityMolder.java b/eclipse/Jewelrycraft/common/darkknight/jewelrycraft/tileentity/TileEntityMolder.java index e37c2e4..e985f6f 100644 --- a/eclipse/Jewelrycraft/common/darkknight/jewelrycraft/tileentity/TileEntityMolder.java +++ b/eclipse/Jewelrycraft/common/darkknight/jewelrycraft/tileentity/TileEntityMolder.java @@ -3,6 +3,9 @@ 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; @@ -71,8 +74,9 @@ public class TileEntityMolder extends TileEntity { super.updateEntity(); if(isDirty){ + this.markDirty(); worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); - isDirty = true; + isDirty = false; } if (moltenMetal.getItem() != Item.getItemById(0)) { @@ -99,7 +103,23 @@ public class TileEntityMolder extends TileEntity 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/eclipse/Jewelrycraft/common/darkknight/jewelrycraft/tileentity/TileEntitySmelter.java b/eclipse/Jewelrycraft/common/darkknight/jewelrycraft/tileentity/TileEntitySmelter.java index 9d71ced..53a9f82 100644 --- a/eclipse/Jewelrycraft/common/darkknight/jewelrycraft/tileentity/TileEntitySmelter.java +++ b/eclipse/Jewelrycraft/common/darkknight/jewelrycraft/tileentity/TileEntitySmelter.java @@ -5,6 +5,9 @@ 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 @@ -59,7 +62,7 @@ public class TileEntitySmelter extends TileEntity Random rand = new Random(); if(isDirty){ worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); - isDirty = true; + isDirty = false; } if (p > 0) --p; @@ -100,7 +103,23 @@ public class TileEntitySmelter extends TileEntity 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/eclipse/Jewelrycraft/common/darkknight/jewelrycraft/util/JewelryNBT.java b/eclipse/Jewelrycraft/common/darkknight/jewelrycraft/util/JewelryNBT.java index 90c68d0..d76c84e 100644 --- a/eclipse/Jewelrycraft/common/darkknight/jewelrycraft/util/JewelryNBT.java +++ b/eclipse/Jewelrycraft/common/darkknight/jewelrycraft/util/JewelryNBT.java @@ -341,13 +341,13 @@ public class JewelryNBT public static boolean isJewelX(ItemStack stack, ItemStack jewel) { - if(jewel(stack) != null && jewel(stack) == jewel && jewel(stack).getItemDamage() == jewel.getItemDamage()) return true; + 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) == modifier && modifier(stack).getItemDamage() == modifier.getItemDamage()) return true; + if(modifier(stack) != null && modifier(stack).getItem() == modifier.getItem() && modifier(stack).getItemDamage() == modifier.getItemDamage()) return true; return false; } @@ -361,7 +361,7 @@ public class JewelryNBT public static boolean isIngotX(ItemStack stack, ItemStack ingot) { - if(ingot(stack) != null && ingot(stack) == ingot && ingot(stack).getItemDamage() == ingot.getItemDamage()) return true; + if(ingot(stack) != null && ingot(stack).getItem() == ingot.getItem() && ingot(stack).getItemDamage() == ingot.getItemDamage()) return true; return false; } diff --git a/eclipse/Jewelrycraft/common/darkknight/jewelrycraft/util/JewelrycraftUtil.java b/eclipse/Jewelrycraft/common/darkknight/jewelrycraft/util/JewelrycraftUtil.java index 738f9b5..271f6f9 100644 --- a/eclipse/Jewelrycraft/common/darkknight/jewelrycraft/util/JewelrycraftUtil.java +++ b/eclipse/Jewelrycraft/common/darkknight/jewelrycraft/util/JewelrycraftUtil.java @@ -1,11 +1,13 @@ 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; @@ -17,6 +19,7 @@ public class JewelrycraftUtil 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() @@ -102,7 +105,7 @@ public class JewelrycraftUtil while (i.hasNext()) { ItemStack temp = i.next(); - if (temp.equals(item) && temp.getItemDamage() == item.getItemDamage()) + if (temp.getItem() == item.getItem() && temp.getItemDamage() == item.getItemDamage()) return true; } return false; @@ -115,7 +118,7 @@ public class JewelrycraftUtil while (i.hasNext()) { ItemStack temp = i.next(); - if (temp.equals(item) && temp.getItemDamage() == item.getItemDamage()) + if (temp.getItem() == item.getItem() && temp.getItemDamage() == item.getItemDamage()) return true; } return false; @@ -128,7 +131,7 @@ public class JewelrycraftUtil while (i.hasNext()) { ItemStack temp = i.next(); - if (temp.equals(item) && temp.getItemDamage() == item.getItemDamage()) + if (temp.getItem() == item.getItem() && temp.getItemDamage() == item.getItemDamage()) return true; } return false; diff --git a/eclipse/Jewelrycraft/resources/assets/jewelrycraft/lang/en_US.lang b/eclipse/Jewelrycraft/resources/assets/jewelrycraft/lang/en_US.lang index 528ba74..a52e437 100644 --- a/eclipse/Jewelrycraft/resources/assets/jewelrycraft/lang/en_US.lang +++ b/eclipse/Jewelrycraft/resources/assets/jewelrycraft/lang/en_US.lang @@ -10,6 +10,7 @@ item.Jewelrycraft.ring.name=Ring item.Jewelrycraft.necklace.name=Necklace item.Jewelrycraft.crystal.name=Crystal item.Jewelrycraft.guide.name=Jewelrycraft Guide +item.Jewelrycraft.bucket.name=[WIP]Bucket of Molten tile.Jewelrycraft.oreShadow.name=Shadow Ore tile.Jewelrycraft.blockShadow.name=Shadow Block tile.Jewelrycraft.glow.name=Glow @@ -18,9 +19,11 @@ tile.Jewelrycraft.molder.name=Molder tile.Jewelrycraft.displayer.name=Storage Displayer tile.Jewelrycraft.jewelCraftingTable.name=Jeweler's Crafting Table tile.Jewelrycraft.altar.name=Jewel Altar +tile.Jewelrycraft.moltenMetal.name=[WIP] Molten itemGroup.JewelryCraft=Jewelrycraft itemGroup.Rings=Jewelrycraft Rings itemGroup.Necklaces=Jewelrycraft Necklaces +itemGroup.Liquids=Liquids chatmessage.Jewelrycraft.molder.addedmold=Added %s to molder. chatmessage.Jewelrycraft.molder.metaliscooling=Molten metal is cooling... chatmessage.Jewelrycraft.molder.moldisempty=Mold is currently empty. diff --git a/eclipse/Jewelrycraft/resources/assets/jewelrycraft/textures/blocks/moltenMetalFlow.png b/eclipse/Jewelrycraft/resources/assets/jewelrycraft/textures/blocks/moltenMetalFlow.png Binary files differnew file mode 100644 index 0000000..8e9a452 --- /dev/null +++ b/eclipse/Jewelrycraft/resources/assets/jewelrycraft/textures/blocks/moltenMetalFlow.png diff --git a/eclipse/Jewelrycraft/resources/assets/jewelrycraft/textures/blocks/moltenMetalFlow.png.mcmeta b/eclipse/Jewelrycraft/resources/assets/jewelrycraft/textures/blocks/moltenMetalFlow.png.mcmeta new file mode 100644 index 0000000..8e55e43 --- /dev/null +++ b/eclipse/Jewelrycraft/resources/assets/jewelrycraft/textures/blocks/moltenMetalFlow.png.mcmeta @@ -0,0 +1,5 @@ +{ + "animation": { + "frametime": 3 + } +} diff --git a/eclipse/Jewelrycraft/resources/assets/jewelrycraft/textures/blocks/moltenMetalStill.png b/eclipse/Jewelrycraft/resources/assets/jewelrycraft/textures/blocks/moltenMetalStill.png Binary files differnew file mode 100644 index 0000000..1eff844 --- /dev/null +++ b/eclipse/Jewelrycraft/resources/assets/jewelrycraft/textures/blocks/moltenMetalStill.png diff --git a/eclipse/Jewelrycraft/resources/assets/jewelrycraft/textures/blocks/moltenMetalStill.png.mcmeta b/eclipse/Jewelrycraft/resources/assets/jewelrycraft/textures/blocks/moltenMetalStill.png.mcmeta new file mode 100644 index 0000000..7ceb363 --- /dev/null +++ b/eclipse/Jewelrycraft/resources/assets/jewelrycraft/textures/blocks/moltenMetalStill.png.mcmeta @@ -0,0 +1,45 @@ +{ + "animation": { + "frametime": 2, + "frames": [ + 0, + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 18, + 17, + 16, + 15, + 14, + 13, + 12, + 11, + 10, + 9, + 8, + 7, + 6, + 5, + 4, + 3, + 2, + 1 + ] + } +}
\ No newline at end of file diff --git a/eclipse/Jewelrycraft/resources/assets/jewelrycraft/textures/items/bucketOverlay.png b/eclipse/Jewelrycraft/resources/assets/jewelrycraft/textures/items/bucketOverlay.png Binary files differnew file mode 100644 index 0000000..fc2e2a9 --- /dev/null +++ b/eclipse/Jewelrycraft/resources/assets/jewelrycraft/textures/items/bucketOverlay.png diff --git a/eclipse/screenshots/2014-04-15_16.25.39.png b/eclipse/screenshots/2014-04-15_16.25.39.png Binary files differnew file mode 100644 index 0000000..549411e --- /dev/null +++ b/eclipse/screenshots/2014-04-15_16.25.39.png |
