diff options
| author | OnyxDarkKnight <sor1n.iliutza16@gmail.com> | 2015-04-19 03:30:08 +0100 |
|---|---|---|
| committer | OnyxDarkKnight <sor1n.iliutza16@gmail.com> | 2015-04-19 03:30:08 +0100 |
| commit | 2a7e0a624f482a28af1c770dbcf2a20f52f94f78 (patch) | |
| tree | 39b7652b939dd20763e242fbd49eb6d2ad6924da /src/main/java/darkknight | |
| parent | 9dc6f69f701e42b30adf7d1b01488f425eaec265 (diff) | |
Added Midas Touch
Diffstat (limited to 'src/main/java/darkknight')
33 files changed, 1160 insertions, 135 deletions
diff --git a/src/main/java/darkknight/jewelrycraft/JewelrycraftMod.java b/src/main/java/darkknight/jewelrycraft/JewelrycraftMod.java index 5bb50a7..360add0 100644 --- a/src/main/java/darkknight/jewelrycraft/JewelrycraftMod.java +++ b/src/main/java/darkknight/jewelrycraft/JewelrycraftMod.java @@ -43,8 +43,10 @@ import darkknight.jewelrycraft.damage.DamageSourceList; import darkknight.jewelrycraft.effects.EffectsList; import darkknight.jewelrycraft.entities.EntityHalfHeart; import darkknight.jewelrycraft.entities.EntityHeart; +import darkknight.jewelrycraft.events.BlockEventHandler; import darkknight.jewelrycraft.events.BucketHandler; import darkknight.jewelrycraft.events.EntityEventHandler; +import darkknight.jewelrycraft.events.EventCommonHandler; import darkknight.jewelrycraft.events.KeyBindings; import darkknight.jewelrycraft.item.ItemList; import darkknight.jewelrycraft.network.PacketClearColorCache; @@ -64,15 +66,17 @@ import darkknight.jewelrycraft.worldGen.village.ComponentJewelry; import darkknight.jewelrycraft.worldGen.village.JCTrades; import darkknight.jewelrycraft.worldGen.village.VillageJewelryHandler; -@Mod (modid = Variables.MODID, name = Variables.MODNAME, version = Variables.VERSION) +@Mod (modid = Variables.MODID, name = Variables.MODNAME, version = Variables.VERSION, guiFactory = Variables.CONFIG_GUI) public class JewelrycraftMod { @Instance (Variables.MODID) public static JewelrycraftMod instance; - @SidedProxy (clientSide = "darkknight.jewelrycraft.proxy.ClientProxy", serverSide = "darkknight.jewelrycraft.proxy.CommonProxy") + + @SidedProxy (clientSide = Variables.CLIENT_PROXY, serverSide = Variables.SERVER_PROXY) public static CommonProxy proxy; public static final Logger logger = Logger.getLogger("Jewelrycraft"); public static File dir; + public static CreativeTabs jewelrycraft = new CreativeTabs(Variables.MODID){ @Override public Item getTabIconItem() @@ -80,6 +84,7 @@ public class JewelrycraftMod return Item.getItemFromBlock(BlockList.jewelCraftingTable); } }; + public static CreativeTabs liquids = new CreativeTabLiquids("Liquids"); public static NBTTagCompound saveData = new NBTTagCompound(); public static NBTTagCompound clientData = new NBTTagCompound(); @@ -96,7 +101,7 @@ public class JewelrycraftMod @EventHandler public void preInit(FMLPreInitializationEvent e) throws IOException { - ConfigHandler.preInit(e); + ConfigHandler.INSTANCE.loadConfig(e); BlockList.preInit(e); ItemList.preInit(e); CraftingRecipes.preInit(e); @@ -113,7 +118,9 @@ public class JewelrycraftMod logger.severe("Error registering Jewelrycraft Structures with Vanilla Minecraft: this is expected in versions earlier than 1.7.10"); } MinecraftForge.EVENT_BUS.register(new EntityEventHandler()); + MinecraftForge.EVENT_BUS.register(new BlockEventHandler()); MinecraftForge.EVENT_BUS.register(BucketHandler.INSTANCE); + FMLCommonHandler.instance().bus().register(new EventCommonHandler()); BucketHandler.INSTANCE.buckets.put(BlockList.moltenMetal, ItemList.bucket); ModMetadata metadata = e.getModMetadata(); @@ -142,7 +149,6 @@ public class JewelrycraftMod createEntity(EntityHeart.class, Variables.MODID + ".Heart", 0xFF0000, 0xFF0000, false); createEntity(EntityHalfHeart.class, Variables.MODID + ".Half-Heart", 0x000000, 0xFF0000, false); -// EntityRegistry.addSpawn(EntityMob.class, 5, 2, 3, EnumCreatureType.creature, BiomeGenBase.forest, BiomeGenBase.forestHills, BiomeGenBase.birchForest, BiomeGenBase.birchForestHills, BiomeGenBase.plains, BiomeGenBase.beach, BiomeGenBase.coldBeach, BiomeGenBase.frozenRiver); } public void createEntity(Class<? extends Entity> entity, String entityName, int solidColor, int spotColor, boolean hasSpawnEgg) @@ -164,6 +170,7 @@ public class JewelrycraftMod GameRegistry.registerWorldGenerator(new Generation(), 0); if (FMLCommonHandler.instance().getSide() == Side.CLIENT) FMLCommonHandler.instance().bus().register(new KeyBindings()); new GuiHandler(); + FMLCommonHandler.instance().bus().register(ConfigHandler.INSTANCE); } /** diff --git a/src/main/java/darkknight/jewelrycraft/block/BlockJewelrsCraftingTable.java b/src/main/java/darkknight/jewelrycraft/block/BlockJewelrsCraftingTable.java index fe245e6..a5d058b 100644 --- a/src/main/java/darkknight/jewelrycraft/block/BlockJewelrsCraftingTable.java +++ b/src/main/java/darkknight/jewelrycraft/block/BlockJewelrsCraftingTable.java @@ -87,7 +87,7 @@ public class BlockJewelrsCraftingTable extends BlockContainer te.isDirty = true; } if (!te.hasEndItem && te.hasJewelry && te.hasGem && !te.crafting){ - te.carving = ConfigHandler.jewelryCraftingTime; + te.carving = ConfigHandler.GEM_PLACEMENT_TIME; te.angle = 0; te.crafting = true; te.isDirty = true; @@ -183,7 +183,7 @@ public class BlockJewelrsCraftingTable extends BlockContainer te.endItem = new ItemStack(Item.getItemById(0), 0, 0); te.hasEndItem = false; te.isDirty = true; - }else if (te.hasJewelry && te.hasGem && te.carving > 0 && te.jewelry != null) player.addChatMessage(new ChatComponentText(StatCollector.translateToLocalFormatted("chatmessage." + Variables.MODID + ".table.iscrafting", te.jewelry.getDisplayName()) + " (" + (ConfigHandler.jewelryCraftingTime - te.carving) * 100 / ConfigHandler.jewelryCraftingTime + "%)")); + }else if (te.hasJewelry && te.hasGem && te.carving > 0 && te.jewelry != null) player.addChatMessage(new ChatComponentText(StatCollector.translateToLocalFormatted("chatmessage." + Variables.MODID + ".table.iscrafting", te.jewelry.getDisplayName()) + " (" + (ConfigHandler.GEM_PLACEMENT_TIME - te.carving) * 100 / ConfigHandler.GEM_PLACEMENT_TIME + "%)")); else if (!te.hasGem) player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage." + Variables.MODID + ".table.missinggem"))); else if (!te.hasJewelry) player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage." + Variables.MODID + ".table.missingjewelry"))); } diff --git a/src/main/java/darkknight/jewelrycraft/block/BlockList.java b/src/main/java/darkknight/jewelrycraft/block/BlockList.java index 7fae41c..a42a1f3 100644 --- a/src/main/java/darkknight/jewelrycraft/block/BlockList.java +++ b/src/main/java/darkknight/jewelrycraft/block/BlockList.java @@ -12,6 +12,7 @@ import darkknight.jewelrycraft.tileentity.TileEntityBlockShadow; import darkknight.jewelrycraft.tileentity.TileEntityDisplayer; import darkknight.jewelrycraft.tileentity.TileEntityHandPedestal; import darkknight.jewelrycraft.tileentity.TileEntityJewelrsCraftingTable; +import darkknight.jewelrycraft.tileentity.TileEntityMidasTouch; import darkknight.jewelrycraft.tileentity.TileEntityMolder; import darkknight.jewelrycraft.tileentity.TileEntityShadowEye; import darkknight.jewelrycraft.tileentity.TileEntityShadowHand; @@ -20,7 +21,7 @@ import darkknight.jewelrycraft.util.Variables; public class BlockList { - public static Block shadowOre, smelter, molder, displayer, jewelCraftingTable, shadowBlock, shadowEye, jewelAltar, handPedestal, shadowHand; + public static Block shadowOre, smelter, molder, displayer, jewelCraftingTable, shadowBlock, shadowEye, jewelAltar, handPedestal, shadowHand, midasTouchBlock; public static BlockMoltenMetal moltenMetal; public static Fluid moltenMetalFluid; private static boolean isInitialized = false; @@ -41,6 +42,8 @@ public class BlockList shadowEye = new BlockShadowEye().setHardness(5.0F).setResistance(6.0F).setStepSound(Block.soundTypePiston).setBlockName(Variables.MODID + ".shadowEye").setCreativeTab(JewelrycraftMod.jewelrycraft); handPedestal = new BlockHandPedestal(Material.rock).setHardness(5.0F).setResistance(6.0F).setStepSound(Block.soundTypePiston).setBlockName(Variables.MODID + ".handPedestal").setCreativeTab(JewelrycraftMod.jewelrycraft); shadowHand = new BlockShadowHand(Material.rock).setStepSound(Block.soundTypePiston).setBlockName(Variables.MODID + ".shadowHand").setCreativeTab(JewelrycraftMod.jewelrycraft).setBlockUnbreakable(); + midasTouchBlock = new BlockMidasTouch(Material.iron).setHardness(3.0F).setResistance(10.0F).setStepSound(Block.soundTypeMetal).setBlockName(Variables.MODID + ".midasTouchBlock"); + GameRegistry.registerBlock(shadowOre, "shadowOre"); GameRegistry.registerBlock(shadowBlock, "shadowBlock"); GameRegistry.registerBlock(smelter, "Smelter"); @@ -51,6 +54,8 @@ public class BlockList GameRegistry.registerBlock(shadowEye, "Shadow Eye"); GameRegistry.registerBlock(handPedestal, "Stone Bricks Pedestal"); GameRegistry.registerBlock(shadowHand, "Shadow Hand"); + GameRegistry.registerBlock(midasTouchBlock, "Midas Touch Block"); + GameRegistry.registerTileEntity(TileEntitySmelter.class, Variables.MODID + ":smelter"); GameRegistry.registerTileEntity(TileEntityMolder.class, Variables.MODID + ":molder"); GameRegistry.registerTileEntity(TileEntityJewelrsCraftingTable.class, Variables.MODID + ":table"); @@ -60,6 +65,8 @@ public class BlockList GameRegistry.registerTileEntity(TileEntityShadowEye.class, Variables.MODID + ":shadowEye"); GameRegistry.registerTileEntity(TileEntityHandPedestal.class, Variables.MODID + ":handPedestal"); GameRegistry.registerTileEntity(TileEntityShadowHand.class, Variables.MODID + ":shadowHand"); + GameRegistry.registerTileEntity(TileEntityMidasTouch.class, Variables.MODID + ":midsaTouch"); + 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); diff --git a/src/main/java/darkknight/jewelrycraft/block/BlockMidasTouch.java b/src/main/java/darkknight/jewelrycraft/block/BlockMidasTouch.java new file mode 100644 index 0000000..4e09e4a --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/block/BlockMidasTouch.java @@ -0,0 +1,83 @@ +package darkknight.jewelrycraft.block; + +import java.util.ArrayList; +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.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import darkknight.jewelrycraft.tileentity.TileEntityMidasTouch; +import darkknight.jewelrycraft.tileentity.TileEntityMolder; + +public class BlockMidasTouch extends BlockContainer +{ + protected BlockMidasTouch(Material mat) + { + super(mat); + setHarvestLevel("pickaxe", 2); + } + + @Override + public TileEntity createNewTileEntity(World world, int var2) + { + return new TileEntityMidasTouch(); + } + + @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; + } + + public int quantityDropped(Random rand) + { + return 0; + } + + public Item getItemDropped(int id, Random rand, int size) + { + return Items.gold_nugget; + } + + public void onBlockHarvested(World world, int i, int j, int k, int meta, EntityPlayer player) + { + } + + public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) + { + TileEntity tile = world.getTileEntity(x, y, z); + if (((TileEntityMidasTouch)tile).target != null) this.setBlockBounds(0.5f - ((TileEntityMidasTouch)tile).target.width / 2, 0F, 0.5f - ((TileEntityMidasTouch)tile).target.width / 2, 0.5f + ((TileEntityMidasTouch)tile).target.width / 2, ((TileEntityMidasTouch)tile).target.height, 0.5f + ((TileEntityMidasTouch)tile).target.width / 2); + } + + @Override + public void registerBlockIcons(IIconRegister icon) + { + blockIcon = icon.registerIcon("minecraft:gold_block"); + } +} diff --git a/src/main/java/darkknight/jewelrycraft/block/BlockMolder.java b/src/main/java/darkknight/jewelrycraft/block/BlockMolder.java index 5840c72..8c152e3 100644 --- a/src/main/java/darkknight/jewelrycraft/block/BlockMolder.java +++ b/src/main/java/darkknight/jewelrycraft/block/BlockMolder.java @@ -156,7 +156,7 @@ public class BlockMolder extends BlockContainer dropItem(me.getWorldObj(), me.xCoord, me.yCoord, 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." + Variables.MODID + ".molder.metaliscooling") + " (" + (ConfigHandler.ingotCoolingTime - me.cooling) * 100 / ConfigHandler.ingotCoolingTime + "%)")); + }else if (me.hasMoltenMetal && me.cooling >= 0) player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage." + Variables.MODID + ".molder.metaliscooling") + " (" + (ConfigHandler.INGOT_COOLING_TIME - me.cooling) * 100 / ConfigHandler.INGOT_COOLING_TIME + "%)")); else if (me.mold.getItem() == ItemList.molds && !me.hasMoltenMetal) player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage." + Variables.MODID + ".molder.moldisempty"))); else if (me.mold.getItem() != ItemList.molds) player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage." + Variables.MODID + ".molder.moldismissing"))); me.isDirty = true; diff --git a/src/main/java/darkknight/jewelrycraft/block/BlockShadow.java b/src/main/java/darkknight/jewelrycraft/block/BlockShadow.java index b175fe6..9312c7a 100644 --- a/src/main/java/darkknight/jewelrycraft/block/BlockShadow.java +++ b/src/main/java/darkknight/jewelrycraft/block/BlockShadow.java @@ -24,6 +24,7 @@ public class BlockShadow extends BlockContainer public BlockShadow() { super(Material.iron); + setHarvestLevel("pickaxe", 3); setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); } diff --git a/src/main/java/darkknight/jewelrycraft/block/BlockSmelter.java b/src/main/java/darkknight/jewelrycraft/block/BlockSmelter.java index aa41003..ec33fde 100644 --- a/src/main/java/darkknight/jewelrycraft/block/BlockSmelter.java +++ b/src/main/java/darkknight/jewelrycraft/block/BlockSmelter.java @@ -156,14 +156,14 @@ public class BlockSmelter extends BlockContainer // if (Item.getIdFromItem(te.metal.getItem()) == Block.getIdFromBlock(Blocks.stained_glass) || Item.getIdFromItem(te.metal.getItem()) == Block.getIdFromBlock(Blocks.stained_hardened_clay) || Item.getIdFromItem(te.metal.getItem()) == Block.getIdFromBlock(Blocks.wool) || Item.getIdFromItem(te.metal.getItem()) == Block.getIdFromBlock(Blocks.carpet)) te.metal.setItemDamage(15 - te.metal.getItemDamage()); te.metal.stackSize = 1; te.hasMetal = true; - te.melting = ConfigHandler.ingotMeltingTime; + te.melting = ConfigHandler.INGOT_MELTING_TIME; if (!entityPlayer.capabilities.isCreativeMode) --item.stackSize; te.isDirty = true; }else if (te.hasMetal && te.hasMoltenMetal && check2 && overflow || te.hasMetal && !te.hasMoltenMetal && itemCoincidesWithMetal && overflow){ entityPlayer.addChatMessage(new ChatComponentText(StatCollector.translateToLocalFormatted("Smelting extra " + (isOre ? "ores" : "ingots") + " (" + (te.metal.stackSize + 1) + ")"))); te.metal.stackSize++; te.hasMetal = true; - te.melting += ConfigHandler.ingotMeltingTime; + te.melting += ConfigHandler.INGOT_MELTING_TIME; if (!entityPlayer.capabilities.isCreativeMode) --item.stackSize; te.isDirty = true; } @@ -200,8 +200,7 @@ public class BlockSmelter extends BlockContainer if (te != null && me != null && !world.isRemote) if (te.hasMoltenMetal && isConnectedToMolder(world, i, j, k) && me != null && me.hasMold && !me.hasMoltenMetal && !me.hasJewelBase){ te.pouring = true; te.isDirty = true; -// System.out.println(Block.getBlockById(Item.getIdFromItem(te.moltenMetal.getItem()))); - }else if (te.hasMetal && te.melting > 0) player.addChatMessage(new ChatComponentText(StatCollector.translateToLocalFormatted("chatmessage." + Variables.MODID + ".smelter.metalismelting", te.metal.getDisplayName()) + " (" + (ConfigHandler.ingotMeltingTime * te.metal.stackSize - te.melting) * 100 / (ConfigHandler.ingotMeltingTime * te.metal.stackSize) + "%)")); + }else if (te.hasMetal && te.melting > 0) player.addChatMessage(new ChatComponentText(StatCollector.translateToLocalFormatted("chatmessage." + Variables.MODID + ".smelter.metalismelting", te.metal.getDisplayName()) + " (" + (ConfigHandler.INGOT_MELTING_TIME * te.metal.stackSize - te.melting) * 100 / (ConfigHandler.INGOT_MELTING_TIME * te.metal.stackSize) + "%)")); else if (te.hasMoltenMetal && !isConnectedToMolder(world, i, j, k)) player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage." + Variables.MODID + ".smelter.molderismissing"))); else if (!me.hasMold && te.hasMoltenMetal) player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage." + Variables.MODID + ".smelter.molderhasnomold"))); else if (me.hasMoltenMetal && te.hasMoltenMetal) player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chatmessage." + Variables.MODID + ".smelter.molderhasmoltenmetal"))); diff --git a/src/main/java/darkknight/jewelrycraft/client/InventoryTabVanilla.java b/src/main/java/darkknight/jewelrycraft/client/InventoryTabVanilla.java index c8d598c..4f5ae88 100644 --- a/src/main/java/darkknight/jewelrycraft/client/InventoryTabVanilla.java +++ b/src/main/java/darkknight/jewelrycraft/client/InventoryTabVanilla.java @@ -11,13 +11,13 @@ public class InventoryTabVanilla extends AbstractTab } @Override - public void onTabClicked () + public void onTabClicked() { TabRegistry.openInventoryGui(); } @Override - public boolean shouldAddToList () + public boolean shouldAddToList() { return true; } diff --git a/src/main/java/darkknight/jewelrycraft/client/TabJewelry.java b/src/main/java/darkknight/jewelrycraft/client/TabJewelry.java index 4598962..65d4a3b 100644 --- a/src/main/java/darkknight/jewelrycraft/client/TabJewelry.java +++ b/src/main/java/darkknight/jewelrycraft/client/TabJewelry.java @@ -1,10 +1,9 @@ package darkknight.jewelrycraft.client; +import net.minecraft.item.ItemStack; import darkknight.jewelrycraft.JewelrycraftMod; import darkknight.jewelrycraft.item.ItemList; import darkknight.jewelrycraft.network.PacketKeyPressEvent; -import net.minecraft.init.Items; -import net.minecraft.item.ItemStack; public class TabJewelry extends AbstractTab { diff --git a/src/main/java/darkknight/jewelrycraft/client/TabRegistry.java b/src/main/java/darkknight/jewelrycraft/client/TabRegistry.java index 2765b73..a264412 100644 --- a/src/main/java/darkknight/jewelrycraft/client/TabRegistry.java +++ b/src/main/java/darkknight/jewelrycraft/client/TabRegistry.java @@ -7,6 +7,7 @@ import net.minecraft.client.gui.inventory.GuiInventory; import net.minecraft.network.play.client.C0DPacketCloseWindow; import net.minecraftforge.client.event.GuiScreenEvent; import cpw.mods.fml.client.FMLClientHandler; +import cpw.mods.fml.common.Loader; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -18,52 +19,47 @@ import darkknight.jewelrycraft.client.*; public class TabRegistry { private static ArrayList<AbstractTab> tabList = new ArrayList<AbstractTab>(); - - public static void registerTab (AbstractTab tab) + + public static void registerTab(AbstractTab tab) { tabList.add(tab); } - - public static ArrayList<AbstractTab> getTabList () + + public static ArrayList<AbstractTab> getTabList() { return tabList; } - - @SideOnly(Side.CLIENT) + + @SideOnly (Side.CLIENT) @SubscribeEvent - public void guiPostInit (GuiScreenEvent.InitGuiEvent.Post event) + public void guiPostInit(GuiScreenEvent.InitGuiEvent.Post event) { - if ((event.gui instanceof GuiInventory)) - { + if ((event.gui instanceof GuiInventory)){ int xSize = 176; int ySize = 166; int guiLeft = (event.gui.width - xSize) / 2; int guiTop = (event.gui.height - ySize) / 2; - if(!mc.thePlayer.getActivePotionEffects().isEmpty()) guiLeft += 60; - + if (!mc.thePlayer.getActivePotionEffects().isEmpty()) guiLeft += 60; updateTabValues(guiLeft, guiTop, InventoryTabVanilla.class); addTabsToList(event.buttonList); } } - + private static Minecraft mc = FMLClientHandler.instance().getClient(); - - public static void openInventoryGui () + + public static void openInventoryGui() { mc.thePlayer.sendQueue.addToSendQueue(new C0DPacketCloseWindow(mc.thePlayer.openContainer.windowId)); GuiInventory inventory = new GuiInventory(mc.thePlayer); mc.displayGuiScreen(inventory); } - - public static void updateTabValues (int cornerX, int cornerY, Class<?> selectedButton) + + public static void updateTabValues(int cornerX, int cornerY, Class<?> selectedButton) { - int count = 2; - for (int i = 0; i < tabList.size(); i++) - { + int count = 2 + (Loader.isModLoaded("TConstruct") ? 1 : 0); + for(int i = 0; i < tabList.size(); i++){ AbstractTab t = tabList.get(i); - - if (t.shouldAddToList()) - { + if (t.shouldAddToList()){ t.id = count; t.xPosition = cornerX + (count - 2) * 28; t.yPosition = cornerY - 28; @@ -72,15 +68,11 @@ public class TabRegistry } } } - - public static void addTabsToList (List buttonList) + + public static void addTabsToList(List buttonList) { - for (AbstractTab tab : tabList) - { - if (tab.shouldAddToList()) - { - buttonList.add(tab); - } + for(AbstractTab tab: tabList){ + if (tab.shouldAddToList()) if (!(Loader.isModLoaded("TConstruct") && tab instanceof InventoryTabVanilla) || !tabList.get(1).enabled) buttonList.add(tab); } } }
\ No newline at end of file diff --git a/src/main/java/darkknight/jewelrycraft/client/gui/GuiJewelry.java b/src/main/java/darkknight/jewelrycraft/client/gui/GuiJewelry.java index 44d312b..981fbfd 100644 --- a/src/main/java/darkknight/jewelrycraft/client/gui/GuiJewelry.java +++ b/src/main/java/darkknight/jewelrycraft/client/gui/GuiJewelry.java @@ -4,7 +4,6 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.util.ResourceLocation; import org.lwjgl.opengl.GL11; -import darkknight.jewelrycraft.client.JewelryInventory; import darkknight.jewelrycraft.client.TabJewelry; import darkknight.jewelrycraft.client.TabRegistry; import darkknight.jewelrycraft.client.gui.container.ContainerJewelryTab; diff --git a/src/main/java/darkknight/jewelrycraft/config/ConfigGui.java b/src/main/java/darkknight/jewelrycraft/config/ConfigGui.java new file mode 100644 index 0000000..bb40ed8 --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/config/ConfigGui.java @@ -0,0 +1,26 @@ +package darkknight.jewelrycraft.config; + +import cpw.mods.fml.client.config.GuiConfig; +import cpw.mods.fml.client.config.IConfigElement; +import net.minecraft.client.gui.GuiScreen; +import net.minecraftforge.common.config.ConfigElement; +import java.util.ArrayList; +import java.util.List; +import darkknight.jewelrycraft.util.Variables; + +public class ConfigGui extends GuiConfig +{ + public ConfigGui(GuiScreen parent) + { + super(parent, getElements(), Variables.MODID, Variables.MODID, false, false, Variables.MODNAME + " Config"); + } + + @SuppressWarnings ({"rawtypes"}) + private static List<IConfigElement> getElements() + { + List<IConfigElement> list = new ArrayList<IConfigElement>(ConfigHandler.categories.length); + for(String category: ConfigHandler.categories) + list.add(new ConfigElement(ConfigHandler.INSTANCE.config.getCategory(category))); + return list; + } +}
\ No newline at end of file diff --git a/src/main/java/darkknight/jewelrycraft/config/ConfigGuiFactory.java b/src/main/java/darkknight/jewelrycraft/config/ConfigGuiFactory.java new file mode 100644 index 0000000..d06efc3 --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/config/ConfigGuiFactory.java @@ -0,0 +1,31 @@ +package darkknight.jewelrycraft.config; + +import cpw.mods.fml.client.IModGuiFactory; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiScreen; +import java.util.Set; + +public class ConfigGuiFactory implements IModGuiFactory +{ + @Override + public void initialize(Minecraft minecraftInstance) + {} + + @Override + public Class<? extends GuiScreen> mainConfigGuiClass() + { + return ConfigGui.class; + } + + @Override + public Set<RuntimeOptionCategoryElement> runtimeGuiCategories() + { + return null; + } + + @Override + public RuntimeOptionGuiHandler getHandlerFor(RuntimeOptionCategoryElement element) + { + return null; + } +}
\ No newline at end of file diff --git a/src/main/java/darkknight/jewelrycraft/config/ConfigHandler.java b/src/main/java/darkknight/jewelrycraft/config/ConfigHandler.java index 9f568a3..9553111 100644 --- a/src/main/java/darkknight/jewelrycraft/config/ConfigHandler.java +++ b/src/main/java/darkknight/jewelrycraft/config/ConfigHandler.java @@ -2,54 +2,65 @@ package darkknight.jewelrycraft.config; import java.io.File; import net.minecraftforge.common.config.Configuration; +import cpw.mods.fml.client.event.ConfigChangedEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; import darkknight.jewelrycraft.util.Variables; public class ConfigHandler { public static Configuration config; - public static int ingotCoolingTime = 100; - public static int ingotMeltingTime = 1500; - public static int jewelryCraftingTime = 200; - private static boolean isInitialized = false; - public static boolean generateVillageNetherstar = false; - public static boolean canFurnacesGenerateIngots = true; - public static int maxVillageJewelers = 1; - public static int jewelerWeight = 30; - public static int ingotChestMin = 1; - public static int ingotChestMax = 4; - public static int ingotChestMaxStack = 2; - public static int jewelsChestMin = 2; - public static int jewelsChestMax = 5; - public static int furnacesIngotStackMin = 2; - public static int furnacesIngotStackMax = 5; + public static final ConfigHandler INSTANCE = new ConfigHandler(); + public static final String[] categories = { "Timers", "Village Generation"}; - /** - * Generates the config file and all the elements and attributes them to the appropriate variables if they exist - * - * @param e FMLPreInitializationEvent - */ - public static void preInit(FMLPreInitializationEvent e) + public static int INGOT_COOLING_TIME; + public static int INGOT_MELTING_TIME; + public static int GEM_PLACEMENT_TIME; + public static int RITUAL_TIME; + + public static boolean GENERATE_VILLAGE_NETHERSTAR; + public static boolean CAN_FURNACE_GENERATE_INGOTS; + public static int MAX_VILLAGE_JEWELERS; + public static int JEWELER_WEIGHT; + public static int INGOT_CHEST_MIN; + public static int INGOT_CHEST_MAX; + public static int INGOT_CHEST_MAX_STACK; + public static int GEM_CHEST_MIN; + public static int GEM_CHEST_MAX; + public static int FURNACE_MIN_INGOT_STACK; + public static int FURNACE_MAX_INGOT_STACK; + + public void loadConfig(FMLPreInitializationEvent event) + { + config = new Configuration(event.getSuggestedConfigurationFile(),true); + config.load(); + syncConfigs(); + } + + private void syncConfigs() + { + INGOT_COOLING_TIME = config.getInt("Molder Ingot Cooling Time", categories[0], 100, 5, Integer.MAX_VALUE, "This sets the number of ticks you need to wait before the mold is cooled."); + INGOT_MELTING_TIME = config.getInt("Ingot Melting Time", categories[0], 1500, 5, Integer.MAX_VALUE, "This sets the number of ticks you need to wait before an ingot is completely smelted."); + GEM_PLACEMENT_TIME = config.getInt( "Jewelry Crafting Time", categories[0], 200, 5, Integer.MAX_VALUE, "This sets the number of ticks it takes for a jewel to be modified."); + RITUAL_TIME = config.getInt( "Ritual Time", categories[0], 1000, 5, Integer.MAX_VALUE, "This sets the number of ticks it takes for the ritual to end."); + + GENERATE_VILLAGE_NETHERSTAR = config.getBoolean("Netherstar Generation", categories[1], false, "If set to true Nether Stars will be able to generate in Jewelers chests."); + CAN_FURNACE_GENERATE_INGOTS = config.getBoolean("Furnace Ingots Generation", categories[1], true, "If set to true jewelers will generate ingots in furnaces."); + MAX_VILLAGE_JEWELERS = config.getInt("Maximum Jewelers", categories[1], 1, 0, Integer.MAX_VALUE, "Sets how many jewelers can be in a village."); + JEWELER_WEIGHT = config.getInt("Jewelers Weight", categories[1], 30, 0, Integer.MAX_VALUE, "Chance of getting a jeweler in a village. The higher the value, the higher the chance."); + INGOT_CHEST_MIN = config.getInt("Ingot Chest Min", categories[1], 1, 0, Integer.MAX_VALUE, "Minimum number of ingots that can be found in a chest from the Jeweler. (It's the chest from the back part)"); + INGOT_CHEST_MAX = config.getInt("Ingot Chest Max", categories[1], 4, 0, Integer.MAX_VALUE, "Maximum number of ingots that can be found in a chest from the Jeweler. (It's the chest from the back part)"); + INGOT_CHEST_MAX_STACK = config.getInt("Ingot Chest Max Stack", categories[1], 2, 0, Integer.MAX_VALUE, "Maximum number of the stack the ingots can be. For example: if set to 2 and ingots have a chance of generating, you have a chance of getting a stack of max 2 ingots in a chest."); + GEM_CHEST_MIN = config.getInt("Jewelers Chest Min", categories[1], 2, 0, Integer.MAX_VALUE, "Determines the minimum nuber of jewels/modifiers that can be generated in the front chests of a Jeweler."); + GEM_CHEST_MAX = config.getInt("Jewelers Chest Max", categories[1], 5, 0, Integer.MAX_VALUE, "Determines the maximum nuber of jewels/modifiers that can be generated in the front chests of a Jeweler."); + FURNACE_MIN_INGOT_STACK = config.getInt("Ingot Furnace Min", categories[1], 2, 0, Integer.MAX_VALUE, "Determines the minimum number of ingots that can generate in a furnace."); + FURNACE_MAX_INGOT_STACK = config.getInt("Ingot Furnace Max", categories[1], 5, 0, Integer.MAX_VALUE, "Determines the maximum number of ingots that can generate in a furnace."); + if (config.hasChanged()) config.save(); + } + + @SubscribeEvent + public void onConfigChanged(ConfigChangedEvent.OnConfigChangedEvent event) { - if (!isInitialized){ - config = new Configuration(new File(e.getModConfigurationDirectory(), Variables.MODID+".cfg")); - config.load(); - ingotCoolingTime = config.get("Timers", "Molder Ingot Cooling Time", ingotCoolingTime, "This sets the number of ticks you need to wait before the mold is cooled.").getInt(); - ingotMeltingTime = config.get("Timers", "Ingot Melting Time", ingotMeltingTime, "This sets the number of ticks you need to wait before an ingot is completely smelted.").getInt(); - jewelryCraftingTime = config.get("Timers", "Jewelry Crafting Time", jewelryCraftingTime, "This sets the number of ticks it takes for a jewel to be modified.").getInt(); - generateVillageNetherstar = config.get("Village Generation", "Netherstar Generation", generateVillageNetherstar, "If set to true Nether Stars will be able to generate in Jewelers chests.").getBoolean(generateVillageNetherstar); - canFurnacesGenerateIngots = config.get("Village Generation", "Furnace Ingots Generation", canFurnacesGenerateIngots, "If set to true jewelers will generate ingots in furnaces.").getBoolean(canFurnacesGenerateIngots); - maxVillageJewelers = config.get("Village Generation", "Maximum Jewelers", maxVillageJewelers, "Sets how many jewelers can be in a village.").getInt(); - jewelerWeight = config.get("Village Generation", "Jewelers Weight", jewelerWeight, "Chance of getting a jeweler in a village. The higher the value, the higher the chance.").getInt(); - ingotChestMin = config.get("Village Generation", "Ingot Chest Min", ingotChestMin, "Minimum number of ingots that can be found in a chest from the Jeweler. (It's the chest from the back part)").getInt(); - ingotChestMax = config.get("Village Generation", "Ingot Chest Max", ingotChestMax, "Maximum number of ingots that can be found in a chest from the Jeweler. (It's the chest from the back part)").getInt(); - ingotChestMaxStack = config.get("Village Generation", "Ingot Chest Max Stack", ingotChestMaxStack, "Maximum number of the stack the ingots can be. For example: if set to 2 and ingots have a chance of generating, you have a chance of getting a stack of max 2 ingots in a chest.").getInt(); - jewelsChestMin = config.get("Village Generation", "Jewelers Chest Min", jewelsChestMin, "Determines the minimum nuber of jewels/modifiers that can be generated in the front chests of a Jeweler.").getInt(); - jewelsChestMax = config.get("Village Generation", "Jewelers Chest Max", jewelsChestMax, "Determines the maximum nuber of jewels/modifiers that can be generated in the front chests of a Jeweler.").getInt(); - furnacesIngotStackMin = config.get("Village Generation", "Ingot Furnace Min", furnacesIngotStackMin, "Determines the minimum number of ingots that can generate in a furnace.").getInt(); - furnacesIngotStackMax = config.get("Village Generation", "Ingot Furnace Max", furnacesIngotStackMax, "Determines the maximum number of ingots that can generate in a furnace.").getInt(); - config.save(); - isInitialized = true; - } + if (event.modID.equals(Variables.MODID)) syncConfigs(); } } diff --git a/src/main/java/darkknight/jewelrycraft/curses/CurseList.java b/src/main/java/darkknight/jewelrycraft/curses/CurseList.java index a076e07..e4105c8 100644 --- a/src/main/java/darkknight/jewelrycraft/curses/CurseList.java +++ b/src/main/java/darkknight/jewelrycraft/curses/CurseList.java @@ -5,21 +5,20 @@ import darkknight.jewelrycraft.util.Variables; public class CurseList { - private static Curse rotten, flaming, blind, greed, infamy; - private static boolean isInitialized = false; + private static Curse rotten; + private static Curse flaming; + private static Curse blind; + private static Curse greed; + private static Curse infamy; + private static Curse midasTouch; - /** - * @param e - */ public static void preInit(FMLPreInitializationEvent e) { - if (!isInitialized){ - rotten = new CurseRottenHeart(0, Variables.MODNAME + ":" + "Rotten Heart", 0); - flaming = new CurseFlamingSoul(1, Variables.MODNAME + ":" + "Flaming Soul", 0); - greed = new CurseGreed(2, Variables.MODNAME + ":" + "Greed", 0); - blind = new CurseBlind(3, Variables.MODNAME + ":" + "Blind", 0); - infamy = new CurseInfamy(4, Variables.MODNAME + ":" + "Infamy", 0); - isInitialized = true; - } + rotten = new CurseRottenHeart(0, Variables.MODNAME + ":" + "Rotten Heart", 0); + flaming = new CurseFlamingSoul(1, Variables.MODNAME + ":" + "Flaming Soul", 0); + greed = new CurseGreed(2, Variables.MODNAME + ":" + "Greed", 0); + blind = new CurseBlind(3, Variables.MODNAME + ":" + "Blind", 0); + infamy = new CurseInfamy(4, Variables.MODNAME + ":" + "Infamy", 0); + midasTouch = new CurseMidasTouch(5, Variables.MODNAME + ":" + "Midas Touch", 0); } } diff --git a/src/main/java/darkknight/jewelrycraft/curses/CurseMidasTouch.java b/src/main/java/darkknight/jewelrycraft/curses/CurseMidasTouch.java new file mode 100644 index 0000000..a2a6da7 --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/curses/CurseMidasTouch.java @@ -0,0 +1,94 @@ +package darkknight.jewelrycraft.curses; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockCompressed; +import net.minecraft.block.BlockPressurePlate; +import net.minecraft.block.BlockPressurePlateWeighted; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLiving; +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.ItemArmor; +import net.minecraft.item.ItemAxe; +import net.minecraft.item.ItemHoe; +import net.minecraft.item.ItemPickaxe; +import net.minecraft.item.ItemSpade; +import net.minecraft.item.ItemStack; +import net.minecraft.item.ItemSword; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; +import darkknight.jewelrycraft.block.BlockList; +import darkknight.jewelrycraft.entities.EntityHalfHeart; +import darkknight.jewelrycraft.entities.EntityHeart; +import darkknight.jewelrycraft.item.ItemList; +import darkknight.jewelrycraft.tileentity.TileEntityMidasTouch; +import darkknight.jewelrycraft.util.JewelryNBT; +import darkknight.jewelrycraft.util.JewelrycraftUtil; + +public class CurseMidasTouch extends Curse +{ + public CurseMidasTouch(int id, String name, int text) + { + super(id, name, text); + } + + @Override + public void attackedByPlayerAction(World world, EntityPlayer player, Entity target) + { + if (!world.isRemote && target instanceof EntityLiving && !(target instanceof EntityHeart) && !(target instanceof EntityHalfHeart) && player.inventory.getCurrentItem() == null){ + world.setBlock(MathHelper.floor_double(target.posX), MathHelper.floor_double(target.posY), MathHelper.floor_double(target.posZ), BlockList.midasTouchBlock, 0, 2); + TileEntityMidasTouch midasTouchVictim = new TileEntityMidasTouch(); + midasTouchVictim.setEntity(target); + world.setTileEntity(MathHelper.floor_double(target.posX), MathHelper.floor_double(target.posY), MathHelper.floor_double(target.posZ), midasTouchVictim); + target.setDead(); + } + } + + @Override + public void action(World world, EntityPlayer player) + { + ItemStack curItem = player.inventory.getCurrentItem(); + if(curItem != null && curItem.getItem() != ItemList.goldObj && !isGoldenObject(curItem.getItem())){ + int index = player.inventory.currentItem; + ItemStack item = curItem; + ItemStack result = new ItemStack(ItemList.goldObj, item.stackSize, item.getItemDamage()); + JewelryNBT.addItem(result, item); + if(changeItem(curItem) != null) result = changeItem(curItem); + player.inventory.setInventorySlotContents(index, result); + } + } + + public ItemStack changeItem(ItemStack currItem) + { + if(currItem.getItem() instanceof ItemSword) return new ItemStack(Items.golden_sword, currItem.stackSize, currItem.getItemDamage()); + else if(currItem.getItem() instanceof ItemSpade) return new ItemStack(Items.golden_shovel, currItem.stackSize, currItem.getItemDamage()); + else if(currItem.getItem() instanceof ItemPickaxe) return new ItemStack(Items.golden_pickaxe, currItem.stackSize, currItem.getItemDamage()); + else if(currItem.getItem() instanceof ItemAxe) return new ItemStack(Items.golden_axe, currItem.stackSize, currItem.getItemDamage()); + else if(currItem.getItem() instanceof ItemHoe) return new ItemStack(Items.golden_hoe, currItem.stackSize, currItem.getItemDamage()); + else if(currItem.getItem() instanceof ItemArmor && ((ItemArmor)currItem.getItem()).armorType == 0) return new ItemStack(Items.golden_helmet, currItem.stackSize, currItem.getItemDamage()); + else if(currItem.getItem() instanceof ItemArmor && ((ItemArmor)currItem.getItem()).armorType == 1) return new ItemStack(Items.golden_chestplate, currItem.stackSize, currItem.getItemDamage()); + else if(currItem.getItem() instanceof ItemArmor && ((ItemArmor)currItem.getItem()).armorType == 2) return new ItemStack(Items.golden_leggings, currItem.stackSize, currItem.getItemDamage()); + else if(currItem.getItem() instanceof ItemArmor && ((ItemArmor)currItem.getItem()).armorType == 3) return new ItemStack(Items.golden_boots, currItem.stackSize, currItem.getItemDamage()); + else if(currItem.getItem().getUnlocalizedName().toLowerCase().contains("horsearmor")) return new ItemStack(Items.golden_horse_armor, currItem.stackSize, 0); + else if(currItem.getItem().getUnlocalizedName().toLowerCase().contains("nugget") || currItem.getItem().getItemStackDisplayName(currItem).toLowerCase().contains(" nugget") || currItem.getItem().getItemStackDisplayName(currItem).toLowerCase().contains("nugget ")) return new ItemStack(Items.gold_nugget, currItem.stackSize, 0); + else if(currItem.getItem().getUnlocalizedName().toLowerCase().contains("ingot") || currItem.getItem().getItemStackDisplayName(currItem).toLowerCase().contains(" ingot") || currItem.getItem().getItemStackDisplayName(currItem).toLowerCase().contains("ingot ")) return new ItemStack(Items.gold_ingot, currItem.stackSize, 0); + else if(Block.getBlockFromItem(currItem.getItem()) instanceof BlockPressurePlate || Block.getBlockFromItem(currItem.getItem()) instanceof BlockPressurePlateWeighted) return new ItemStack(Blocks.light_weighted_pressure_plate, currItem.stackSize, 0); + else if(Block.getBlockFromItem(currItem.getItem()) instanceof BlockCompressed) return new ItemStack(Blocks.gold_block, currItem.stackSize, 0); + return null; + } + + public boolean isGoldenObject(Item item) + { + return item.equals(Items.gold_ingot) || item.equals(Items.gold_nugget) || item.equals(Items.golden_helmet) || item.equals(Items.golden_chestplate) || + item.equals(Items.golden_leggings) || item.equals(Items.golden_boots) || item.equals(Items.golden_sword) || item.equals(Items.golden_shovel) || + item.equals(Items.golden_pickaxe) || item.equals(Items.golden_axe) || item.equals(Items.golden_hoe) || item.equals(Items.golden_horse_armor) || + Block.getBlockFromItem(item).equals(Blocks.gold_block) || Block.getBlockFromItem(item).equals(Blocks.light_weighted_pressure_plate); + } + + public String getDescription() + { + return "Be careful what you wish for..."; + } +} diff --git a/src/main/java/darkknight/jewelrycraft/events/BlockEventHandler.java b/src/main/java/darkknight/jewelrycraft/events/BlockEventHandler.java new file mode 100644 index 0000000..81fe34b --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/events/BlockEventHandler.java @@ -0,0 +1,40 @@ +/** + * + */ +package darkknight.jewelrycraft.events; + +import net.minecraft.entity.item.EntityItem; +import net.minecraft.init.Items; +import net.minecraft.item.ItemPickaxe; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; +import net.minecraftforge.event.world.BlockEvent; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import darkknight.jewelrycraft.block.BlockMidasTouch; +import darkknight.jewelrycraft.tileentity.TileEntityMidasTouch; + +/** + * @author Sorin + */ +public class BlockEventHandler +{ + @SubscribeEvent + public void onBlockDestroyed(BlockEvent.BreakEvent event) + { + // System.out.println("Broken " + event.getResult()); + ItemStack item = event.getPlayer().inventory.getCurrentItem(); + if (event.block instanceof BlockMidasTouch && item != null && item.getItem().getHarvestLevel(item, "pickaxe") >= event.block.getHarvestLevel(event.blockMetadata)){ + TileEntityMidasTouch te = (TileEntityMidasTouch)event.world.getTileEntity(event.x, event.y, event.z); + if (te.target != null) dropItem(te.getWorldObj(), te.xCoord, te.yCoord, te.zCoord, new ItemStack(Items.gold_nugget, (int)(te.target.width * te.target.height * 100), 0)); + } + } + + 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); + } +} diff --git a/src/main/java/darkknight/jewelrycraft/events/EventCommonHandler.java b/src/main/java/darkknight/jewelrycraft/events/EventCommonHandler.java new file mode 100644 index 0000000..9919a3f --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/events/EventCommonHandler.java @@ -0,0 +1,17 @@ +package darkknight.jewelrycraft.events; + +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.gameevent.PlayerEvent; + +/** + * @author Sorin + * + */ +public class EventCommonHandler +{ + @SubscribeEvent + public void onItemCrafted(PlayerEvent.ItemCraftedEvent event) + { +// System.out.println(event.crafting + " " + event.craftMatrix.getInventoryName()); + } +} diff --git a/src/main/java/darkknight/jewelrycraft/events/PlayerRenderHandler.java b/src/main/java/darkknight/jewelrycraft/events/PlayerRenderHandler.java index 146b7d6..3ff5ed4 100644 --- a/src/main/java/darkknight/jewelrycraft/events/PlayerRenderHandler.java +++ b/src/main/java/darkknight/jewelrycraft/events/PlayerRenderHandler.java @@ -36,7 +36,6 @@ public class PlayerRenderHandler while (players.hasNext()){ EntityPlayer player = players.next(); NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID); -// System.out.println(event.entityPlayer + " | " + player + " | " + playerInfo); if (checkPlayerInfamy(player.getDisplayName()) && event.entityPlayer.getDisplayName().equals(player.getDisplayName()) && playerInfo.getInteger("cursePoints") > 0){ float yaw = player.prevRotationYawHead + (player.rotationYawHead - player.prevRotationYawHead) * event.partialRenderTick; float yawOffset = player.prevRenderYawOffset + (player.renderYawOffset - player.prevRenderYawOffset) * event.partialRenderTick; diff --git a/src/main/java/darkknight/jewelrycraft/item/ItemGoldObj.java b/src/main/java/darkknight/jewelrycraft/item/ItemGoldObj.java new file mode 100644 index 0000000..20bc0a8 --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/item/ItemGoldObj.java @@ -0,0 +1,60 @@ +/** + * + */ +package darkknight.jewelrycraft.item; + +import java.util.List; +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.item.ItemFood; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.IIcon; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import darkknight.jewelrycraft.util.JewelryNBT; + +public class ItemGoldObj extends Item +{ + public ItemGoldObj() + {} + + public boolean requiresMultipleRenderPasses() + { + return true; + } + + @SideOnly (Side.CLIENT) + public boolean hasEffect(ItemStack item) + { + return true; + } + + @SideOnly (Side.CLIENT) + public int getColorFromItemStack(ItemStack stack, int pass) + { + return 0xffff00; + } + + @Override + public IIcon getIcon(ItemStack stack, int pass) + { + ItemStack item = JewelryNBT.item(stack); + if (item != null) return item.getIconIndex(); + return itemIcon; + } + + public String getItemStackDisplayName(ItemStack stack) + { + return "Golden " + ((JewelryNBT.item(stack) != null) ? JewelryNBT.item(stack).getDisplayName() : "Object"); + } + + public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean displayInfo) + { + if (displayInfo) + if(JewelryNBT.item(stack).getItem() instanceof ItemFood) list.add(EnumChatFormatting.DARK_PURPLE + "It's made of solid gold. How are you suppose to eat this?"); + else list.add(EnumChatFormatting.DARK_PURPLE + "Shiny, but useless :("); + } +} diff --git a/src/main/java/darkknight/jewelrycraft/item/ItemList.java b/src/main/java/darkknight/jewelrycraft/item/ItemList.java index f14d9fc..01f16ca 100644 --- a/src/main/java/darkknight/jewelrycraft/item/ItemList.java +++ b/src/main/java/darkknight/jewelrycraft/item/ItemList.java @@ -21,6 +21,7 @@ public class ItemList public static Item jewelryModifier; public static ItemMoltenMetalBucket bucket; public static ItemMoltenMetal metal; + public static Item goldObj; private static boolean isInitialized = false; /** @@ -42,6 +43,8 @@ public class ItemList bucket = (ItemMoltenMetalBucket)new ItemMoltenMetalBucket().setUnlocalizedName(Variables.MODID + ".bucket"); metal = (ItemMoltenMetal)new ItemMoltenMetal().setUnlocalizedName(Variables.MODID + ".bucket"); jewelryModifier = new ItemJewelryModifier().setUnlocalizedName(Variables.MODID + ".jewelryModifier").setTextureName(Variables.MODID + ":jewelryModifier").setCreativeTab(JewelrycraftMod.jewelrycraft); + goldObj = new ItemGoldObj().setUnlocalizedName(Variables.MODID + ".goldObject"); + GameRegistry.registerItem(thiefGloves, "thiefGloves"); GameRegistry.registerItem(shadowIngot, "shadowIngot"); GameRegistry.registerItem(molds, "molds"); @@ -55,6 +58,7 @@ public class ItemList GameRegistry.registerItem(bucket, "moltenMetalBucket"); GameRegistry.registerItem(metal, "moltenMetal"); GameRegistry.registerItem(jewelryModifier, "jewelryModifier"); + GameRegistry.registerItem(goldObj, "goldObject"); isInitialized = true; } } diff --git a/src/main/java/darkknight/jewelrycraft/item/ItemThiefGloves.java b/src/main/java/darkknight/jewelrycraft/item/ItemThiefGloves.java index 1a99cf8..decf34e 100644 --- a/src/main/java/darkknight/jewelrycraft/item/ItemThiefGloves.java +++ b/src/main/java/darkknight/jewelrycraft/item/ItemThiefGloves.java @@ -28,9 +28,6 @@ public class ItemThiefGloves extends Item { public Random rand = new Random(); - /** - * - */ public ItemThiefGloves() { super(); diff --git a/src/main/java/darkknight/jewelrycraft/item/render/ItemRender.java b/src/main/java/darkknight/jewelrycraft/item/render/ItemRender.java index 144b2af..a150ae0 100644 --- a/src/main/java/darkknight/jewelrycraft/item/render/ItemRender.java +++ b/src/main/java/darkknight/jewelrycraft/item/render/ItemRender.java @@ -1,17 +1,34 @@ package darkknight.jewelrycraft.item.render; +import net.minecraft.block.Block; +import net.minecraft.block.BlockAnvil; +import net.minecraft.block.BlockHopper; +import net.minecraft.client.Minecraft; import net.minecraft.client.model.ModelBase; -import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; -import net.minecraft.item.ItemStack; +import net.minecraft.client.renderer.*; +import net.minecraft.client.renderer.entity.RenderItem; +import net.minecraft.client.renderer.texture.*; +import net.minecraft.client.renderer.tileentity.*; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.init.Blocks; +import net.minecraft.item.*; +import net.minecraft.src.FMLRenderAccessLibrary; import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.client.IItemRenderer; +import net.minecraft.util.IIcon; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.client.*; import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL12; +import darkknight.jewelrycraft.util.JewelryNBT; public class ItemRender implements IItemRenderer { TileEntitySpecialRenderer render; public TileEntity entity; ModelBase model; + private RenderBlocks renderBlocksIr = new RenderBlocks(); + private Minecraft mc = Minecraft.getMinecraft(); + private static final ResourceLocation RES_ITEM_GLINT = new ResourceLocation("textures/misc/enchanted_item_glint.png"); /** * @param render @@ -25,6 +42,9 @@ public class ItemRender implements IItemRenderer this.model = model; } + public ItemRender() + {} + /** * @param item * @param type @@ -56,10 +76,503 @@ public class ItemRender implements IItemRenderer @Override public void renderItem(ItemRenderType type, ItemStack item, Object ... data) { - if (type == IItemRenderer.ItemRenderType.ENTITY){ - GL11.glRotatef(180f, 0f, 1f, 0f); - GL11.glTranslatef(-0.5f, -0.5f, -0.4f); + if (render != null && entity != null && JewelryNBT.item(item) == null){ + if (type == IItemRenderer.ItemRenderType.ENTITY){ + GL11.glRotatef(180f, 0f, 1f, 0f); + GL11.glTranslatef(-0.5f, -0.5f, -0.4f); + } + render.renderTileEntityAt(entity, 0.0D, 0.0D, 0.0D, 0.0F); + }else if (JewelryNBT.item(item) != null){ + GL11.glPushMatrix(); + GL11.glColor3f(1F, 1F, 0F); + renderItem(Minecraft.getMinecraft().thePlayer, JewelryNBT.item(item), 0, type); + GL11.glPopMatrix(); + } + } + + public void renderItem(EntityLivingBase entity, ItemStack itemStack, int meta, ItemRenderType type) + { + GL11.glPushMatrix(); + TextureManager texturemanager = this.mc.getTextureManager(); + Item item = itemStack.getItem(); + Block block = Block.getBlockFromItem(item); + IItemRenderer customRenderer = MinecraftForgeClient.getItemRenderer(itemStack, type); + if (customRenderer != null){ + texturemanager.bindTexture(texturemanager.getResourceLocation(itemStack.getItemSpriteNumber())); + if (type.equals(type.EQUIPPED)) GL11.glTranslatef(0.7F, 0.55F, 0.55F); + ForgeHooksClient.renderEquippedItem(type, customRenderer, renderBlocksIr, entity, itemStack); + }else if (itemStack.getItemSpriteNumber() == 0 && item instanceof ItemBlock && RenderBlocks.renderItemIn3d(block.getRenderType())){ + texturemanager.bindTexture(texturemanager.getResourceLocation(0)); + if (type.equals(type.EQUIPPED)) GL11.glTranslatef(0.5F, 0.5F, 0.5F); + if (itemStack != null && block != null && block.getRenderBlockPass() != 0){ + GL11.glDepthMask(false); + renderBlockAsItem(block, itemStack.getItemDamage(), 1.0F); + GL11.glDepthMask(true); + }else{ + renderBlockAsItem(block, itemStack.getItemDamage(), 1.0F); + } + }else{ + IIcon iicon = itemStack.getIconIndex(); + if (iicon == null){ + GL11.glPopMatrix(); + return; + } + texturemanager.bindTexture(texturemanager.getResourceLocation(itemStack.getItemSpriteNumber())); + TextureUtil.func_152777_a(false, false, 1.0F); + Tessellator tessellator = Tessellator.instance; + float f = iicon.getMinU(); + float f1 = iicon.getMaxU(); + float f2 = iicon.getMinV(); + float f3 = iicon.getMaxV(); + float f4 = 0.0F; + float f5 = 0.3F; + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + float f6 = 1.6F; + GL11.glScalef(f6, f6, f6); + if(type.equals(type.ENTITY)){ + GL11.glTranslatef(0.0F, 0.0265F, 0.0F); + GL11.glRotatef(-30F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(45F, 0.0F, 1.0F, 0.0F); + GL11.glScalef(0.625F, 0.625F, 0.625F); + } + if (!type.equals(type.EQUIPPED_FIRST_PERSON)){ + GL11.glRotatef(45f, 0f, 1f, 0f); + GL11.glRotatef(180f, 0f, 1f, 0f); + GL11.glRotatef(30f, 1f, 0f, 0f); + if (type.equals(type.EQUIPPED)){ + GL11.glRotatef(35f, 1f, 0f, 0f); + GL11.glTranslatef(0F, -0.15F, -0.6F); + } + GL11.glTranslatef(-0.5F, -0.5F, 0.0F); + } + else if(type.equals(type.EQUIPPED_FIRST_PERSON)){ + GL11.glTranslatef(-0.35F, 0.4F, 0.93F); + GL11.glRotatef(45f, 0f, 1f, 0f); + GL11.glRotatef(-25f, 0f, 0f, 1f); + } + if (itemStack.getItem().requiresMultipleRenderPasses()){ + for(int x = 0; x < itemStack.getItem().getRenderPasses(itemStack.getItemDamage()); x++){ + iicon = itemStack.getItem().getIcon(itemStack, x); + f = iicon.getMinU(); + f1 = iicon.getMaxU(); + f2 = iicon.getMinV(); + f3 = iicon.getMaxV(); + ItemRenderer.renderItemIn2D(tessellator, f1, f2, f, f3, iicon.getIconWidth(), iicon.getIconHeight(), 0.0625F); + } + }else{ + ItemRenderer.renderItemIn2D(tessellator, f1, f2, f, f3, iicon.getIconWidth(), iicon.getIconHeight(), 0.0625F); + } + GL11.glDepthFunc(GL11.GL_EQUAL); + texturemanager.bindTexture(RES_ITEM_GLINT); + GL11.glEnable(GL11.GL_BLEND); + OpenGlHelper.glBlendFunc(768, 1, 1, 0); + GL11.glMatrixMode(GL11.GL_TEXTURE); + GL11.glPushMatrix(); + float f8 = 0.325F; + GL11.glScalef(f8, f8, f8); + GL11.glTranslatef(17F, 0.0F, 0.0F); + GL11.glRotatef(-30.0F, 0.0F, 0.0F, 1.0F); + GL11.glColor3f(1F, 1F, 0F); + ItemRenderer.renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 256, 256, 0.0625F); + GL11.glPopMatrix(); + GL11.glPushMatrix(); + GL11.glScalef(f8, f8, f8); + float f9 = (float)(Minecraft.getSystemTime() % 30000L) / 30000.0F * 8.0F; + GL11.glTranslatef(-f9, 0.0F, 0.0F); + GL11.glRotatef(30.0F, 0.0F, 0.0F, 1.0F); + ItemRenderer.renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 256, 256, 0.0625F); + GL11.glPopMatrix(); + GL11.glMatrixMode(GL11.GL_MODELVIEW); + GL11.glDisable(GL11.GL_BLEND); + GL11.glDepthFunc(GL11.GL_LEQUAL); + GL11.glDisable(GL12.GL_RESCALE_NORMAL); + texturemanager.bindTexture(texturemanager.getResourceLocation(itemStack.getItemSpriteNumber())); + TextureUtil.func_147945_b(); + } + GL11.glPopMatrix(); + } + + public void renderBlockAsItem(Block block, int damage, float luminacy) + { + Tessellator tessellator = Tessellator.instance; + boolean flag = block == Blocks.grass; + if (block == Blocks.dispenser || block == Blocks.dropper || block == Blocks.furnace) damage = 3; + int j; + float f1; + float f2; + GL11.glColor4f(1F, 1F, 0F, 1.0F); + j = block.getRenderType(); + renderBlocksIr.setRenderBoundsFromBlock(block); + int k; + if (j != 0 && j != 31 && j != 39 && j != 16 && j != 26){ + GL11.glColor4f(1F, 1F, 0F, 1.0F); + if (j == 1){ + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, -1.0F, 0.0F); + IIcon iicon = renderBlocksIr.getBlockIconFromSideAndMetadata(block, 0, damage); + renderBlocksIr.drawCrossedSquares(iicon, -0.5D, -0.5D, -0.5D, 1.0F); + tessellator.draw(); + }else if (j == 19){ + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, -1.0F, 0.0F); + block.setBlockBoundsForItemRender(); + renderBlocksIr.renderBlockStemSmall(block, damage, renderBlocksIr.renderMaxY, -0.5D, -0.5D, -0.5D); + tessellator.draw(); + }else if (j == 23){ + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, -1.0F, 0.0F); + block.setBlockBoundsForItemRender(); + tessellator.draw(); + }else if (j == 13){ + block.setBlockBoundsForItemRender(); + GL11.glTranslatef(-0.5F, -0.5F, -0.5F); + f1 = 0.0625F; + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, -1.0F, 0.0F); + renderBlocksIr.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, renderBlocksIr.getBlockIconFromSide(block, 0)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 1.0F, 0.0F); + renderBlocksIr.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, renderBlocksIr.getBlockIconFromSide(block, 1)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 0.0F, -1.0F); + tessellator.addTranslation(0.0F, 0.0F, f1); + renderBlocksIr.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, renderBlocksIr.getBlockIconFromSide(block, 2)); + tessellator.addTranslation(0.0F, 0.0F, -f1); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 0.0F, 1.0F); + tessellator.addTranslation(0.0F, 0.0F, -f1); + renderBlocksIr.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, renderBlocksIr.getBlockIconFromSide(block, 3)); + tessellator.addTranslation(0.0F, 0.0F, f1); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(-1.0F, 0.0F, 0.0F); + tessellator.addTranslation(f1, 0.0F, 0.0F); + renderBlocksIr.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, renderBlocksIr.getBlockIconFromSide(block, 4)); + tessellator.addTranslation(-f1, 0.0F, 0.0F); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(1.0F, 0.0F, 0.0F); + tessellator.addTranslation(-f1, 0.0F, 0.0F); + renderBlocksIr.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, renderBlocksIr.getBlockIconFromSide(block, 5)); + tessellator.addTranslation(f1, 0.0F, 0.0F); + tessellator.draw(); + GL11.glTranslatef(0.5F, 0.5F, 0.5F); + }else if (j == 22){ + GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F); + GL11.glTranslatef(-0.5F, -0.5F, -0.5F); + TileEntityRendererChestHelper.instance.renderChest(block, damage, luminacy); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + }else if (j == 6){ + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, -1.0F, 0.0F); + renderBlocksIr.renderBlockCropsImpl(block, damage, -0.5D, -0.5D, -0.5D); + tessellator.draw(); + }else if (j == 2){ + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, -1.0F, 0.0F); + renderBlocksIr.renderTorchAtAngle(block, -0.5D, -0.5D, -0.5D, 0.0D, 0.0D, 0); + tessellator.draw(); + }else if (j == 10){ + for(k = 0; k < 2; ++k){ + if (k == 0){ + renderBlocksIr.setRenderBounds(0.0D, 0.0D, 0.0D, 1.0D, 1.0D, 0.5D); + } + if (k == 1){ + renderBlocksIr.setRenderBounds(0.0D, 0.0D, 0.5D, 1.0D, 0.5D, 1.0D); + } + GL11.glTranslatef(-0.5F, -0.5F, -0.5F); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, -1.0F, 0.0F); + renderBlocksIr.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, renderBlocksIr.getBlockIconFromSide(block, 0)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 1.0F, 0.0F); + renderBlocksIr.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, renderBlocksIr.getBlockIconFromSide(block, 1)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 0.0F, -1.0F); + renderBlocksIr.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, renderBlocksIr.getBlockIconFromSide(block, 2)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 0.0F, 1.0F); + renderBlocksIr.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, renderBlocksIr.getBlockIconFromSide(block, 3)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(-1.0F, 0.0F, 0.0F); + renderBlocksIr.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, renderBlocksIr.getBlockIconFromSide(block, 4)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(1.0F, 0.0F, 0.0F); + renderBlocksIr.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, renderBlocksIr.getBlockIconFromSide(block, 5)); + tessellator.draw(); + GL11.glTranslatef(0.5F, 0.5F, 0.5F); + } + }else if (j == 27){ + k = 0; + GL11.glTranslatef(-0.5F, -0.5F, -0.5F); + tessellator.startDrawingQuads(); + for(int l = 0; l < 8; ++l){ + byte b0 = 0; + byte b1 = 1; + if (l == 0){ + b0 = 2; + } + if (l == 1){ + b0 = 3; + } + if (l == 2){ + b0 = 4; + } + if (l == 3){ + b0 = 5; + b1 = 2; + } + if (l == 4){ + b0 = 6; + b1 = 3; + } + if (l == 5){ + b0 = 7; + b1 = 5; + } + if (l == 6){ + b0 = 6; + b1 = 2; + } + if (l == 7){ + b0 = 3; + } + float f5 = (float)b0 / 16.0F; + float f6 = 1.0F - (float)k / 16.0F; + float f7 = 1.0F - (float)(k + b1) / 16.0F; + k += b1; + renderBlocksIr.setRenderBounds((double)(0.5F - f5), (double)f7, (double)(0.5F - f5), (double)(0.5F + f5), (double)f6, (double)(0.5F + f5)); + tessellator.setNormal(0.0F, -1.0F, 0.0F); + renderBlocksIr.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, renderBlocksIr.getBlockIconFromSide(block, 0)); + tessellator.setNormal(0.0F, 1.0F, 0.0F); + renderBlocksIr.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, renderBlocksIr.getBlockIconFromSide(block, 1)); + tessellator.setNormal(0.0F, 0.0F, -1.0F); + renderBlocksIr.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, renderBlocksIr.getBlockIconFromSide(block, 2)); + tessellator.setNormal(0.0F, 0.0F, 1.0F); + renderBlocksIr.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, renderBlocksIr.getBlockIconFromSide(block, 3)); + tessellator.setNormal(-1.0F, 0.0F, 0.0F); + renderBlocksIr.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, renderBlocksIr.getBlockIconFromSide(block, 4)); + tessellator.setNormal(1.0F, 0.0F, 0.0F); + renderBlocksIr.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, renderBlocksIr.getBlockIconFromSide(block, 5)); + } + tessellator.draw(); + GL11.glTranslatef(0.5F, 0.5F, 0.5F); + renderBlocksIr.setRenderBounds(0.0D, 0.0D, 0.0D, 1.0D, 1.0D, 1.0D); + }else if (j == 11){ + for(k = 0; k < 4; ++k){ + f2 = 0.125F; + if (k == 0){ + renderBlocksIr.setRenderBounds((double)(0.5F - f2), 0.0D, 0.0D, (double)(0.5F + f2), 1.0D, (double)(f2 * 2.0F)); + } + if (k == 1){ + renderBlocksIr.setRenderBounds((double)(0.5F - f2), 0.0D, (double)(1.0F - f2 * 2.0F), (double)(0.5F + f2), 1.0D, 1.0D); + } + f2 = 0.0625F; + if (k == 2){ + renderBlocksIr.setRenderBounds((double)(0.5F - f2), (double)(1.0F - f2 * 3.0F), (double)(-f2 * 2.0F), (double)(0.5F + f2), (double)(1.0F - f2), (double)(1.0F + f2 * 2.0F)); + } + if (k == 3){ + renderBlocksIr.setRenderBounds((double)(0.5F - f2), (double)(0.5F - f2 * 3.0F), (double)(-f2 * 2.0F), (double)(0.5F + f2), (double)(0.5F - f2), (double)(1.0F + f2 * 2.0F)); + } + GL11.glTranslatef(-0.5F, -0.5F, -0.5F); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, -1.0F, 0.0F); + renderBlocksIr.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, renderBlocksIr.getBlockIconFromSide(block, 0)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 1.0F, 0.0F); + renderBlocksIr.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, renderBlocksIr.getBlockIconFromSide(block, 1)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 0.0F, -1.0F); + renderBlocksIr.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, renderBlocksIr.getBlockIconFromSide(block, 2)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 0.0F, 1.0F); + renderBlocksIr.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, renderBlocksIr.getBlockIconFromSide(block, 3)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(-1.0F, 0.0F, 0.0F); + renderBlocksIr.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, renderBlocksIr.getBlockIconFromSide(block, 4)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(1.0F, 0.0F, 0.0F); + renderBlocksIr.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, renderBlocksIr.getBlockIconFromSide(block, 5)); + tessellator.draw(); + GL11.glTranslatef(0.5F, 0.5F, 0.5F); + } + renderBlocksIr.setRenderBounds(0.0D, 0.0D, 0.0D, 1.0D, 1.0D, 1.0D); + }else if (j == 21){ + for(k = 0; k < 3; ++k){ + f2 = 0.0625F; + if (k == 0){ + renderBlocksIr.setRenderBounds((double)(0.5F - f2), 0.30000001192092896D, 0.0D, (double)(0.5F + f2), 1.0D, (double)(f2 * 2.0F)); + } + if (k == 1){ + renderBlocksIr.setRenderBounds((double)(0.5F - f2), 0.30000001192092896D, (double)(1.0F - f2 * 2.0F), (double)(0.5F + f2), 1.0D, 1.0D); + } + f2 = 0.0625F; + if (k == 2){ + renderBlocksIr.setRenderBounds((double)(0.5F - f2), 0.5D, 0.0D, (double)(0.5F + f2), (double)(1.0F - f2), 1.0D); + } + GL11.glTranslatef(-0.5F, -0.5F, -0.5F); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, -1.0F, 0.0F); + renderBlocksIr.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, renderBlocksIr.getBlockIconFromSide(block, 0)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 1.0F, 0.0F); + renderBlocksIr.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, renderBlocksIr.getBlockIconFromSide(block, 1)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 0.0F, -1.0F); + renderBlocksIr.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, renderBlocksIr.getBlockIconFromSide(block, 2)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 0.0F, 1.0F); + renderBlocksIr.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, renderBlocksIr.getBlockIconFromSide(block, 3)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(-1.0F, 0.0F, 0.0F); + renderBlocksIr.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, renderBlocksIr.getBlockIconFromSide(block, 4)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(1.0F, 0.0F, 0.0F); + renderBlocksIr.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, renderBlocksIr.getBlockIconFromSide(block, 5)); + tessellator.draw(); + GL11.glTranslatef(0.5F, 0.5F, 0.5F); + } + }else if (j == 32){ + for(k = 0; k < 2; ++k){ + if (k == 0){ + renderBlocksIr.setRenderBounds(0.0D, 0.0D, 0.3125D, 1.0D, 0.8125D, 0.6875D); + } + if (k == 1){ + renderBlocksIr.setRenderBounds(0.25D, 0.0D, 0.25D, 0.75D, 1.0D, 0.75D); + } + GL11.glTranslatef(-0.5F, -0.5F, -0.5F); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, -1.0F, 0.0F); + renderBlocksIr.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, renderBlocksIr.getBlockIconFromSideAndMetadata(block, 0, damage)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 1.0F, 0.0F); + renderBlocksIr.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, renderBlocksIr.getBlockIconFromSideAndMetadata(block, 1, damage)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 0.0F, -1.0F); + renderBlocksIr.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, renderBlocksIr.getBlockIconFromSideAndMetadata(block, 2, damage)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 0.0F, 1.0F); + renderBlocksIr.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, renderBlocksIr.getBlockIconFromSideAndMetadata(block, 3, damage)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(-1.0F, 0.0F, 0.0F); + renderBlocksIr.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, renderBlocksIr.getBlockIconFromSideAndMetadata(block, 4, damage)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(1.0F, 0.0F, 0.0F); + renderBlocksIr.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, renderBlocksIr.getBlockIconFromSideAndMetadata(block, 5, damage)); + tessellator.draw(); + GL11.glTranslatef(0.5F, 0.5F, 0.5F); + } + renderBlocksIr.setRenderBounds(0.0D, 0.0D, 0.0D, 1.0D, 1.0D, 1.0D); + }else if (j == 35){ + GL11.glTranslatef(-0.5F, -0.5F, -0.5F); + renderBlocksIr.renderBlockAnvilOrient((BlockAnvil)block, 0, 0, 0, damage << 2, true); + GL11.glTranslatef(0.5F, 0.5F, 0.5F); + }else if (j == 34){ + for(k = 0; k < 3; ++k){ + if (k == 0){ + renderBlocksIr.setRenderBounds(0.125D, 0.0D, 0.125D, 0.875D, 0.1875D, 0.875D); + renderBlocksIr.setOverrideBlockTexture(renderBlocksIr.getBlockIcon(Blocks.obsidian)); + }else if (k == 1){ + renderBlocksIr.setRenderBounds(0.1875D, 0.1875D, 0.1875D, 0.8125D, 0.875D, 0.8125D); + renderBlocksIr.setOverrideBlockTexture(renderBlocksIr.getBlockIcon(Blocks.beacon)); + }else if (k == 2){ + renderBlocksIr.setRenderBounds(0.0D, 0.0D, 0.0D, 1.0D, 1.0D, 1.0D); + renderBlocksIr.setOverrideBlockTexture(renderBlocksIr.getBlockIcon(Blocks.glass)); + } + GL11.glTranslatef(-0.5F, -0.5F, -0.5F); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, -1.0F, 0.0F); + renderBlocksIr.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, renderBlocksIr.getBlockIconFromSideAndMetadata(block, 0, damage)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 1.0F, 0.0F); + renderBlocksIr.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, renderBlocksIr.getBlockIconFromSideAndMetadata(block, 1, damage)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 0.0F, -1.0F); + renderBlocksIr.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, renderBlocksIr.getBlockIconFromSideAndMetadata(block, 2, damage)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 0.0F, 1.0F); + renderBlocksIr.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, renderBlocksIr.getBlockIconFromSideAndMetadata(block, 3, damage)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(-1.0F, 0.0F, 0.0F); + renderBlocksIr.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, renderBlocksIr.getBlockIconFromSideAndMetadata(block, 4, damage)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(1.0F, 0.0F, 0.0F); + renderBlocksIr.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, renderBlocksIr.getBlockIconFromSideAndMetadata(block, 5, damage)); + tessellator.draw(); + GL11.glTranslatef(0.5F, 0.5F, 0.5F); + } + renderBlocksIr.setRenderBounds(0.0D, 0.0D, 0.0D, 1.0D, 1.0D, 1.0D); + renderBlocksIr.clearOverrideBlockTexture(); + }else if (j == 38){ + GL11.glTranslatef(-0.5F, -0.5F, -0.5F); + renderBlocksIr.renderBlockHopperMetadata((BlockHopper)block, 0, 0, 0, 0, true); + GL11.glTranslatef(0.5F, 0.5F, 0.5F); + }else{ + FMLRenderAccessLibrary.renderInventoryBlock(renderBlocksIr, block, damage, j); + } + }else{ + if (j == 16){ + damage = 1; + } + block.setBlockBoundsForItemRender(); + renderBlocksIr.setRenderBoundsFromBlock(block); + GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F); + GL11.glTranslatef(-0.5F, -0.5F, -0.5F); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, -1.0F, 0.0F); + renderBlocksIr.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, renderBlocksIr.getBlockIconFromSideAndMetadata(block, 0, damage)); + tessellator.draw(); + GL11.glColor4f(1F, 1F, 0F, 1.0F); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 1.0F, 0.0F); + renderBlocksIr.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, renderBlocksIr.getBlockIconFromSideAndMetadata(block, 1, damage)); + tessellator.draw(); + GL11.glColor4f(1F, 1F, 0F, 1.0F); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 0.0F, -1.0F); + renderBlocksIr.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, renderBlocksIr.getBlockIconFromSideAndMetadata(block, 2, damage)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 0.0F, 1.0F); + renderBlocksIr.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, renderBlocksIr.getBlockIconFromSideAndMetadata(block, 3, damage)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(-1.0F, 0.0F, 0.0F); + renderBlocksIr.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, renderBlocksIr.getBlockIconFromSideAndMetadata(block, 4, damage)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(1.0F, 0.0F, 0.0F); + renderBlocksIr.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, renderBlocksIr.getBlockIconFromSideAndMetadata(block, 5, damage)); + tessellator.draw(); + GL11.glTranslatef(0.5F, 0.5F, 0.5F); } - render.renderTileEntityAt(entity, 0.0D, 0.0D, 0.0D, 0.0F); } } diff --git a/src/main/java/darkknight/jewelrycraft/proxy/ClientProxy.java b/src/main/java/darkknight/jewelrycraft/proxy/ClientProxy.java index 08b9b0d..3709b5f 100644 --- a/src/main/java/darkknight/jewelrycraft/proxy/ClientProxy.java +++ b/src/main/java/darkknight/jewelrycraft/proxy/ClientProxy.java @@ -7,6 +7,7 @@ import net.minecraftforge.client.MinecraftForgeClient; import net.minecraftforge.common.MinecraftForge; import cpw.mods.fml.client.registry.ClientRegistry; import cpw.mods.fml.client.registry.RenderingRegistry; +import cpw.mods.fml.common.Loader; import cpw.mods.fml.common.registry.VillagerRegistry; import darkknight.jewelrycraft.block.BlockList; import darkknight.jewelrycraft.client.InventoryTabVanilla; @@ -17,6 +18,7 @@ import darkknight.jewelrycraft.entities.EntityHeart; import darkknight.jewelrycraft.entities.renders.HeartRender; import darkknight.jewelrycraft.events.PlayerRenderHandler; import darkknight.jewelrycraft.events.ScreenHandler; +import darkknight.jewelrycraft.item.ItemList; import darkknight.jewelrycraft.item.render.ItemRender; import darkknight.jewelrycraft.model.ModelDisplayer; import darkknight.jewelrycraft.model.ModelHalfHeart; @@ -30,6 +32,7 @@ import darkknight.jewelrycraft.model.ModelSmelter; import darkknight.jewelrycraft.tileentity.TileEntityDisplayer; import darkknight.jewelrycraft.tileentity.TileEntityHandPedestal; import darkknight.jewelrycraft.tileentity.TileEntityJewelrsCraftingTable; +import darkknight.jewelrycraft.tileentity.TileEntityMidasTouch; import darkknight.jewelrycraft.tileentity.TileEntityMolder; import darkknight.jewelrycraft.tileentity.TileEntityShadowEye; import darkknight.jewelrycraft.tileentity.TileEntityShadowHand; @@ -37,6 +40,7 @@ import darkknight.jewelrycraft.tileentity.TileEntitySmelter; import darkknight.jewelrycraft.tileentity.renders.TileEntityDisplayerRender; import darkknight.jewelrycraft.tileentity.renders.TileEntityHandPedestalRender; import darkknight.jewelrycraft.tileentity.renders.TileEntityJewelrsCraftingTableRender; +import darkknight.jewelrycraft.tileentity.renders.TileEntityMidasTouchRender; import darkknight.jewelrycraft.tileentity.renders.TileEntityMolderRender; import darkknight.jewelrycraft.tileentity.renders.TileEntityShadowEyeRender; import darkknight.jewelrycraft.tileentity.renders.TileEntityShadowHandRender; @@ -59,6 +63,7 @@ public class ClientProxy extends CommonProxy ClientRegistry.bindTileEntitySpecialRenderer(TileEntityJewelrsCraftingTable.class, new TileEntityJewelrsCraftingTableRender()); ClientRegistry.bindTileEntitySpecialRenderer(TileEntityDisplayer.class, new TileEntityDisplayerRender()); ClientRegistry.bindTileEntitySpecialRenderer(TileEntityShadowEye.class, new TileEntityShadowEyeRender()); + ClientRegistry.bindTileEntitySpecialRenderer(TileEntityMidasTouch.class, new TileEntityMidasTouchRender()); ClientRegistry.bindTileEntitySpecialRenderer(TileEntityHandPedestal.class, pedestalRender); ClientRegistry.bindTileEntitySpecialRenderer(TileEntityShadowHand.class, shadowHandRender); @@ -69,11 +74,13 @@ public class ClientProxy extends CommonProxy MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(BlockList.shadowEye), new ItemRender(new TileEntityShadowEyeRender(), new TileEntityShadowEye(), new ModelShadowEye())); MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(BlockList.handPedestal), new ItemRender(pedestalRender, new TileEntityHandPedestal(), new ModelHandPedestal(pedestalResourceLocation))); MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(BlockList.shadowHand), new ItemRender(shadowHandRender, new TileEntityShadowHand(), new ModelShadowHand(shadowResourceLocation))); + MinecraftForgeClient.registerItemRenderer(ItemList.goldObj, new ItemRender()); + VillagerRegistry.instance().registerVillagerSkin(3000, new ResourceLocation(Variables.MODID, "textures/entities/jeweler.png")); RenderingRegistry.registerEntityRenderingHandler(EntityHeart.class, new HeartRender(new ModelHeart(), 0.25F)); RenderingRegistry.registerEntityRenderingHandler(EntityHalfHeart.class, new HeartRender(new ModelHalfHeart(), 0.25F)); - + TabRegistry.registerTab(new InventoryTabVanilla()); TabRegistry.registerTab(new TabJewelry()); MinecraftForge.EVENT_BUS.register(new TabRegistry()); diff --git a/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityJewelrsCraftingTable.java b/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityJewelrsCraftingTable.java index c148bd0..cb216a0 100644 --- a/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityJewelrsCraftingTable.java +++ b/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityJewelrsCraftingTable.java @@ -98,7 +98,7 @@ public class TileEntityJewelrsCraftingTable extends TileEntity else angle = 0F; if (hasJewelry && hasGem && !hasEndItem && crafting){ if (carving > 0) carving--; - if (crafting) for(int l = 0; l < ConfigHandler.jewelryCraftingTime / (carving + 2); ++l){ + if (crafting) for(int l = 0; l < ConfigHandler.GEM_PLACEMENT_TIME / (carving + 2); ++l){ if (worldObj.rand.nextInt(10) == 0) worldObj.playSoundEffect(xCoord, yCoord + 0.5F, zCoord, "random.orb", 0.05F, 1F); if (getBlockMetadata() == 0) worldObj.spawnParticle("instantSpell", xCoord + 0.5F, (double)yCoord + 0.8F, zCoord + 0.2F, 0.0D, 0.0D, 0.0D); if (getBlockMetadata() == 1) worldObj.spawnParticle("instantSpell", xCoord + 0.8F, (double)yCoord + 0.8F, zCoord + 0.5F, 0.0D, 0.0D, 0.0D); diff --git a/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityMidasTouch.java b/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityMidasTouch.java new file mode 100644 index 0000000..1cee6d0 --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityMidasTouch.java @@ -0,0 +1,83 @@ +package darkknight.jewelrycraft.tileentity; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityList; +import net.minecraft.entity.EntityLivingBase; +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 TileEntityMidasTouch extends TileEntity +{ + public Entity target; + + public TileEntityMidasTouch() + {} + + public void setEntity(Entity ent) + { + target = ent; + } + + @Override + public void writeToNBT(NBTTagCompound nbt) + { + super.writeToNBT(nbt); + if (target != null){ + int id = EntityList.getEntityID(target); + NBTTagCompound tag = new NBTTagCompound(); + target.writeToNBT(tag); + nbt.setInteger("entityID", id); + nbt.setTag("entity", tag); + } + } + + /** + * @param nbt + */ + @Override + public void readFromNBT(NBTTagCompound nbt) + { + super.readFromNBT(nbt); + NBTTagCompound en = (NBTTagCompound)nbt.getTag("entity"); + int entityID = nbt.getInteger("entityID"); + EntityLivingBase entity = (EntityLivingBase)EntityList.createEntityByID(entityID, worldObj); + if (entity != null){ + entity.readFromNBT(en); + target = entity; + } + } + + /** + * + */ + @Override + public boolean canUpdate() + { + return false; + } + + /** + * @return + */ + @Override + public Packet getDescriptionPacket() + { + NBTTagCompound nbttagcompound = new NBTTagCompound(); + writeToNBT(nbttagcompound); + return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, nbttagcompound); + } + + /** + * @param net + * @param packet + */ + @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/TileEntityShadowEye.java b/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityShadowEye.java index c6e9da5..5174d44 100644 --- a/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityShadowEye.java +++ b/src/main/java/darkknight/jewelrycraft/tileentity/TileEntityShadowEye.java @@ -14,6 +14,7 @@ import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; import darkknight.jewelrycraft.block.BlockHandPedestal; import darkknight.jewelrycraft.block.BlockList; +import darkknight.jewelrycraft.config.ConfigHandler; import darkknight.jewelrycraft.particles.EntityShadowsFX; import darkknight.jewelrycraft.util.JewelryNBT; import darkknight.jewelrycraft.util.JewelrycraftUtil; @@ -93,7 +94,7 @@ public class TileEntityShadowEye extends TileEntity opening++; timer = 20; } - if (valid && opening == 4) timer = 1000; + if (valid && opening == 4) timer = ConfigHandler.RITUAL_TIME; else if (!valid){ active = false; timer = -1; diff --git a/src/main/java/darkknight/jewelrycraft/tileentity/TileEntitySmelter.java b/src/main/java/darkknight/jewelrycraft/tileentity/TileEntitySmelter.java index 83f2cb2..b9a276b 100644 --- a/src/main/java/darkknight/jewelrycraft/tileentity/TileEntitySmelter.java +++ b/src/main/java/darkknight/jewelrycraft/tileentity/TileEntitySmelter.java @@ -149,14 +149,14 @@ public class TileEntitySmelter extends TileEntity if (pouredQuantity <= 0f){ pouring = false; pouredQuantity = 0.1f; - me.cooling = ConfigHandler.ingotCoolingTime; + me.cooling = ConfigHandler.INGOT_COOLING_TIME; } if (quantity <= 0f){ quantity = 0f; hasMoltenMetal = false; moltenMetal = new ItemStack(Item.getItemById(0), 0, 0); // pouring = false; - me.cooling = ConfigHandler.ingotCoolingTime; + me.cooling = ConfigHandler.INGOT_COOLING_TIME; } me.isDirty = true; } diff --git a/src/main/java/darkknight/jewelrycraft/tileentity/renders/TileEntityMidasTouchRender.java b/src/main/java/darkknight/jewelrycraft/tileentity/renders/TileEntityMidasTouchRender.java new file mode 100644 index 0000000..bac8e8e --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/tileentity/renders/TileEntityMidasTouchRender.java @@ -0,0 +1,27 @@ +package darkknight.jewelrycraft.tileentity.renders; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.entity.EntityLiving; +import net.minecraft.tileentity.TileEntity; +import org.lwjgl.opengl.GL11; +import darkknight.jewelrycraft.tileentity.TileEntityMidasTouch; + +public class TileEntityMidasTouchRender extends TileEntitySpecialRenderer +{ + @Override + public void renderTileEntityAt(TileEntity te, double x, double y, double z, float scale) + { + GL11.glPushMatrix(); + TileEntityMidasTouch midas = (TileEntityMidasTouch)te; + if (midas.target != null){ + EntityLiving target = ((EntityLiving)midas.target); + target.hurtTime = 0; + GL11.glTranslatef(0.5F, 0.0F, 0.5F); + GL11.glColor3f(1.0F, 1.0F, 0.0F); + RenderManager.instance.renderEntityWithPosYaw(target, midas.xCoord - RenderManager.instance.renderPosX, midas.yCoord - RenderManager.instance.renderPosY, midas.zCoord - RenderManager.instance.renderPosZ, 0F, 1F); + } + GL11.glPopMatrix(); + } +} diff --git a/src/main/java/darkknight/jewelrycraft/util/JewelryNBT.java b/src/main/java/darkknight/jewelrycraft/util/JewelryNBT.java index f16c074..295a776 100644 --- a/src/main/java/darkknight/jewelrycraft/util/JewelryNBT.java +++ b/src/main/java/darkknight/jewelrycraft/util/JewelryNBT.java @@ -16,6 +16,21 @@ import net.minecraft.world.World; public class JewelryNBT { // TODO NBT Tag Adding + public static void addItem(ItemStack item, ItemStack target) + { + if (target != null){ + NBTTagCompound itemStackData; + if (item.hasTagCompound()) itemStackData = item.getTagCompound(); + else{ + itemStackData = new NBTTagCompound(); + item.setTagCompound(itemStackData); + } + NBTTagCompound targetNBT = new NBTTagCompound(); + target.writeToNBT(targetNBT); + itemStackData.setTag("target", targetNBT); + } + } + /** * @param item The item you want to add the NBT data on * @param metal The metal you want to add on the item @@ -448,6 +463,17 @@ public class JewelryNBT } // TODO Return components based on NBT + public static ItemStack item(ItemStack stack) + { + if (stack != null && stack != new ItemStack(Item.getItemById(0), 0, 0) && stack.hasTagCompound() && stack.getTagCompound().hasKey("target")){ + NBTTagCompound itemNBT = (NBTTagCompound)stack.getTagCompound().getTag("target"); + ItemStack target = new ItemStack(Item.getItemById(0), 0, 0); + target.readFromNBT(itemNBT); + return target; + } + return null; + } + /** * @param stack * @return diff --git a/src/main/java/darkknight/jewelrycraft/util/Variables.java b/src/main/java/darkknight/jewelrycraft/util/Variables.java index f45f5c6..aa67e22 100644 --- a/src/main/java/darkknight/jewelrycraft/util/Variables.java +++ b/src/main/java/darkknight/jewelrycraft/util/Variables.java @@ -7,4 +7,7 @@ public class Variables public static final String VERSION = "1.0"; public static final String PACKET_CHANNEL = "jewelrycraft2"; public static final int MAX_CURSES = 10; + public static final String CONFIG_GUI = "darkknight.jewelrycraft.config.ConfigGuiFactory"; + public static final String CLIENT_PROXY = "darkknight.jewelrycraft.proxy.ClientProxy"; + public static final String SERVER_PROXY = "darkknight.jewelrycraft.proxy.CommonProxy"; } diff --git a/src/main/java/darkknight/jewelrycraft/worldGen/village/ComponentJewelry.java b/src/main/java/darkknight/jewelrycraft/worldGen/village/ComponentJewelry.java index c50e321..2e8bbd1 100644 --- a/src/main/java/darkknight/jewelrycraft/worldGen/village/ComponentJewelry.java +++ b/src/main/java/darkknight/jewelrycraft/worldGen/village/ComponentJewelry.java @@ -166,29 +166,29 @@ public class ComponentJewelry extends StructureVillagePieces.House1 for(int i = 4; i <= 7; i++) for(int j = 1; j <= 5; j++) placeBlockAtCurrentPosition(world, Blocks.carpet, bgCarpetColor, i, 1, j, sbb); - generateChest(world, 3, 1, 1, 0, random, sbb, ConfigHandler.jewelsChestMin, ConfigHandler.jewelsChestMax); + generateChest(world, 3, 1, 1, 0, random, sbb, ConfigHandler.GEM_CHEST_MIN, ConfigHandler.GEM_CHEST_MAX); 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, ConfigHandler.jewelsChestMin, ConfigHandler.jewelsChestMax); - generateFurnace(world, 1, 1, 7, 0, random, sbb, ConfigHandler.furnacesIngotStackMin, ConfigHandler.furnacesIngotStackMax, ConfigHandler.canFurnacesGenerateIngots); - generateFurnace(world, 1, 2, 7, 0, random, sbb, ConfigHandler.furnacesIngotStackMin, ConfigHandler.furnacesIngotStackMax, ConfigHandler.canFurnacesGenerateIngots); - generateFurnace(world, 1, 3, 7, 0, random, sbb, ConfigHandler.furnacesIngotStackMin, ConfigHandler.furnacesIngotStackMax, ConfigHandler.canFurnacesGenerateIngots); - generateFurnace(world, 1, 1, 10, 0, random, sbb, ConfigHandler.furnacesIngotStackMin, ConfigHandler.furnacesIngotStackMax, ConfigHandler.canFurnacesGenerateIngots); - generateFurnace(world, 1, 2, 10, 0, random, sbb, ConfigHandler.furnacesIngotStackMin, ConfigHandler.furnacesIngotStackMax, ConfigHandler.canFurnacesGenerateIngots); - generateFurnace(world, 1, 3, 10, 0, random, sbb, ConfigHandler.furnacesIngotStackMin, ConfigHandler.furnacesIngotStackMax, ConfigHandler.canFurnacesGenerateIngots); + generateChest(world, 3, 1, 5, 0, random, sbb, ConfigHandler.GEM_CHEST_MIN, ConfigHandler.GEM_CHEST_MAX); + generateFurnace(world, 1, 1, 7, 0, random, sbb, ConfigHandler.FURNACE_MIN_INGOT_STACK, ConfigHandler.FURNACE_MAX_INGOT_STACK, ConfigHandler.CAN_FURNACE_GENERATE_INGOTS); + generateFurnace(world, 1, 2, 7, 0, random, sbb, ConfigHandler.FURNACE_MIN_INGOT_STACK, ConfigHandler.FURNACE_MAX_INGOT_STACK, ConfigHandler.CAN_FURNACE_GENERATE_INGOTS); + generateFurnace(world, 1, 3, 7, 0, random, sbb, ConfigHandler.FURNACE_MIN_INGOT_STACK, ConfigHandler.FURNACE_MAX_INGOT_STACK, ConfigHandler.CAN_FURNACE_GENERATE_INGOTS); + generateFurnace(world, 1, 1, 10, 0, random, sbb, ConfigHandler.FURNACE_MIN_INGOT_STACK, ConfigHandler.FURNACE_MAX_INGOT_STACK, ConfigHandler.CAN_FURNACE_GENERATE_INGOTS); + generateFurnace(world, 1, 2, 10, 0, random, sbb, ConfigHandler.FURNACE_MIN_INGOT_STACK, ConfigHandler.FURNACE_MAX_INGOT_STACK, ConfigHandler.CAN_FURNACE_GENERATE_INGOTS); + generateFurnace(world, 1, 3, 10, 0, random, sbb, ConfigHandler.FURNACE_MIN_INGOT_STACK, ConfigHandler.FURNACE_MAX_INGOT_STACK, ConfigHandler.CAN_FURNACE_GENERATE_INGOTS); 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()); - if (random.nextBoolean()) generateIngotChest(world, 9, 1, 7, 0, random, sbb, ConfigHandler.ingotChestMin, ConfigHandler.ingotChestMax, Blocks.chest, ConfigHandler.ingotChestMaxStack); - else generateOresChest(world, 9, 1, 7, 0, random, sbb, ConfigHandler.ingotChestMin, ConfigHandler.ingotChestMax, Blocks.chest, ConfigHandler.ingotChestMaxStack); - if (random.nextBoolean()) generateIngotChest(world, 9, 1, 8, 0, random, sbb, ConfigHandler.ingotChestMin, ConfigHandler.ingotChestMax, Blocks.chest, ConfigHandler.ingotChestMaxStack); - else generateOresChest(world, 9, 1, 8, 0, random, sbb, ConfigHandler.ingotChestMin, ConfigHandler.ingotChestMax, Blocks.chest, ConfigHandler.ingotChestMaxStack); - if (random.nextBoolean()) generateIngotChest(world, 9, 1, 9, 0, random, sbb, ConfigHandler.ingotChestMin, ConfigHandler.ingotChestMax, Blocks.trapped_chest, ConfigHandler.ingotChestMaxStack); - else generateOresChest(world, 9, 1, 9, 0, random, sbb, ConfigHandler.ingotChestMin, ConfigHandler.ingotChestMax, Blocks.trapped_chest, ConfigHandler.ingotChestMaxStack); - if (random.nextBoolean()) generateIngotChest(world, 9, 1, 10, 0, random, sbb, ConfigHandler.ingotChestMin, ConfigHandler.ingotChestMax, Blocks.trapped_chest, ConfigHandler.ingotChestMaxStack); - else generateOresChest(world, 9, 1, 10, 0, random, sbb, ConfigHandler.ingotChestMin, ConfigHandler.ingotChestMax, Blocks.trapped_chest, ConfigHandler.ingotChestMaxStack); + if (random.nextBoolean()) generateIngotChest(world, 9, 1, 7, 0, random, sbb, ConfigHandler.INGOT_CHEST_MIN, ConfigHandler.INGOT_CHEST_MAX, Blocks.chest, ConfigHandler.INGOT_CHEST_MAX_STACK); + else generateOresChest(world, 9, 1, 7, 0, random, sbb, ConfigHandler.INGOT_CHEST_MIN, ConfigHandler.INGOT_CHEST_MAX, Blocks.chest, ConfigHandler.INGOT_CHEST_MAX_STACK); + if (random.nextBoolean()) generateIngotChest(world, 9, 1, 8, 0, random, sbb, ConfigHandler.INGOT_CHEST_MIN, ConfigHandler.INGOT_CHEST_MAX, Blocks.chest, ConfigHandler.INGOT_CHEST_MAX_STACK); + else generateOresChest(world, 9, 1, 8, 0, random, sbb, ConfigHandler.INGOT_CHEST_MIN, ConfigHandler.INGOT_CHEST_MAX, Blocks.chest, ConfigHandler.INGOT_CHEST_MAX_STACK); + if (random.nextBoolean()) generateIngotChest(world, 9, 1, 9, 0, random, sbb, ConfigHandler.INGOT_CHEST_MIN, ConfigHandler.INGOT_CHEST_MAX, Blocks.trapped_chest, ConfigHandler.INGOT_CHEST_MAX_STACK); + else generateOresChest(world, 9, 1, 9, 0, random, sbb, ConfigHandler.INGOT_CHEST_MIN, ConfigHandler.INGOT_CHEST_MAX, Blocks.trapped_chest, ConfigHandler.INGOT_CHEST_MAX_STACK); + if (random.nextBoolean()) generateIngotChest(world, 9, 1, 10, 0, random, sbb, ConfigHandler.INGOT_CHEST_MIN, ConfigHandler.INGOT_CHEST_MAX, Blocks.trapped_chest, ConfigHandler.INGOT_CHEST_MAX_STACK); + else generateOresChest(world, 9, 1, 10, 0, random, sbb, ConfigHandler.INGOT_CHEST_MIN, ConfigHandler.INGOT_CHEST_MAX, Blocks.trapped_chest, ConfigHandler.INGOT_CHEST_MAX_STACK); for(int l = 0; l < 6; ++l) for(int i1 = 2; i1 < 9; ++i1){ clearCurrentPositionBlocksUpwards(world, i1, 9, l, sbb); @@ -225,7 +225,7 @@ public class ComponentJewelry extends StructureVillagePieces.House1 while (chest != null && t > 0){ ItemStack jewels = JewelrycraftUtil.gem.get(random.nextInt(JewelrycraftUtil.gem.size())); chest.func_145976_a("Jeweler's Chest"); - if (jewels.getItem() == Items.nether_star && ConfigHandler.generateVillageNetherstar) chest.setInventorySlotContents(random.nextInt(chest.getSizeInventory()), jewels); + if (jewels.getItem() == Items.nether_star && ConfigHandler.GENERATE_VILLAGE_NETHERSTAR) chest.setInventorySlotContents(random.nextInt(chest.getSizeInventory()), jewels); else if (random.nextBoolean() && jewels.getItem() != Items.nether_star) chest.setInventorySlotContents(random.nextInt(chest.getSizeInventory()), jewels); t--; } diff --git a/src/main/java/darkknight/jewelrycraft/worldGen/village/VillageJewelryHandler.java b/src/main/java/darkknight/jewelrycraft/worldGen/village/VillageJewelryHandler.java index a2c3d62..d860db7 100644 --- a/src/main/java/darkknight/jewelrycraft/worldGen/village/VillageJewelryHandler.java +++ b/src/main/java/darkknight/jewelrycraft/worldGen/village/VillageJewelryHandler.java @@ -18,7 +18,7 @@ public class VillageJewelryHandler implements IVillageCreationHandler @Override public PieceWeight getVillagePieceWeight(Random random, int i) { - return new PieceWeight(ComponentJewelry.class, ConfigHandler.jewelerWeight, ConfigHandler.maxVillageJewelers); + return new PieceWeight(ComponentJewelry.class, ConfigHandler.JEWELER_WEIGHT, ConfigHandler.MAX_VILLAGE_JEWELERS); } /** |
