From 46186569d5cb462f90e59a37dc17a9fad51cfa4a Mon Sep 17 00:00:00 2001 From: OnyxDarkKnight Date: Wed, 1 Jul 2015 16:11:31 +0100 Subject: Added a curse tab, added a config to enable/disable extra jewelry info, plus more! --- .../java/darkknight/jewelrycraft/api/Curse.java | 5 +- .../darkknight/jewelrycraft/client/TabCurses.java | 27 +++ .../jewelrycraft/client/TabRegistry.java | 170 ++++++++-------- .../jewelrycraft/client/gui/GuiCurseInfo.java | 189 +++++++++++------ .../jewelrycraft/client/gui/GuiHandler.java | 185 ++++++++--------- .../jewelrycraft/client/gui/GuiJewelry.java | 148 +++++++------- .../jewelrycraft/config/ConfigHandler.java | 4 +- .../darkknight/jewelrycraft/curses/CurseBlind.java | 7 + .../jewelrycraft/curses/CurseFlamingSoul.java | 72 ++++--- .../darkknight/jewelrycraft/curses/CurseGreed.java | 86 ++++---- .../jewelrycraft/curses/CurseHumbleBundle.java | 141 +++++++------ .../jewelrycraft/curses/CurseInfamy.java | 7 + .../jewelrycraft/curses/CurseMidasTouch.java | 7 + .../jewelrycraft/curses/CursePentagram.java | 185 ++++++++++------- .../jewelrycraft/curses/CurseRabbitsPaw.java | 7 + .../jewelrycraft/curses/CurseRottenHeart.java | 76 +++---- .../jewelrycraft/curses/CurseVampireHunger.java | 86 ++++---- .../jewelrycraft/entities/EntityHeart.java | 225 ++++++++++----------- .../jewelrycraft/events/EntityEventHandler.java | 12 +- .../jewelrycraft/events/KeyBindings.java | 71 +++---- .../jewelrycraft/events/ScreenHandler.java | 116 ++++------- .../jewelrycraft/item/ItemBaseJewelry.java | 3 +- .../jewelrycraft/model/ModelShadowEye.java | 7 +- .../jewelrycraft/network/PacketKeyPressEvent.java | 119 +++++------ .../darkknight/jewelrycraft/proxy/ClientProxy.java | 2 + 25 files changed, 1056 insertions(+), 901 deletions(-) create mode 100644 src/main/java/darkknight/jewelrycraft/client/TabCurses.java (limited to 'src/main/java') diff --git a/src/main/java/darkknight/jewelrycraft/api/Curse.java b/src/main/java/darkknight/jewelrycraft/api/Curse.java index bf21a5e..beff14b 100644 --- a/src/main/java/darkknight/jewelrycraft/api/Curse.java +++ b/src/main/java/darkknight/jewelrycraft/api/Curse.java @@ -15,11 +15,12 @@ import net.minecraftforge.event.world.BlockEvent; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -public class Curse +public abstract class Curse { protected int textureID; protected String name, description, texturePackName; protected Random rand = new Random(); + protected Minecraft mc = Minecraft.getMinecraft(); private static ArrayList curses = new ArrayList(); public static ArrayList availableCurses = new ArrayList(); @@ -44,6 +45,8 @@ public class Curse { return name; } + + public abstract String getDisplayName(); /** * @return The description of the curse diff --git a/src/main/java/darkknight/jewelrycraft/client/TabCurses.java b/src/main/java/darkknight/jewelrycraft/client/TabCurses.java new file mode 100644 index 0000000..e9878b0 --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/client/TabCurses.java @@ -0,0 +1,27 @@ +package darkknight.jewelrycraft.client; + +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import darkknight.jewelrycraft.JewelrycraftMod; +import darkknight.jewelrycraft.item.ItemList; +import darkknight.jewelrycraft.network.PacketKeyPressEvent; + +public class TabCurses extends AbstractTab +{ + public TabCurses() + { + super(0, 0, 0, new ItemStack(Items.ender_eye)); + } + + @Override + public void onTabClicked () + { + JewelrycraftMod.netWrapper.sendToServer(new PacketKeyPressEvent(1)); + } + + @Override + public boolean shouldAddToList () + { + return true; + } +} \ No newline at end of file diff --git a/src/main/java/darkknight/jewelrycraft/client/TabRegistry.java b/src/main/java/darkknight/jewelrycraft/client/TabRegistry.java index 6ba37ad..e35f305 100644 --- a/src/main/java/darkknight/jewelrycraft/client/TabRegistry.java +++ b/src/main/java/darkknight/jewelrycraft/client/TabRegistry.java @@ -1,86 +1,86 @@ -package darkknight.jewelrycraft.client; - -import java.util.ArrayList; -import java.util.List; -import net.minecraft.client.Minecraft; -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; -import darkknight.jewelrycraft.client.*; - -/** - * @author TinkersConstruct - */ -public class TabRegistry -{ - private static ArrayList tabList = new ArrayList(); - - public static void registerTab(AbstractTab tab) - { - tabList.add(tab); - } - - public static ArrayList getTabList() - { - return tabList; - } - - @SideOnly (Side.CLIENT) - @SubscribeEvent - public void guiPostInit(GuiScreenEvent.InitGuiEvent.Post event) - { - 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()) if (Loader.isModLoaded("NotEnoughItems")){ - try{ - // Check whether NEI is hidden and enabled - Class c = Class.forName("codechicken.nei.NEIClientConfig"); - Object hidden = c.getMethod("isHidden").invoke(null); - Object enabled = c.getMethod("isEnabled").invoke(null); - if (hidden != null && hidden instanceof Boolean && enabled != null && enabled instanceof Boolean) if ((Boolean)hidden || !((Boolean)enabled)) guiLeft += 60; - } - catch(Exception e){} - }else guiLeft += 60; - updateTabValues(guiLeft, guiTop, InventoryTabVanilla.class); - addTabsToList(event.buttonList); - } - } - - private static Minecraft mc = FMLClientHandler.instance().getClient(); - - 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) - { - int count = 1; - for(int i = 0; i < tabList.size(); i++){ - AbstractTab t = tabList.get(i); - if (t.shouldAddToList()){ - t.id = count; - t.xPosition = cornerX + 151 + (t.id==1?9:0); - t.yPosition = cornerY + 64; - t.enabled = !t.getClass().equals(selectedButton); - count++; - } - } - } - - public static void addTabsToList(List buttonList) - { - for(AbstractTab tab: tabList) - if (tab.shouldAddToList() && tab.enabled) buttonList.add(tab); - } +package darkknight.jewelrycraft.client; + +import java.util.ArrayList; +import java.util.List; +import net.minecraft.client.Minecraft; +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; +import darkknight.jewelrycraft.client.*; + +/** + * @author TinkersConstruct + */ +public class TabRegistry { + private static ArrayList tabList = new ArrayList(); + + public static void registerTab(AbstractTab tab) { + tabList.add(tab); + } + + public static ArrayList getTabList() { + return tabList; + } + + @SideOnly(Side.CLIENT) + @SubscribeEvent + public void guiPostInit(GuiScreenEvent.InitGuiEvent.Post event) { + 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()) if (Loader.isModLoaded("NotEnoughItems")) { + try { + // Check whether NEI is hidden and enabled + Class c = Class.forName("codechicken.nei.NEIClientConfig"); + Object hidden = c.getMethod("isHidden").invoke(null); + Object enabled = c.getMethod("isEnabled").invoke(null); + if (hidden != null && hidden instanceof Boolean && enabled != null && enabled instanceof Boolean) if ((Boolean) hidden || !((Boolean) enabled)) guiLeft += 60; + } catch (Exception e) { + } + } else guiLeft += 60; + updateTabValues(guiLeft, guiTop, InventoryTabVanilla.class); + addTabsToList(event.buttonList); + } + } + + private static Minecraft mc = FMLClientHandler.instance().getClient(); + + 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) { + int count = 0; + for (int i = 0; i < tabList.size(); i++) { + AbstractTab t = tabList.get(i); + if (t.shouldAddToList()) { + if (selectedButton.equals(TabCurses.class)) { + t.xPosition = cornerX + 195; + t.yPosition = cornerY + count*20; + }else if (selectedButton.equals(TabJewelry.class)) { + t.xPosition = cornerX + 140 + count * 20; + t.yPosition = cornerY + 64; + } else { + t.xPosition = cornerX + 131 + count * 20; + t.yPosition = cornerY + 64; + } + t.enabled = !t.getClass().equals(selectedButton); + if (t.enabled) count++; + } + } + } + + public static void addTabsToList(List buttonList) { + for (AbstractTab tab : tabList) + if (tab.shouldAddToList() && tab.enabled) buttonList.add(tab); + } } \ No newline at end of file diff --git a/src/main/java/darkknight/jewelrycraft/client/gui/GuiCurseInfo.java b/src/main/java/darkknight/jewelrycraft/client/gui/GuiCurseInfo.java index 5489911..2b3faa0 100644 --- a/src/main/java/darkknight/jewelrycraft/client/gui/GuiCurseInfo.java +++ b/src/main/java/darkknight/jewelrycraft/client/gui/GuiCurseInfo.java @@ -1,58 +1,133 @@ -package darkknight.jewelrycraft.client.gui; - -import org.lwjgl.input.Keyboard; -import org.lwjgl.input.Mouse; -import org.lwjgl.opengl.GL11; -import net.minecraft.client.gui.GuiScreen; -import net.minecraft.client.renderer.Tessellator; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.Container; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.ResourceLocation; -import net.minecraft.world.World; -import darkknight.jewelrycraft.JewelrycraftMod; -import darkknight.jewelrycraft.api.Curse; -import darkknight.jewelrycraft.events.PlayerRenderHandler; -import darkknight.jewelrycraft.events.ScreenHandler; -import darkknight.jewelrycraft.network.PacketRequestPlayerInfo; -import darkknight.jewelrycraft.network.PacketSendServerPlayersInfo; -import darkknight.jewelrycraft.util.PlayerUtils; -import darkknight.jewelrycraft.util.Variables; - -public class GuiCurseInfo extends GuiScreen -{ - World world; - EntityPlayer player; - - public GuiCurseInfo(Container container, World world, EntityPlayer player) - { - super(); - this.world = world; - this.player = player; - } - - public void drawScreen(int x, int y, float size) - { - super.drawScreen(x, y, size); - this.drawGradientRect(0, 0, this.width, this.height, -1072689136, -804253680); - int ind = 0; - if (player != null){ - NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID); - if (!playerInfo.hasNoTags()){ - for(Curse curse: Curse.getCurseList()) - if (playerInfo.getInteger(curse.getName()) > 0){ - int halfDescrSize = fontRendererObj.getStringWidth(curse.getDescription()) / 2; - mc.renderEngine.bindTexture(Variables.MISC_TEXTURE); - this.drawRect(0, 12 + ind * 34, this.width, 10 + (ind + 1) * 34, 0xff000000); - mc.renderEngine.bindTexture(new ResourceLocation(Variables.MODID, "textures/gui/" + curse.getTexturePack() + ".png")); - int tag = curse.getTextureID(); - GL11.glColor3f(1F, 1F, 1F); - drawTexturedModalRect(this.width/2 - halfDescrSize - 35, 12 + ind * 34, tag % 8 * 32, tag / 8 * 32, 32, 32); - this.drawString(fontRendererObj, curse.getName().substring(curse.getName().indexOf(':') + 1), this.width/2 - halfDescrSize, 20 + ind * 34, 0xffff00); - this.drawCenteredString(fontRendererObj, curse.getDescription(), this.width/2, 30 + ind * 34, 0xffffff); - ind++; - } - } - } - } +package darkknight.jewelrycraft.client.gui; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.ResourceLocation; +import net.minecraft.world.World; + +import org.lwjgl.opengl.GL11; + +import darkknight.jewelrycraft.api.Curse; +import darkknight.jewelrycraft.client.TabCurses; +import darkknight.jewelrycraft.client.TabRegistry; +import darkknight.jewelrycraft.events.KeyBindings; +import darkknight.jewelrycraft.util.PlayerUtils; +import darkknight.jewelrycraft.util.Variables; + +public class GuiCurseInfo extends GuiContainer { + World world; + EntityPlayer player; + ResourceLocation texture; + + public GuiCurseInfo(Container container, World world, EntityPlayer player, ResourceLocation texture) { + super(container); + this.world = world; + this.player = player; + this.texture = texture; + xSize = 214; + ySize = 166; + } + + public void drawScreen(int x, int y, float size) { + super.drawScreen(x, y, size); + // this.drawGradientRect(0, 0, this.width, this.height, -1072689136, + // -804253680); + // int ind = 0; + // if (player != null){ + // NBTTagCompound playerInfo = + // PlayerUtils.getModPlayerPersistTag(player, Variables.MODID); + // if (!playerInfo.hasNoTags()){ + // for(Curse curse: Curse.getCurseList()) + // if (playerInfo.getInteger(curse.getName()) > 0){ + // int halfDescrSize = + // fontRendererObj.getStringWidth(curse.getDescription()) / 2; + // mc.renderEngine.bindTexture(Variables.MISC_TEXTURE); + // this.drawRect(0, 12 + ind * 34, this.width, 10 + (ind + 1) * 34, + // 0xff000000); + // mc.renderEngine.bindTexture(new ResourceLocation(Variables.MODID, + // "textures/gui/" + curse.getTexturePack() + ".png")); + // int tag = curse.getTextureID(); + // GL11.glColor3f(1F, 1F, 1F); + // drawTexturedModalRect(this.width/2 - halfDescrSize - 35, 12 + ind * + // 34, tag % 8 * 32, tag / 8 * 32, 32, 32); + // this.drawString(fontRendererObj, + // curse.getName().substring(curse.getName().indexOf(':') + 1), + // this.width/2 - halfDescrSize, 20 + ind * 34, 0xffff00); + // this.drawCenteredString(fontRendererObj, curse.getDescription(), + // this.width/2, 30 + ind * 34, 0xffffff); + // ind++; + // } + // } + // } + } + + @Override + public void drawGuiContainerBackgroundLayer(float f, int mouseX, int mouseY) { + GL11.glColor3f(1, 1, 1); + Minecraft.getMinecraft().getTextureManager().bindTexture(texture); + drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize); + int ind = 0; + int size = 32; + if (player != null) { + NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID); + if (!playerInfo.hasNoTags()) { + for (Curse curse : Curse.getCurseList()) + if (playerInfo.getInteger(curse.getName()) > 0) { + mc.renderEngine.bindTexture(Variables.MISC_TEXTURE); + drawTexturedModalRect(guiLeft + 43, guiTop + 5 + (size - 8) * ind, 0, 32, 112, 22); + if (playerInfo.getInteger(curse.getName()) == 1) { + GL11.glPushMatrix(); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glColor4f(1f, 1f, 1f, 0.5f); + drawTexturedModalRect(guiLeft + 134, guiTop + 8 + (size - 8) * ind, 3 * 16, 0, 16, 16); + GL11.glDisable(GL11.GL_BLEND); + GL11.glPopMatrix(); + } + int halfDescrSize = fontRendererObj.getStringWidth(curse.getDescription()) / 2; + mc.renderEngine.bindTexture(new ResourceLocation(Variables.MODID, "textures/gui/" + curse.getTexturePack() + ".png")); + int tag = curse.getTextureID(); + GL11.glPushMatrix(); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glScalef(0.5f, 0.5f, 0.0f); + drawTexturedModalRect(guiLeft*2 + 100, guiTop*2 + 16 + ind * 48, tag % 8 * 32, tag / 8 * 32, 32, 32); + GL11.glPopMatrix(); + this.drawString(fontRendererObj, curse.getDisplayName(), guiLeft + 70, guiTop + 12 + ind * (size - 8), 0xffffff); + // this.drawCenteredString(fontRendererObj, + // curse.getDescription(), this.width/2, 30 + ind * 34, + // 0xffffff); + ind++; + } + } + } + } + + @Override + public void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { + } + + @Override + protected void keyTyped(char charecter, int key) + { + super.keyTyped(charecter, key); + if (key == KeyBindings.curses.getKeyCode()) mc.thePlayer.closeScreen(); + } + + @Override + public void initGui() { + super.initGui(); + int cornerX = guiLeft; + int cornerY = guiTop; + this.buttonList.clear(); + TabRegistry.updateTabValues(cornerX, cornerY, TabCurses.class); + TabRegistry.addTabsToList(this.buttonList); + } + + protected void mouseClicked(int x, int y, int id) { + super.mouseClicked(x, y, id); + } } \ No newline at end of file diff --git a/src/main/java/darkknight/jewelrycraft/client/gui/GuiHandler.java b/src/main/java/darkknight/jewelrycraft/client/gui/GuiHandler.java index b9427d7..e91abc0 100644 --- a/src/main/java/darkknight/jewelrycraft/client/gui/GuiHandler.java +++ b/src/main/java/darkknight/jewelrycraft/client/gui/GuiHandler.java @@ -1,92 +1,93 @@ -package darkknight.jewelrycraft.client.gui; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.InventoryBasic; -import net.minecraft.tileentity.TileEntityChest; -import net.minecraft.util.ResourceLocation; -import net.minecraft.world.World; -import cpw.mods.fml.common.network.IGuiHandler; -import cpw.mods.fml.common.network.NetworkRegistry; -import darkknight.jewelrycraft.JewelrycraftMod; -import darkknight.jewelrycraft.client.JewelryInventory; -import darkknight.jewelrycraft.client.gui.container.ContainerCurseInfo; -import darkknight.jewelrycraft.client.gui.container.ContainerGuide; -import darkknight.jewelrycraft.client.gui.container.ContainerJewelryModifier; -import darkknight.jewelrycraft.client.gui.container.ContainerJewelryTab; -import darkknight.jewelrycraft.client.gui.container.ContainerRingChest; -import darkknight.jewelrycraft.util.Variables; - -public class GuiHandler implements IGuiHandler -{ - ResourceLocation pageTexture = new ResourceLocation(Variables.MODID, "textures/gui/guidePage.png"); - ResourceLocation flippedPageTexture = new ResourceLocation(Variables.MODID, "textures/gui/guidePageFlip.png"); - ResourceLocation chestTexture = new ResourceLocation(Variables.MODID, "textures/gui/chest_ring.png"); - ResourceLocation jewelryInvTexture = new ResourceLocation(Variables.MODID, "textures/gui/jewelry_tab.png"); - ResourceLocation jewlryModTexture = new ResourceLocation(Variables.MODID, "textures/gui/jewelry_modifier.png"); - - /** - * - */ - public GuiHandler() - { - NetworkRegistry.INSTANCE.registerGuiHandler(JewelrycraftMod.instance, this); - } - - /** - * @param ID - * @param player - * @param world - * @param x - * @param y - * @param z - * @return - */ - @Override - public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) - { - switch(ID) - { - case 0: - return new ContainerRingChest(player.inventory, (TileEntityChest)world.getTileEntity(x, y, z)); - case 1: - return new ContainerGuide(); - case 2: - return new ContainerJewelryTab(player, player.inventory, new JewelryInventory(player)); - case 3: - return new ContainerJewelryModifier(player.inventory, new InventoryBasic("ItemModifier", false, 37)); - case 4: - return new ContainerCurseInfo(); - default: - return null; - } - } - - /** - * @param ID - * @param player - * @param world - * @param x - * @param y - * @param z - * @return - */ - @Override - public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) - { - switch(ID) - { - case 0: - return new GuiRingChest((ContainerRingChest)getServerGuiElement(ID, player, world, x, y, z), chestTexture); - case 1: - return new GuiGuide((ContainerGuide)getServerGuiElement(ID, player, world, x, y, z), world, pageTexture, flippedPageTexture); - case 2: - return new GuiJewelry(new ContainerJewelryTab(player, player.inventory, new JewelryInventory(player)), jewelryInvTexture); - case 3: - return new GuiJewelryModifier((ContainerJewelryModifier)getServerGuiElement(ID, player, world, x, y, z), jewlryModTexture); - case 4: - return new GuiCurseInfo((ContainerCurseInfo)getServerGuiElement(ID, player, world, x, y, z), world, player); - default: - return null; - } - } -} +package darkknight.jewelrycraft.client.gui; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.InventoryBasic; +import net.minecraft.tileentity.TileEntityChest; +import net.minecraft.util.ResourceLocation; +import net.minecraft.world.World; +import cpw.mods.fml.common.network.IGuiHandler; +import cpw.mods.fml.common.network.NetworkRegistry; +import darkknight.jewelrycraft.JewelrycraftMod; +import darkknight.jewelrycraft.client.JewelryInventory; +import darkknight.jewelrycraft.client.gui.container.ContainerCurseInfo; +import darkknight.jewelrycraft.client.gui.container.ContainerGuide; +import darkknight.jewelrycraft.client.gui.container.ContainerJewelryModifier; +import darkknight.jewelrycraft.client.gui.container.ContainerJewelryTab; +import darkknight.jewelrycraft.client.gui.container.ContainerRingChest; +import darkknight.jewelrycraft.util.Variables; + +public class GuiHandler implements IGuiHandler +{ + ResourceLocation pageTexture = new ResourceLocation(Variables.MODID, "textures/gui/guidePage.png"); + ResourceLocation flippedPageTexture = new ResourceLocation(Variables.MODID, "textures/gui/guidePageFlip.png"); + ResourceLocation chestTexture = new ResourceLocation(Variables.MODID, "textures/gui/chest_ring.png"); + ResourceLocation jewelryInvTexture = new ResourceLocation(Variables.MODID, "textures/gui/jewelry_tab.png"); + ResourceLocation cursesInvTexture = new ResourceLocation(Variables.MODID, "textures/gui/curses_tab.png"); + ResourceLocation jewlryModTexture = new ResourceLocation(Variables.MODID, "textures/gui/jewelry_modifier.png"); + + /** + * + */ + public GuiHandler() + { + NetworkRegistry.INSTANCE.registerGuiHandler(JewelrycraftMod.instance, this); + } + + /** + * @param ID + * @param player + * @param world + * @param x + * @param y + * @param z + * @return + */ + @Override + public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) + { + switch(ID) + { + case 0: + return new ContainerRingChest(player.inventory, (TileEntityChest)world.getTileEntity(x, y, z)); + case 1: + return new ContainerGuide(); + case 2: + return new ContainerJewelryTab(player, player.inventory, new JewelryInventory(player)); + case 3: + return new ContainerJewelryModifier(player.inventory, new InventoryBasic("ItemModifier", false, 37)); + case 4: + return new ContainerCurseInfo(); + default: + return null; + } + } + + /** + * @param ID + * @param player + * @param world + * @param x + * @param y + * @param z + * @return + */ + @Override + public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) + { + switch(ID) + { + case 0: + return new GuiRingChest((ContainerRingChest)getServerGuiElement(ID, player, world, x, y, z), chestTexture); + case 1: + return new GuiGuide((ContainerGuide)getServerGuiElement(ID, player, world, x, y, z), world, pageTexture, flippedPageTexture); + case 2: + return new GuiJewelry(new ContainerJewelryTab(player, player.inventory, new JewelryInventory(player)), jewelryInvTexture); + case 3: + return new GuiJewelryModifier((ContainerJewelryModifier)getServerGuiElement(ID, player, world, x, y, z), jewlryModTexture); + case 4: + return new GuiCurseInfo((ContainerCurseInfo)getServerGuiElement(ID, player, world, x, y, z), world, player, cursesInvTexture); + default: + return null; + } + } +} diff --git a/src/main/java/darkknight/jewelrycraft/client/gui/GuiJewelry.java b/src/main/java/darkknight/jewelrycraft/client/gui/GuiJewelry.java index fc4f15b..3ca0a20 100644 --- a/src/main/java/darkknight/jewelrycraft/client/gui/GuiJewelry.java +++ b/src/main/java/darkknight/jewelrycraft/client/gui/GuiJewelry.java @@ -1,74 +1,74 @@ -package darkknight.jewelrycraft.client.gui; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.inventory.GuiContainer; -import net.minecraft.client.gui.inventory.GuiInventory; -import net.minecraft.util.ResourceLocation; -import org.lwjgl.opengl.GL11; -import darkknight.jewelrycraft.client.TabJewelry; -import darkknight.jewelrycraft.client.TabRegistry; -import darkknight.jewelrycraft.client.gui.container.ContainerJewelryTab; -import darkknight.jewelrycraft.events.KeyBindings; - -public class GuiJewelry extends GuiContainer -{ - ResourceLocation texture; - - /** - * @param containerJewelryTab - * @param texture - */ - public GuiJewelry(ContainerJewelryTab containerJewelryTab, ResourceLocation texture) - { - super(containerJewelryTab); - xSize = 194; - ySize = 166; - this.texture = texture; - } - - /** - * @param f - * @param mouseX - * @param mouseY - */ - @Override - public void drawGuiContainerBackgroundLayer(float f, int mouseX, int mouseY) - { - GL11.glColor3f(1, 1, 1); - Minecraft.getMinecraft().getTextureManager().bindTexture(texture); - drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize); - GL11.glPushMatrix(); - GuiInventory.func_147046_a(guiLeft - 24, guiTop + 124, 60, (float)(guiLeft - 24) - mouseX, (float)(guiTop + 124 - 90) - mouseY, this.mc.thePlayer); - GL11.glPopMatrix(); - } - - /** - * @param mouseX - * @param mouseY - */ - @Override - public void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - {} - - /** - * @param charecter - * @param key - */ - @Override - protected void keyTyped(char charecter, int key) - { - super.keyTyped(charecter, key); - if (key == KeyBindings.inventory.getKeyCode()) mc.thePlayer.closeScreen(); - } - - @Override - public void initGui () - { - super.initGui(); - int cornerX = guiLeft; - int cornerY = guiTop; - this.buttonList.clear(); - TabRegistry.updateTabValues(cornerX, cornerY, TabJewelry.class); - TabRegistry.addTabsToList(this.buttonList); - } -} +package darkknight.jewelrycraft.client.gui; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.client.gui.inventory.GuiInventory; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; +import darkknight.jewelrycraft.client.TabJewelry; +import darkknight.jewelrycraft.client.TabRegistry; +import darkknight.jewelrycraft.client.gui.container.ContainerJewelryTab; +import darkknight.jewelrycraft.events.KeyBindings; + +public class GuiJewelry extends GuiContainer +{ + ResourceLocation texture; + + /** + * @param containerJewelryTab + * @param texture + */ + public GuiJewelry(ContainerJewelryTab containerJewelryTab, ResourceLocation texture) + { + super(containerJewelryTab); + xSize = 194; + ySize = 166; + this.texture = texture; + } + + /** + * @param f + * @param mouseX + * @param mouseY + */ + @Override + public void drawGuiContainerBackgroundLayer(float f, int mouseX, int mouseY) + { + GL11.glColor3f(1, 1, 1); + Minecraft.getMinecraft().getTextureManager().bindTexture(texture); + drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize); + GL11.glPushMatrix(); + GuiInventory.func_147046_a(guiLeft - 24, guiTop + 124, 60, (float)(guiLeft - 24) - mouseX, (float)(guiTop + 124 - 90) - mouseY, this.mc.thePlayer); + GL11.glPopMatrix(); + } + + /** + * @param mouseX + * @param mouseY + */ + @Override + public void drawGuiContainerForegroundLayer(int mouseX, int mouseY) + {} + + /** + * @param charecter + * @param key + */ + @Override + protected void keyTyped(char charecter, int key) + { + super.keyTyped(charecter, key); + if (key == KeyBindings.inventory.getKeyCode()) mc.thePlayer.closeScreen(); + } + + @Override + public void initGui () + { + super.initGui(); + int cornerX = guiLeft; + int cornerY = guiTop; + this.buttonList.clear(); + TabRegistry.updateTabValues(cornerX, cornerY, TabJewelry.class); + TabRegistry.addTabsToList(this.buttonList); + } +} diff --git a/src/main/java/darkknight/jewelrycraft/config/ConfigHandler.java b/src/main/java/darkknight/jewelrycraft/config/ConfigHandler.java index 115f3b1..8252f1a 100644 --- a/src/main/java/darkknight/jewelrycraft/config/ConfigHandler.java +++ b/src/main/java/darkknight/jewelrycraft/config/ConfigHandler.java @@ -33,6 +33,7 @@ public class ConfigHandler public static boolean CRYSTAL_GLOW; public static boolean HEARTS_DESPAWN; + public static boolean JEWELRY_INFO; public static boolean CURSES_ENABLED = true; public static boolean CURSE_ROTTEN_HEART = true; @@ -68,7 +69,7 @@ public class ConfigHandler 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."); - HEART_DESPAWN_TIME = config.getInt( "Hearts Despawn Time", categories[0], 600, 20, Integer.MAX_VALUE, "This sets the number of ticks it takes for hearts to despawn, 20=1 second"); + HEART_DESPAWN_TIME = config.getInt( "Hearts Despawn Time", categories[0], 900, 20, Integer.MAX_VALUE, "This sets the number of ticks it takes for hearts to despawn, 20=1 second"); 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."); @@ -85,6 +86,7 @@ public class ConfigHandler CRYSTAL_GLOW = config.getBoolean("Crystal Glow", categories[2], false, "If true, then crystal will slowly glow (can cause lag)"); HEARTS_DESPAWN = config.getBoolean("Hearts Despawn", categories[2], true, "If false, then Hearts and Half-hearts will no longer despawn"); + JEWELRY_INFO = config.getBoolean("Jewelry Info", categories[2], true, "If false, then extra info won't be show when hovering over a jewelery."); ENABLE_WORLD_GEN = config.getBoolean("World Generation", categories[3], true, "If false, nothing will generate (this includes ore)"); ORE_GEN = config.getBoolean("Ore Generation", categories[3], true, "If false, ores won't generate"); diff --git a/src/main/java/darkknight/jewelrycraft/curses/CurseBlind.java b/src/main/java/darkknight/jewelrycraft/curses/CurseBlind.java index 932e23b..f7ab76f 100644 --- a/src/main/java/darkknight/jewelrycraft/curses/CurseBlind.java +++ b/src/main/java/darkknight/jewelrycraft/curses/CurseBlind.java @@ -1,6 +1,7 @@ package darkknight.jewelrycraft.curses; import java.util.Random; + import darkknight.jewelrycraft.api.Curse; import darkknight.jewelrycraft.config.ConfigHandler; import darkknight.jewelrycraft.util.Variables; @@ -39,4 +40,10 @@ public class CurseBlind extends Curse { return 7; } + + @Override + public String getDisplayName() + { + return StatCollector.translateToLocal("curse." + Variables.MODID + ".blind"); + } } diff --git a/src/main/java/darkknight/jewelrycraft/curses/CurseFlamingSoul.java b/src/main/java/darkknight/jewelrycraft/curses/CurseFlamingSoul.java index ed7cd2d..4a559b6 100644 --- a/src/main/java/darkknight/jewelrycraft/curses/CurseFlamingSoul.java +++ b/src/main/java/darkknight/jewelrycraft/curses/CurseFlamingSoul.java @@ -1,33 +1,39 @@ -package darkknight.jewelrycraft.curses; - -import darkknight.jewelrycraft.api.Curse; -import darkknight.jewelrycraft.config.ConfigHandler; -import darkknight.jewelrycraft.util.Variables; -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.util.StatCollector; -import net.minecraft.world.World; - -public class CurseFlamingSoul extends Curse -{ - public CurseFlamingSoul(String name, int txtID, String pack) - { - super(name, txtID, pack); - } - - public void attackedByPlayerAction(World world, EntityPlayer player, Entity target) - { - player.setFire(5); - } - - public String getDescription() - { - return StatCollector.translateToLocal("curse." + Variables.MODID + ".flamingsoul.description"); - } - - @Override - public boolean canCurseBeActivated(World world) - { - return ConfigHandler.CURSE_FLAMING_SOUL; - } -} +package darkknight.jewelrycraft.curses; + +import darkknight.jewelrycraft.api.Curse; +import darkknight.jewelrycraft.config.ConfigHandler; +import darkknight.jewelrycraft.util.Variables; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.StatCollector; +import net.minecraft.world.World; + +public class CurseFlamingSoul extends Curse +{ + public CurseFlamingSoul(String name, int txtID, String pack) + { + super(name, txtID, pack); + } + + public void attackedByPlayerAction(World world, EntityPlayer player, Entity target) + { + player.setFire(5); + } + + public String getDescription() + { + return StatCollector.translateToLocal("curse." + Variables.MODID + ".flamingsoul.description"); + } + + @Override + public boolean canCurseBeActivated(World world) + { + return ConfigHandler.CURSE_FLAMING_SOUL; + } + + @Override + public String getDisplayName() + { + return StatCollector.translateToLocal("curse." + Variables.MODID + ".flamingsoul"); + } +} diff --git a/src/main/java/darkknight/jewelrycraft/curses/CurseGreed.java b/src/main/java/darkknight/jewelrycraft/curses/CurseGreed.java index be5dd83..37a774a 100644 --- a/src/main/java/darkknight/jewelrycraft/curses/CurseGreed.java +++ b/src/main/java/darkknight/jewelrycraft/curses/CurseGreed.java @@ -1,40 +1,46 @@ -package darkknight.jewelrycraft.curses; - -import darkknight.jewelrycraft.api.Curse; -import darkknight.jewelrycraft.config.ConfigHandler; -import darkknight.jewelrycraft.util.Variables; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.potion.Potion; -import net.minecraft.potion.PotionEffect; -import net.minecraft.util.StatCollector; -import net.minecraft.world.World; - -public class CurseGreed extends Curse -{ - public CurseGreed(String name, int txtID, String pack) - { - super(name, txtID, pack); - } - - @Override - public void action(World world, EntityPlayer player) - { - } - - @Override - public boolean itemToss() - { - return true; - } - - public String getDescription() - { - return StatCollector.translateToLocal("curse." + Variables.MODID + ".greed.description"); - } - - @Override - public boolean canCurseBeActivated(World world) - { - return ConfigHandler.CURSE_GREED; - } -} +package darkknight.jewelrycraft.curses; + +import darkknight.jewelrycraft.api.Curse; +import darkknight.jewelrycraft.config.ConfigHandler; +import darkknight.jewelrycraft.util.Variables; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.potion.Potion; +import net.minecraft.potion.PotionEffect; +import net.minecraft.util.StatCollector; +import net.minecraft.world.World; + +public class CurseGreed extends Curse +{ + public CurseGreed(String name, int txtID, String pack) + { + super(name, txtID, pack); + } + + @Override + public void action(World world, EntityPlayer player) + { + } + + @Override + public boolean itemToss() + { + return true; + } + + public String getDescription() + { + return StatCollector.translateToLocal("curse." + Variables.MODID + ".greed.description"); + } + + @Override + public boolean canCurseBeActivated(World world) + { + return ConfigHandler.CURSE_GREED; + } + + @Override + public String getDisplayName() + { + return StatCollector.translateToLocal("curse." + Variables.MODID + ".greed"); + } +} diff --git a/src/main/java/darkknight/jewelrycraft/curses/CurseHumbleBundle.java b/src/main/java/darkknight/jewelrycraft/curses/CurseHumbleBundle.java index c65d9b7..855277c 100644 --- a/src/main/java/darkknight/jewelrycraft/curses/CurseHumbleBundle.java +++ b/src/main/java/darkknight/jewelrycraft/curses/CurseHumbleBundle.java @@ -1,67 +1,74 @@ -/** - * - */ -package darkknight.jewelrycraft.curses; - -import java.util.ArrayList; -import net.minecraft.entity.Entity; -import net.minecraft.entity.item.EntityItem; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Blocks; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.util.StatCollector; -import net.minecraft.world.World; -import net.minecraftforge.event.world.BlockEvent; -import darkknight.jewelrycraft.api.Curse; -import darkknight.jewelrycraft.config.ConfigHandler; -import darkknight.jewelrycraft.util.Variables; - -/** - * @author Sorin - * - */ -public class CurseHumbleBundle extends Curse -{ - protected CurseHumbleBundle(String name, int txtID, String texturepack) - { - super(name, txtID, texturepack); - } - - @Override - public void entityDropItems(EntityPlayer player, Entity target, ArrayList drops) - { - for(EntityItem item: drops){ - ItemStack drop = item.getEntityItem().copy(); - target.entityDropItem(drop, 0.5F); - } - } - - public void onBlockItemsDrop(EntityPlayer player, BlockEvent.HarvestDropsEvent event) - { - for(ItemStack item: event.drops){ - ItemStack drop = item.copy(); - if(drop.getItem() != Item.getItemFromBlock(event.block)) dropItem(event.world, event.x, event.y, event.z, drop); - } - } - - public void dropItem(World world, double x, double y, double z, ItemStack stack) - { - EntityItem entityitem = new EntityItem(world, x + 0.5D, y + 0.5D, z + 0.5D, stack); - entityitem.motionX = 0; - entityitem.motionZ = 0; - entityitem.motionY = 0.11000000298023224D; - world.spawnEntityInWorld(entityitem); - } - - public String getDescription() - { - return StatCollector.translateToLocal("curse." + Variables.MODID + ".humblebundle.description"); - } - - @Override - public boolean canCurseBeActivated(World world) - { - return ConfigHandler.CURSE_HUMBLE_BUNDLE; - } -} +/** + * + */ +package darkknight.jewelrycraft.curses; + +import java.util.ArrayList; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.StatCollector; +import net.minecraft.world.World; +import net.minecraftforge.event.world.BlockEvent; +import darkknight.jewelrycraft.api.Curse; +import darkknight.jewelrycraft.config.ConfigHandler; +import darkknight.jewelrycraft.util.Variables; + +/** + * @author Sorin + * + */ +public class CurseHumbleBundle extends Curse +{ + protected CurseHumbleBundle(String name, int txtID, String texturepack) + { + super(name, txtID, texturepack); + } + + @Override + public void entityDropItems(EntityPlayer player, Entity target, ArrayList drops) + { + for(EntityItem item: drops){ + ItemStack drop = item.getEntityItem().copy(); + target.entityDropItem(drop, 0.5F); + } + } + + public void onBlockItemsDrop(EntityPlayer player, BlockEvent.HarvestDropsEvent event) + { + for(ItemStack item: event.drops){ + ItemStack drop = item.copy(); + if(drop.getItem() != Item.getItemFromBlock(event.block)) dropItem(event.world, event.x, event.y, event.z, drop); + } + } + + public void dropItem(World world, double x, double y, double z, ItemStack stack) + { + EntityItem entityitem = new EntityItem(world, x + 0.5D, y + 0.5D, z + 0.5D, stack); + entityitem.motionX = 0; + entityitem.motionZ = 0; + entityitem.motionY = 0.11000000298023224D; + world.spawnEntityInWorld(entityitem); + } + + public String getDescription() + { + return StatCollector.translateToLocal("curse." + Variables.MODID + ".humblebundle.description"); + } + + @Override + public String getDisplayName() + { + return StatCollector.translateToLocal("curse." + Variables.MODID + ".humblebundle"); + } + + @Override + public boolean canCurseBeActivated(World world) + { + return ConfigHandler.CURSE_HUMBLE_BUNDLE; + } +} diff --git a/src/main/java/darkknight/jewelrycraft/curses/CurseInfamy.java b/src/main/java/darkknight/jewelrycraft/curses/CurseInfamy.java index c30ca8a..138f322 100644 --- a/src/main/java/darkknight/jewelrycraft/curses/CurseInfamy.java +++ b/src/main/java/darkknight/jewelrycraft/curses/CurseInfamy.java @@ -1,6 +1,7 @@ package darkknight.jewelrycraft.curses; import org.lwjgl.opengl.GL11; + import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -70,6 +71,12 @@ public class CurseInfamy extends Curse { return StatCollector.translateToLocal("curse." + Variables.MODID + ".infamy.description"); } + + @Override + public String getDisplayName() + { + return StatCollector.translateToLocal("curse." + Variables.MODID + ".infamy"); + } @Override public boolean canCurseBeActivated(World world) diff --git a/src/main/java/darkknight/jewelrycraft/curses/CurseMidasTouch.java b/src/main/java/darkknight/jewelrycraft/curses/CurseMidasTouch.java index 198a0e0..8133b75 100644 --- a/src/main/java/darkknight/jewelrycraft/curses/CurseMidasTouch.java +++ b/src/main/java/darkknight/jewelrycraft/curses/CurseMidasTouch.java @@ -1,6 +1,7 @@ package darkknight.jewelrycraft.curses; import java.util.Random; + import net.minecraft.block.Block; import net.minecraft.block.BlockCompressed; import net.minecraft.block.BlockPressurePlate; @@ -96,6 +97,12 @@ public class CurseMidasTouch extends Curse { return StatCollector.translateToLocal("curse." + Variables.MODID + ".midastouch.description"); } + + @Override + public String getDisplayName() + { + return StatCollector.translateToLocal("curse." + Variables.MODID + ".midastouch"); + } @Override public boolean canCurseBeActivated(World world) diff --git a/src/main/java/darkknight/jewelrycraft/curses/CursePentagram.java b/src/main/java/darkknight/jewelrycraft/curses/CursePentagram.java index f59e92e..60608fb 100644 --- a/src/main/java/darkknight/jewelrycraft/curses/CursePentagram.java +++ b/src/main/java/darkknight/jewelrycraft/curses/CursePentagram.java @@ -15,7 +15,9 @@ import net.minecraft.world.World; import net.minecraft.world.biome.BiomeGenBase; import net.minecraftforge.client.event.RenderHandEvent; import net.minecraftforge.client.event.RenderPlayerEvent; + import org.lwjgl.opengl.GL11; + import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import darkknight.jewelrycraft.api.Curse; @@ -23,82 +25,109 @@ import darkknight.jewelrycraft.config.ConfigHandler; import darkknight.jewelrycraft.damage.DamageSourceList; import darkknight.jewelrycraft.util.Variables; -public class CursePentagram extends Curse -{ - float rot = 0F; - - public CursePentagram(String name, int txtID, String pack) - { - super(name, txtID, pack); - } - - @Override - public void action(World world, EntityPlayer player) - { - // FMLInterModComms.sendMessage(modId, key, value); - // GameRegistry.findItem("Botania", "flower"); - // FMLInterModComms.fetchRuntimeMessages(forMod) - if (!world.isRemote){ - for(Object entity: world.getEntitiesWithinAABBExcludingEntity(player, AxisAlignedBB.getBoundingBox(player.boundingBox.minX - 0.5F, player.boundingBox.minY, player.boundingBox.minZ - 0.5F, player.boundingBox.maxX + 0.5F, player.boundingBox.maxY, player.boundingBox.maxZ + 0.5F))){ - if (entity instanceof EntityLivingBase && rand.nextInt(40) == 0){ - ((EntityLivingBase)entity).attackEntityFrom(DamageSourceList.shadows, 2f); - if (player.shouldHeal()) player.heal(2F); - else player.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(player.getMaxHealth() + 2f); - } - } - } - } - - @Override - public void attackedByPlayerAction(World world, EntityPlayer player, Entity target) - {} - - @Override - public void playerRender(EntityPlayer player, RenderPlayerEvent.Specials.Post event) - {} - - @SideOnly (Side.CLIENT) - public void playerHandRender(EntityPlayer player, RenderHandEvent event) - { - ResourceLocation PENTAGRAM_TEXTURE = new ResourceLocation(Variables.MODID, "textures/gui/" + getTexturePack() + ".png"); - GL11.glPushMatrix(); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_SRC_COLOR); - Tessellator tessellator = Tessellator.instance; - TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager(); - texturemanager.bindTexture(PENTAGRAM_TEXTURE); - GL11.glRotatef(rot, 0F, 1F, 0F); - GL11.glTranslatef(-0.8F, (player.isSneaking() ? 0.1625F : 0F) + -1.6F, -0.8F); - GL11.glRotatef(90F, 1F, 0F, 0F); - GL11.glScalef(0.05F, 0.05F, 0.05F); - rot += 3F; - if (rot > 360F) rot = 0F; - float f = 0.00390625F; - float f1 = 0.00390625F; - int x = 0; - int y = 0; - int u = 32 * 7; - int v = 0; - int width = 32; - int height = 32; - tessellator.startDrawingQuads(); - tessellator.addVertexWithUV((double)(x + 0), (double)(y + height), (double)0, (double)((float)(u + 0) * f), (double)((float)(v + height) * f1)); - tessellator.addVertexWithUV((double)(x + width), (double)(y + height), (double)0, (double)((float)(u + width) * f), (double)((float)(v + height) * f1)); - tessellator.addVertexWithUV((double)(x + width), (double)(y + 0), (double)0, (double)((float)(u + width) * f), (double)((float)(v + 0) * f1)); - tessellator.addVertexWithUV((double)(x + 0), (double)(y + 0), (double)0, (double)((float)(u + 0) * f), (double)((float)(v + 0) * f1)); - tessellator.draw(); - GL11.glDisable(GL11.GL_BLEND); - GL11.glPopMatrix(); - } - - public String getDescription() - { - return StatCollector.translateToLocal("curse." + Variables.MODID + ".pentagram.description"); - } - - @Override - public boolean canCurseBeActivated(World world) - { - return ConfigHandler.CURSE_PENTAGRAM; - } +public class CursePentagram extends Curse { + float rot = 0F; + + public CursePentagram(String name, int txtID, String pack) { + super(name, txtID, pack); + } + + @Override + public void action(World world, EntityPlayer player) { + if (!world.isRemote) { + for (Object entity : world.getEntitiesWithinAABBExcludingEntity(player, AxisAlignedBB.getBoundingBox(player.boundingBox.minX - 0.5F, player.boundingBox.minY, player.boundingBox.minZ - 0.5F, player.boundingBox.maxX + 0.5F, player.boundingBox.maxY, player.boundingBox.maxZ + 0.5F))) { + if (entity instanceof EntityLivingBase && rand.nextInt(40) == 0) { + ((EntityLivingBase) entity).attackEntityFrom(DamageSourceList.shadows, 2f); + if (player.shouldHeal()) player.heal(2F); + else player.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(player.getMaxHealth() + 2f); + } + } + } + } + + @Override + public void attackedByPlayerAction(World world, EntityPlayer player, Entity target) { + } + + @Override + public void playerRender(EntityPlayer player, RenderPlayerEvent.Specials.Post event) { + ResourceLocation PENTAGRAM_TEXTURE = new ResourceLocation(Variables.MODID, "textures/gui/" + getTexturePack() + ".png"); + GL11.glPushMatrix(); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_SRC_COLOR); + Tessellator tessellator = Tessellator.instance; + TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager(); + texturemanager.bindTexture(PENTAGRAM_TEXTURE); + GL11.glRotatef(rot, 0F, 1F, 0F); + GL11.glTranslatef(-0.8F, (player.isSneaking() ? 0.1625F : 0F) + 1.5F, -0.8F); + GL11.glRotatef(90F, 1F, 0F, 0F); + GL11.glScalef(0.05F, 0.05F, 0.05F); + rot += 3F; + if (rot > 360F) rot = 0F; + float f = 0.00390625F; + float f1 = 0.00390625F; + int x = 0; + int y = 0; + int u = 32 * 7; + int v = 0; + int width = 32; + int height = 32; + tessellator.startDrawingQuads(); + tessellator.addVertexWithUV((double) (x + 0), (double) (y + height), (double) 0, (double) ((float) (u + 0) * f), (double) ((float) (v + height) * f1)); + tessellator.addVertexWithUV((double) (x + width), (double) (y + height), (double) 0, (double) ((float) (u + width) * f), (double) ((float) (v + height) * f1)); + tessellator.addVertexWithUV((double) (x + width), (double) (y + 0), (double) 0, (double) ((float) (u + width) * f), (double) ((float) (v + 0) * f1)); + tessellator.addVertexWithUV((double) (x + 0), (double) (y + 0), (double) 0, (double) ((float) (u + 0) * f), (double) ((float) (v + 0) * f1)); + tessellator.draw(); + GL11.glDisable(GL11.GL_BLEND); + GL11.glPopMatrix(); + } + + @SideOnly(Side.CLIENT) + public void playerHandRender(EntityPlayer player, RenderHandEvent event) { + if (mc.gameSettings.thirdPersonView == 0) { + ResourceLocation PENTAGRAM_TEXTURE = new ResourceLocation(Variables.MODID, "textures/gui/" + getTexturePack() + ".png"); + GL11.glPushMatrix(); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_SRC_COLOR); + Tessellator tessellator = Tessellator.instance; + TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager(); + texturemanager.bindTexture(PENTAGRAM_TEXTURE); + GL11.glRotatef(rot, 0F, 1F, 0F); + GL11.glTranslatef(-0.8F, (player.isSneaking() ? 0.1625F : 0F) - 1.6F, -0.8F); + GL11.glRotatef(90F, 1F, 0F, 0F); + GL11.glScalef(0.05F, 0.05F, 0.05F); + rot += 3F; + if (rot > 360F) rot = 0F; + float f = 0.00390625F; + float f1 = 0.00390625F; + int x = 0; + int y = 0; + int u = 32 * 7; + int v = 0; + int width = 32; + int height = 32; + tessellator.startDrawingQuads(); + tessellator.addVertexWithUV((double) (x + 0), (double) (y + height), (double) 0, (double) ((float) (u + 0) * f), (double) ((float) (v + height) * f1)); + tessellator.addVertexWithUV((double) (x + width), (double) (y + height), (double) 0, (double) ((float) (u + width) * f), (double) ((float) (v + height) * f1)); + tessellator.addVertexWithUV((double) (x + width), (double) (y + 0), (double) 0, (double) ((float) (u + width) * f), (double) ((float) (v + 0) * f1)); + tessellator.addVertexWithUV((double) (x + 0), (double) (y + 0), (double) 0, (double) ((float) (u + 0) * f), (double) ((float) (v + 0) * f1)); + tessellator.draw(); + GL11.glDisable(GL11.GL_BLEND); + GL11.glPopMatrix(); + } + } + + public String getDescription() { + return StatCollector.translateToLocal("curse." + Variables.MODID + ".pentagram.description"); + } + + @Override + public String getDisplayName() { + return StatCollector.translateToLocal("curse." + Variables.MODID + ".pentagram"); + } + + @Override + public boolean canCurseBeActivated(World world) { + return ConfigHandler.CURSE_PENTAGRAM; + } } diff --git a/src/main/java/darkknight/jewelrycraft/curses/CurseRabbitsPaw.java b/src/main/java/darkknight/jewelrycraft/curses/CurseRabbitsPaw.java index b675954..ed4d294 100644 --- a/src/main/java/darkknight/jewelrycraft/curses/CurseRabbitsPaw.java +++ b/src/main/java/darkknight/jewelrycraft/curses/CurseRabbitsPaw.java @@ -4,6 +4,7 @@ package darkknight.jewelrycraft.curses; import java.util.ArrayList; + import darkknight.jewelrycraft.api.Curse; import darkknight.jewelrycraft.config.ConfigHandler; import darkknight.jewelrycraft.entities.EntityHalfHeart; @@ -64,6 +65,12 @@ public class CurseRabbitsPaw extends Curse { return StatCollector.translateToLocal("curse." + Variables.MODID + ".rabbitspaw.description"); } + + @Override + public String getDisplayName() + { + return StatCollector.translateToLocal("curse." + Variables.MODID + ".rabbitspaw"); + } @Override public boolean canCurseBeActivated(World world) diff --git a/src/main/java/darkknight/jewelrycraft/curses/CurseRottenHeart.java b/src/main/java/darkknight/jewelrycraft/curses/CurseRottenHeart.java index afc05b0..5cb47cd 100644 --- a/src/main/java/darkknight/jewelrycraft/curses/CurseRottenHeart.java +++ b/src/main/java/darkknight/jewelrycraft/curses/CurseRottenHeart.java @@ -1,35 +1,41 @@ -package darkknight.jewelrycraft.curses; - -import darkknight.jewelrycraft.api.Curse; -import darkknight.jewelrycraft.config.ConfigHandler; -import darkknight.jewelrycraft.util.Variables; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.potion.Potion; -import net.minecraft.potion.PotionEffect; -import net.minecraft.util.StatCollector; -import net.minecraft.world.World; - -public class CurseRottenHeart extends Curse -{ - public CurseRottenHeart(String name, int txtID, String pack) - { - super(name, txtID, pack); - } - - @Override - public void action(World world, EntityPlayer player) - { - if (!player.isPotionActive(Potion.poison) || player.getActivePotionEffect(Potion.poison).getDuration() < 30) player.addPotionEffect(new PotionEffect(Potion.poison.id, 80)); - } - - public String getDescription() - { - return StatCollector.translateToLocal("curse." + Variables.MODID + ".rottenheart.description"); - } - - @Override - public boolean canCurseBeActivated(World world) - { - return world.getWorldInfo().isHardcoreModeEnabled() ? false : ConfigHandler.CURSE_ROTTEN_HEART; - } -} +package darkknight.jewelrycraft.curses; + +import darkknight.jewelrycraft.api.Curse; +import darkknight.jewelrycraft.config.ConfigHandler; +import darkknight.jewelrycraft.util.Variables; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.potion.Potion; +import net.minecraft.potion.PotionEffect; +import net.minecraft.util.StatCollector; +import net.minecraft.world.World; + +public class CurseRottenHeart extends Curse +{ + public CurseRottenHeart(String name, int txtID, String pack) + { + super(name, txtID, pack); + } + + @Override + public void action(World world, EntityPlayer player) + { + if (!player.isPotionActive(Potion.poison) || player.getActivePotionEffect(Potion.poison).getDuration() < 30) player.addPotionEffect(new PotionEffect(Potion.poison.id, 80)); + } + + public String getDescription() + { + return StatCollector.translateToLocal("curse." + Variables.MODID + ".rottenheart.description"); + } + + @Override + public String getDisplayName() + { + return StatCollector.translateToLocal("curse." + Variables.MODID + ".rottenheart"); + } + + @Override + public boolean canCurseBeActivated(World world) + { + return world.getWorldInfo().isHardcoreModeEnabled() ? false : ConfigHandler.CURSE_ROTTEN_HEART; + } +} diff --git a/src/main/java/darkknight/jewelrycraft/curses/CurseVampireHunger.java b/src/main/java/darkknight/jewelrycraft/curses/CurseVampireHunger.java index 3c63641..c486e5d 100644 --- a/src/main/java/darkknight/jewelrycraft/curses/CurseVampireHunger.java +++ b/src/main/java/darkknight/jewelrycraft/curses/CurseVampireHunger.java @@ -1,40 +1,46 @@ -/** - * - */ -package darkknight.jewelrycraft.curses; - -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.util.StatCollector; -import net.minecraft.world.World; -import darkknight.jewelrycraft.api.Curse; -import darkknight.jewelrycraft.config.ConfigHandler; -import darkknight.jewelrycraft.util.Variables; - -/** - * @author Sorin - * - */ -public class CurseVampireHunger extends Curse -{ - protected CurseVampireHunger(String name, int txtID, String texturepack) - { - super(name, txtID, texturepack); - } - - public void attackedByPlayerAction(World world, EntityPlayer player, Entity target) - { - if(player.shouldHeal() && rand.nextInt(5) == 0) player.heal(1F); - } - - public String getDescription() - { - return StatCollector.translateToLocal("curse." + Variables.MODID + ".vampirehunger.description"); - } - - @Override - public boolean canCurseBeActivated(World world) - { - return ConfigHandler.CURSE_VAMPIRE_HUNGER; - } -} +/** + * + */ +package darkknight.jewelrycraft.curses; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.StatCollector; +import net.minecraft.world.World; +import darkknight.jewelrycraft.api.Curse; +import darkknight.jewelrycraft.config.ConfigHandler; +import darkknight.jewelrycraft.util.Variables; + +/** + * @author Sorin + * + */ +public class CurseVampireHunger extends Curse +{ + protected CurseVampireHunger(String name, int txtID, String texturepack) + { + super(name, txtID, texturepack); + } + + public void attackedByPlayerAction(World world, EntityPlayer player, Entity target) + { + if(player.shouldHeal() && rand.nextInt(5) == 0) player.heal(1F); + } + + public String getDescription() + { + return StatCollector.translateToLocal("curse." + Variables.MODID + ".vampirehunger.description"); + } + + @Override + public String getDisplayName() + { + return StatCollector.translateToLocal("curse." + Variables.MODID + ".vampirehunger"); + } + + @Override + public boolean canCurseBeActivated(World world) + { + return ConfigHandler.CURSE_VAMPIRE_HUNGER; + } +} diff --git a/src/main/java/darkknight/jewelrycraft/entities/EntityHeart.java b/src/main/java/darkknight/jewelrycraft/entities/EntityHeart.java index 6612c52..26f6d2e 100644 --- a/src/main/java/darkknight/jewelrycraft/entities/EntityHeart.java +++ b/src/main/java/darkknight/jewelrycraft/entities/EntityHeart.java @@ -22,121 +22,112 @@ import darkknight.jewelrycraft.util.Variables; /** * @author Sorin */ -public class EntityHeart extends EntityLiving -{ - public EntityHeart(World world) - { - super(world); - this.setSize(0.4F, 0.4F); - } - - protected void applyEntityAttributes() - { - super.applyEntityAttributes(); - this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(getQuantity()); - } - - @Override - public void updateEntityActionState() - { - if(ConfigHandler.HEARTS_DESPAWN) ++this.entityAge; - } - - public void onLivingUpdate() - { - super.onLivingUpdate(); - if (ConfigHandler.HEARTS_DESPAWN && this.entityAge > ConfigHandler.HEART_DESPAWN_TIME) this.setDead(); - } - - protected void collideWithEntity(Entity entity) - { - super.collideWithEntity(entity); - if (!this.worldObj.isRemote && entity instanceof EntityHeart && getType().equals(((EntityHeart)entity).getType())){ - setQuantity(getQuantity() + ((EntityHeart)entity).getQuantity()); - getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(getQuantity() + ((EntityHeart)entity).getQuantity()); - this.heal(getQuantity()); - entity.setDead(); - } - } - - @Override - public void onCollideWithPlayer(EntityPlayer player) - { - if (!this.worldObj.isRemote){ - NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID); - if (getType() == "Red" && player.getHealth() < player.getMaxHealth()){ - float healAmount = player.getMaxHealth() - player.getHealth(); - if (getQuantity() > healAmount){ - player.heal(healAmount); - this.setQuantity(getQuantity() - healAmount); - }else{ - player.heal(getQuantity()); - this.setDead(); - } - }else if (getType().equals("White") && playerInfo.getFloat("WhiteHeart") > 0.1F){ - playerInfo.setFloat(getType() + "Heart", 0F); - player.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(player.getMaxHealth() + playerInfo.getFloat("WhiteHeart")); - this.setDead(); - }else if (getType() != "Red"){ - playerInfo.setFloat(getType() + "Heart", playerInfo.getFloat(getType() + "Heart") + getQuantity()); - JewelrycraftMod.netWrapper.sendToServer(new PacketRequestPlayerInfo()); - this.setDead(); - } - } - } - - @SideOnly (Side.CLIENT) - public boolean canRenderOnFire() - { - return false; - } - - protected void entityInit() - { - super.entityInit(); - this.dataWatcher.addObject(16, "Red"); - this.dataWatcher.addObject(17, 2f); - } - - public void writeEntityToNBT(NBTTagCompound nbt) - { - super.writeEntityToNBT(nbt); - nbt.setString("Type", getType()); - nbt.setFloat("Quantity", getQuantity()); - } - - /** - * (abstract) Protected helper method to read subclass entity data from NBT. - */ - public void readEntityFromNBT(NBTTagCompound nbt) - { - super.readEntityFromNBT(nbt); - setType(nbt.getString("Type")); - setQuantity(nbt.getFloat("Quantity")); - } - - public String getType() - { - return this.dataWatcher.getWatchableObjectString(16); - } - - public void setType(String type) - { - this.dataWatcher.updateObject(16, type); - } - - public Float getQuantity() - { - return this.dataWatcher.getWatchableObjectFloat(17); - } - - public void setQuantity(Float qty) - { - this.dataWatcher.updateObject(17, qty); - } - - public EnumCreatureAttribute getCreatureAttribute() - { - return JewelrycraftUtil.HEART; - } +public class EntityHeart extends EntityLiving { + public EntityHeart(World world) { + super(world); + this.setSize(0.4F, 0.4F); + } + + protected void applyEntityAttributes() { + super.applyEntityAttributes(); + this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(getQuantity()); + } + + @Override + public void updateEntityActionState() { + if (ConfigHandler.HEARTS_DESPAWN) ++this.entityAge; + this.setCanPickUpLoot(true); + } + + public void onLivingUpdate() { + super.onLivingUpdate(); + if (ConfigHandler.HEARTS_DESPAWN && this.entityAge > ConfigHandler.HEART_DESPAWN_TIME) this.setDead(); + } + + protected void collideWithEntity(Entity entity) { + super.collideWithEntity(entity); + if (!this.worldObj.isRemote && entity instanceof EntityHeart && getType().equals(((EntityHeart) entity).getType())) { + setQuantity(getQuantity() + ((EntityHeart) entity).getQuantity()); + getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(getQuantity() + ((EntityHeart) entity).getQuantity()); + this.heal(getQuantity()); + entity.setDead(); + } + } + + @Override + public void onCollideWithPlayer(EntityPlayer player) { + if (!this.worldObj.isRemote) { + NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID); + if (playerInfo != null) { + if (getType() == "Red" && player.getHealth() < player.getMaxHealth()) { + float healAmount = player.getMaxHealth() - player.getHealth(); + if (getQuantity() > healAmount) { + player.heal(healAmount); + this.setQuantity(getQuantity() - healAmount); + } else { + player.heal(getQuantity()); + this.setDead(); + } + } else if (getType().equals("White") && playerInfo.getFloat("WhiteHeart") > 0.1F) { + playerInfo.setFloat(getType() + "Heart", 0F); + player.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(player.getMaxHealth() + playerInfo.getFloat("WhiteHeart")); + this.setDead(); + } else if (getType().equals("Black") || getType().equals("Blue")) { + playerInfo.setFloat(getType() + "Heart", playerInfo.getFloat(getType() + "Heart") + getQuantity()); + JewelrycraftMod.netWrapper.sendToServer(new PacketRequestPlayerInfo()); + this.setDead(); + } + } + } + } + + @SideOnly(Side.CLIENT) + public boolean canRenderOnFire() { + return false; + } + + protected void entityInit() { + super.entityInit(); + this.dataWatcher.addObject(16, "Red"); + this.dataWatcher.addObject(17, 2f); + } + + public void writeEntityToNBT(NBTTagCompound nbt) { + super.writeEntityToNBT(nbt); + nbt.setString("Type", getType()); + nbt.setFloat("Quantity", getQuantity()); + } + + /** + * (abstract) Protected helper method to read subclass entity data from NBT. + */ + public void readEntityFromNBT(NBTTagCompound nbt) { + super.readEntityFromNBT(nbt); + setType(nbt.getString("Type")); + setQuantity(nbt.getFloat("Quantity")); + } + + public String getType() { + return this.dataWatcher.getWatchableObjectString(16); + } + + public void setType(String type) { + this.dataWatcher.updateObject(16, type); + } + + public Float getQuantity() { + return this.dataWatcher.getWatchableObjectFloat(17); + } + + public void setQuantity(Float qty) { + this.dataWatcher.updateObject(17, qty); + } + + public EnumCreatureAttribute getCreatureAttribute() { + return JewelrycraftUtil.HEART; + } + + public boolean isEntityInvulnerable() { + return false; + } } diff --git a/src/main/java/darkknight/jewelrycraft/events/EntityEventHandler.java b/src/main/java/darkknight/jewelrycraft/events/EntityEventHandler.java index 0bc2257..0419c7f 100644 --- a/src/main/java/darkknight/jewelrycraft/events/EntityEventHandler.java +++ b/src/main/java/darkknight/jewelrycraft/events/EntityEventHandler.java @@ -22,7 +22,9 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.server.MinecraftServer; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.ChatComponentText; +import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.MathHelper; +import net.minecraft.util.StatCollector; import net.minecraft.util.WeightedRandom; import net.minecraftforge.client.event.EntityViewRenderEvent; import net.minecraftforge.event.entity.EntityJoinWorldEvent; @@ -148,8 +150,7 @@ public class EntityEventHandler { JewelrycraftMod.netWrapper.sendToServer(new PacketRequestPlayerInfo()); if (addedCurses) { JewelrycraftMod.netWrapper.sendToAll(new PacketSendServerPlayersInfo()); - // player.openGui(JewelrycraftMod.instance, 4, - // player.worldObj, 0, 0, 0); + player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("curse." + Variables.MODID + ".activated"))); addedCurses = false; } } @@ -184,7 +185,7 @@ public class EntityEventHandler { if (entity instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer) entity; NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID); - if (!(event.source.getEntity() instanceof EntityPlayer)) { + if (!(event.source.getEntity() instanceof EntityPlayer) && !player.capabilities.isCreativeMode) { if (!player.worldObj.isRemote) for (int i = 0; i < 18; i++) if (playerInfo.hasKey("ext" + i)) { NBTTagCompound nbt = (NBTTagCompound) playerInfo.getTag("ext" + i); @@ -207,7 +208,7 @@ public class EntityEventHandler { if (curse.canCurseBeActivated(player.worldObj) && playerInfo.getInteger(curse.getName()) > 0) curse.attackedAction(player.worldObj, player); } - if (!player.worldObj.isRemote && (float) player.hurtResistantTime <= (float) player.maxHurtResistantTime / 2.0F && !event.source.isUnblockable()) { + if (!player.worldObj.isRemote && !player.capabilities.isCreativeMode && (float) player.hurtResistantTime <= (float) player.maxHurtResistantTime / 2.0F && !event.source.isUnblockable()) { if (playerInfo.getFloat("WhiteHeart") > 0) { playerInfo.setFloat("WhiteHeart", 0f); JewelrycraftMod.netWrapper.sendToServer(new PacketRequestPlayerInfo()); @@ -232,7 +233,7 @@ public class EntityEventHandler { Iterator iterator = enemies.iterator(); while (iterator.hasNext()) { Entity enemy = (Entity) iterator.next(); - enemy.attackEntityFrom(DamageSourceList.blackHeart, 5f * event.ammount); + enemy.attackEntityFrom(DamageSourceList.blackHeart, 2f * event.ammount); } } float damage = playerInfo.getFloat("BlackHeart") - event.ammount; @@ -270,6 +271,7 @@ public class EntityEventHandler { } if (ConfigHandler.CURSES_ENABLED) for (Curse curse : Curse.getCurseList()) if (curse.canCurseBeActivated(player.worldObj) && playerInfo.getInteger(curse.getName()) > 0) curse.attackedByPlayerAction(entity.worldObj, player, entity); + if(entity instanceof EntityHeart && entity.getAge() < 50) event.setCanceled(true); } } diff --git a/src/main/java/darkknight/jewelrycraft/events/KeyBindings.java b/src/main/java/darkknight/jewelrycraft/events/KeyBindings.java index 948a422..5104426 100644 --- a/src/main/java/darkknight/jewelrycraft/events/KeyBindings.java +++ b/src/main/java/darkknight/jewelrycraft/events/KeyBindings.java @@ -1,35 +1,38 @@ -package darkknight.jewelrycraft.events; - -import net.minecraft.client.settings.KeyBinding; -import org.lwjgl.input.Keyboard; -import cpw.mods.fml.client.registry.ClientRegistry; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.common.gameevent.InputEvent; -import darkknight.jewelrycraft.JewelrycraftMod; -import darkknight.jewelrycraft.network.PacketKeyPressEvent; -import darkknight.jewelrycraft.util.Variables; - -public class KeyBindings -{ - public static KeyBinding render = new KeyBinding("Pretty Render", Keyboard.KEY_Z, Variables.MODNAME); - public static KeyBinding inventory = new KeyBinding("Jewelry Inventory", Keyboard.KEY_J, Variables.MODNAME); - - /** - * - */ - public KeyBindings() - { - ClientRegistry.registerKeyBinding(render); - ClientRegistry.registerKeyBinding(inventory); - } - - /** - * @param event - */ - @SubscribeEvent - public void onKeyInput(InputEvent.KeyInputEvent event) - { - if (render.isPressed()) JewelrycraftMod.fancyRender = !JewelrycraftMod.fancyRender; - if (inventory.isPressed()) JewelrycraftMod.netWrapper.sendToServer(new PacketKeyPressEvent(0)); - } +package darkknight.jewelrycraft.events; + +import net.minecraft.client.settings.KeyBinding; +import org.lwjgl.input.Keyboard; +import cpw.mods.fml.client.registry.ClientRegistry; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.gameevent.InputEvent; +import darkknight.jewelrycraft.JewelrycraftMod; +import darkknight.jewelrycraft.network.PacketKeyPressEvent; +import darkknight.jewelrycraft.util.Variables; + +public class KeyBindings +{ + public static KeyBinding render = new KeyBinding("Pretty Render", Keyboard.KEY_Z, Variables.MODNAME); + public static KeyBinding inventory = new KeyBinding("Jewelry Inventory", Keyboard.KEY_J, Variables.MODNAME); + public static KeyBinding curses = new KeyBinding("Curses Tab", Keyboard.KEY_C, Variables.MODNAME); + + /** + * + */ + public KeyBindings() + { + ClientRegistry.registerKeyBinding(render); + ClientRegistry.registerKeyBinding(inventory); + ClientRegistry.registerKeyBinding(curses); + } + + /** + * @param event + */ + @SubscribeEvent + public void onKeyInput(InputEvent.KeyInputEvent event) + { + if (render.isPressed()) JewelrycraftMod.fancyRender = !JewelrycraftMod.fancyRender; + if (inventory.isPressed()) JewelrycraftMod.netWrapper.sendToServer(new PacketKeyPressEvent(0)); + if (curses.isPressed()) JewelrycraftMod.netWrapper.sendToServer(new PacketKeyPressEvent(1)); + } } \ No newline at end of file diff --git a/src/main/java/darkknight/jewelrycraft/events/ScreenHandler.java b/src/main/java/darkknight/jewelrycraft/events/ScreenHandler.java index b8df767..c86597e 100644 --- a/src/main/java/darkknight/jewelrycraft/events/ScreenHandler.java +++ b/src/main/java/darkknight/jewelrycraft/events/ScreenHandler.java @@ -15,84 +15,40 @@ import darkknight.jewelrycraft.api.Curse; import darkknight.jewelrycraft.config.ConfigHandler; import darkknight.jewelrycraft.util.Variables; -public class ScreenHandler extends Gui -{ - private Minecraft mc; - public static NBTTagCompound tagCache = null; - public static int cooldown; - - public ScreenHandler(Minecraft mc) - { - super(); - this.mc = mc; - } - - @SubscribeEvent - public void renderScreen(RenderGameOverlayEvent event) - { - if (event.isCancelable() || event.type != ElementType.ALL || tagCache == null) return; - if (!mc.gameSettings.showDebugInfo && !(mc.currentScreen instanceof GuiChat)){ - int count = 0; - int size = 32; - ScaledResolution resolution = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight); - if (tagCache.hasKey("cursePoints") && tagCache.getInteger("cursePoints") > 0){ - mc.renderEngine.bindTexture(Variables.MISC_TEXTURE); - if (ConfigHandler.CURSES_ENABLED) for(Curse curse: Curse.getCurseList()){ - if (curse.canCurseBeActivated(mc.theWorld) && tagCache.hasKey(curse.getName()) && tagCache.getInteger(curse.getName()) > 0){ - drawTexturedModalRect(-16, -16 + (size - 6) * count, 0, 32, 144, 60); - count++; - } - } - count = 0; - if (ConfigHandler.CURSES_ENABLED) for(Curse curse: Curse.getCurseList()) - if (curse.canCurseBeActivated(mc.theWorld) && tagCache.hasKey(curse.getName()) && tagCache.getInteger(curse.getName()) > 0){ - mc.renderEngine.bindTexture(new ResourceLocation(Variables.MODID, "textures/gui/" + curse.getTexturePack() + ".png")); - int tag = curse.getTextureID(); - GL11.glPushMatrix(); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glScalef(0.45f, 0.45f, 0.0f); - drawTexturedModalRect(28, 18 + (size + 26) * count, tag % 8 * size, tag / 8 * size, size, size); - GL11.glPopMatrix(); - count++; - } - count = 0; - size = 16; - if (ConfigHandler.CURSES_ENABLED) for(Curse curse: Curse.getCurseList()) - if (curse.canCurseBeActivated(mc.theWorld) && tagCache.hasKey(curse.getName()) && tagCache.getInteger(curse.getName()) > 0){ - mc.fontRenderer.drawStringWithShadow(curse.getName().split(":")[1], 30, 11 + (size + 10) * count, 16777215); - if (tagCache.getInteger(curse.getName()) == 2){ - mc.renderEngine.bindTexture(Variables.MISC_TEXTURE); - GL11.glPushMatrix(); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glColor4f(1f, 1f, 1f, 0.5f); - drawTexturedModalRect(95, 7 + (size + 10) * count, 3 * size, 0, size, size); - GL11.glPopMatrix(); - } - count++; - } - } - GL11.glPushMatrix(); - GL11.glColor4f(1f, 1f, 1f, 1.0f); - mc.renderEngine.bindTexture(Variables.MISC_TEXTURE); - count = 0; - size = 16; - if (tagCache.getFloat("BlueHeart") > 0){ - drawTexturedModalRect(resolution.getScaledWidth()/2 + 90 + 35*count, resolution.getScaledHeight() - 20, 0 * size, 0 * size, size, size); - mc.fontRenderer.drawStringWithShadow("x" + (MathHelper.ceiling_float_int(tagCache.getFloat("BlueHeart")) / 2.0F), resolution.getScaledWidth()/2 + 105 + 35*count, resolution.getScaledHeight() - 16, 16777215); - } - count++; - mc.renderEngine.bindTexture(Variables.MISC_TEXTURE); - if (tagCache.getFloat("BlackHeart") > 0){ - drawTexturedModalRect(resolution.getScaledWidth()/2 + 90 + (mc.fontRenderer.getStringWidth(String.valueOf((MathHelper.ceiling_float_int(tagCache.getFloat("BlueHeart")) / 2.0F))) - 14) + 35*count, resolution.getScaledHeight() - 20, 1 * size, 0 * size, size, size); - mc.fontRenderer.drawStringWithShadow("x" + (MathHelper.ceiling_float_int(tagCache.getFloat("BlackHeart")) / 2.0F), resolution.getScaledWidth()/2 + 105 + (mc.fontRenderer.getStringWidth(String.valueOf((MathHelper.ceiling_float_int(tagCache.getFloat("BlueHeart")) / 2.0F))) - 14) + 35*count, resolution.getScaledHeight() - 16, 16777215); - } - count++; - mc.renderEngine.bindTexture(Variables.MISC_TEXTURE); - if (tagCache.getFloat("WhiteHeart") > 0) - drawTexturedModalRect(resolution.getScaledWidth()/2 + 90 + (mc.fontRenderer.getStringWidth(String.valueOf((MathHelper.ceiling_float_int(tagCache.getFloat("BlueHeart")) / 2.0F))) - 14) + (mc.fontRenderer.getStringWidth(String.valueOf((MathHelper.ceiling_float_int(tagCache.getFloat("BlackHeart")) / 2.0F))) - 14) + 35*count, resolution.getScaledHeight() - 20, 2 * size, 1 * size, size, size); - GL11.glPopMatrix(); - } - } +public class ScreenHandler extends Gui { + private Minecraft mc; + public static NBTTagCompound tagCache = null; + public static int cooldown; + + public ScreenHandler(Minecraft mc) { + super(); + this.mc = mc; + } + + @SubscribeEvent + public void renderScreen(RenderGameOverlayEvent event) { + if (event.isCancelable() || event.type != ElementType.ALL || tagCache == null) return; + int count = 0; + int size = 32; + ScaledResolution resolution = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight); + GL11.glPushMatrix(); + GL11.glColor4f(1f, 1f, 1f, 1.0f); + mc.renderEngine.bindTexture(Variables.MISC_TEXTURE); + count = 0; + size = 16; + if (tagCache.getFloat("BlueHeart") > 0) { + drawTexturedModalRect(resolution.getScaledWidth() / 2 + 90 + 35 * count, resolution.getScaledHeight() - 20, 0 * size, 0 * size, size, size); + mc.fontRenderer.drawStringWithShadow("x" + (MathHelper.ceiling_float_int(tagCache.getFloat("BlueHeart")) / 2.0F), resolution.getScaledWidth() / 2 + 105 + 35 * count, resolution.getScaledHeight() - 16, 16777215); + } + count++; + mc.renderEngine.bindTexture(Variables.MISC_TEXTURE); + if (tagCache.getFloat("BlackHeart") > 0) { + drawTexturedModalRect(resolution.getScaledWidth() / 2 + 90 + (mc.fontRenderer.getStringWidth(String.valueOf((MathHelper.ceiling_float_int(tagCache.getFloat("BlueHeart")) / 2.0F))) - 14) + 35 * count, resolution.getScaledHeight() - 20, 1 * size, 0 * size, size, size); + mc.fontRenderer.drawStringWithShadow("x" + (MathHelper.ceiling_float_int(tagCache.getFloat("BlackHeart")) / 2.0F), resolution.getScaledWidth() / 2 + 105 + (mc.fontRenderer.getStringWidth(String.valueOf((MathHelper.ceiling_float_int(tagCache.getFloat("BlueHeart")) / 2.0F))) - 14) + 35 * count, resolution.getScaledHeight() - 16, 16777215); + } + count++; + mc.renderEngine.bindTexture(Variables.MISC_TEXTURE); + if (tagCache.getFloat("WhiteHeart") > 0) drawTexturedModalRect(resolution.getScaledWidth() / 2 + 90 + (mc.fontRenderer.getStringWidth(String.valueOf((MathHelper.ceiling_float_int(tagCache.getFloat("BlueHeart")) / 2.0F))) - 14) + (mc.fontRenderer.getStringWidth(String.valueOf((MathHelper.ceiling_float_int(tagCache.getFloat("BlackHeart")) / 2.0F))) - 14) + 35 * count, resolution.getScaledHeight() - 20, 2 * size, 1 * size, size, size); + GL11.glPopMatrix(); + } } \ No newline at end of file diff --git a/src/main/java/darkknight/jewelrycraft/item/ItemBaseJewelry.java b/src/main/java/darkknight/jewelrycraft/item/ItemBaseJewelry.java index 204ec9b..f5dafb8 100644 --- a/src/main/java/darkknight/jewelrycraft/item/ItemBaseJewelry.java +++ b/src/main/java/darkknight/jewelrycraft/item/ItemBaseJewelry.java @@ -32,6 +32,7 @@ import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import darkknight.jewelrycraft.JewelrycraftMod; import darkknight.jewelrycraft.api.ModifierEffects; +import darkknight.jewelrycraft.config.ConfigHandler; import darkknight.jewelrycraft.util.JewelryNBT; import darkknight.jewelrycraft.util.JewelrycraftUtil; import darkknight.jewelrycraft.util.Variables; @@ -79,7 +80,7 @@ public abstract class ItemBaseJewelry extends Item */ public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4) { - if (stack.hasTagCompound()){ + if (stack.hasTagCompound() && ConfigHandler.JEWELRY_INFO){ ItemStack ingot = JewelryNBT.ingot(stack); if (ingot != null && Item.getIdFromItem(JewelryNBT.ingot(stack).getItem()) > 0) list.add(StatCollector.translateToLocal("info." + Variables.MODID + ".metal") + ": " + EnumChatFormatting.YELLOW + ingot.getDisplayName().replace(StatCollector.translateToLocal("info." + Variables.MODID + ".ingot"), " ")); ItemStack gem = JewelryNBT.gem(stack); diff --git a/src/main/java/darkknight/jewelrycraft/model/ModelShadowEye.java b/src/main/java/darkknight/jewelrycraft/model/ModelShadowEye.java index e2f339d..1962aa8 100644 --- a/src/main/java/darkknight/jewelrycraft/model/ModelShadowEye.java +++ b/src/main/java/darkknight/jewelrycraft/model/ModelShadowEye.java @@ -119,8 +119,11 @@ public class ModelShadowEye extends ModelBase { else { Eye.rotateAngleX = 0F; - Eye.rotateAngleY = 0F; - Eye.rotateAngleZ = 0F; + Eye.rotateAngleZ = 0F; + if (f3 == 0) Eye.rotateAngleY = (float) (0.5F*Math.PI); + else if (f3 == 1) Eye.rotateAngleY = (float) (Math.PI); + else if (f3 == 2) Eye.rotateAngleY = (float) (1.5F*Math.PI); + else if (f3 == 3) Eye.rotateAngleY = (float) (0F*Math.PI); } } diff --git a/src/main/java/darkknight/jewelrycraft/network/PacketKeyPressEvent.java b/src/main/java/darkknight/jewelrycraft/network/PacketKeyPressEvent.java index 13d0969..34e8364 100644 --- a/src/main/java/darkknight/jewelrycraft/network/PacketKeyPressEvent.java +++ b/src/main/java/darkknight/jewelrycraft/network/PacketKeyPressEvent.java @@ -1,59 +1,60 @@ -package darkknight.jewelrycraft.network; - -import io.netty.buffer.ByteBuf; -import net.minecraft.entity.player.EntityPlayer; -import cpw.mods.fml.common.network.simpleimpl.IMessage; -import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; -import cpw.mods.fml.common.network.simpleimpl.MessageContext; -import darkknight.jewelrycraft.JewelrycraftMod; - -public class PacketKeyPressEvent implements IMessage, IMessageHandler -{ - public int actionID; - - /** - * @param id - */ - public PacketKeyPressEvent(int id) - { - actionID = id; - } - - /** - * - */ - public PacketKeyPressEvent() - {} - - /** - * @param message - * @param ctx - * @return - */ - @Override - public IMessage onMessage(PacketKeyPressEvent message, MessageContext ctx) - { - EntityPlayer sender = ctx.getServerHandler().playerEntity; - // Jewelry inventory - if (message.actionID == 0) sender.openGui(JewelrycraftMod.instance, 2, sender.worldObj, (int)sender.posX, (int)sender.posY, (int)sender.posZ); - return null; - } - - /** - * @param buf - */ - @Override - public void fromBytes(ByteBuf buf) - { - actionID = buf.readInt(); - } - - /** - * @param buf - */ - @Override - public void toBytes(ByteBuf buf) - { - buf.writeInt(actionID); - } -} +package darkknight.jewelrycraft.network; + +import io.netty.buffer.ByteBuf; +import net.minecraft.entity.player.EntityPlayer; +import cpw.mods.fml.common.network.simpleimpl.IMessage; +import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; +import cpw.mods.fml.common.network.simpleimpl.MessageContext; +import darkknight.jewelrycraft.JewelrycraftMod; + +public class PacketKeyPressEvent implements IMessage, IMessageHandler +{ + public int actionID; + + /** + * @param id + */ + public PacketKeyPressEvent(int id) + { + actionID = id; + } + + /** + * + */ + public PacketKeyPressEvent() + {} + + /** + * @param message + * @param ctx + * @return + */ + @Override + public IMessage onMessage(PacketKeyPressEvent message, MessageContext ctx) + { + EntityPlayer sender = ctx.getServerHandler().playerEntity; + // Jewelry inventory + if (message.actionID == 0) sender.openGui(JewelrycraftMod.instance, 2, sender.worldObj, (int)sender.posX, (int)sender.posY, (int)sender.posZ); + if (message.actionID == 1) sender.openGui(JewelrycraftMod.instance, 4, sender.worldObj, (int)sender.posX, (int)sender.posY, (int)sender.posZ); + return null; + } + + /** + * @param buf + */ + @Override + public void fromBytes(ByteBuf buf) + { + actionID = buf.readInt(); + } + + /** + * @param buf + */ + @Override + public void toBytes(ByteBuf buf) + { + buf.writeInt(actionID); + } +} diff --git a/src/main/java/darkknight/jewelrycraft/proxy/ClientProxy.java b/src/main/java/darkknight/jewelrycraft/proxy/ClientProxy.java index ba70925..dbb68be 100644 --- a/src/main/java/darkknight/jewelrycraft/proxy/ClientProxy.java +++ b/src/main/java/darkknight/jewelrycraft/proxy/ClientProxy.java @@ -14,6 +14,7 @@ import darkknight.jewelrycraft.JewelrycraftMod; import darkknight.jewelrycraft.block.BlockList; import darkknight.jewelrycraft.block.render.BlockCrystalRenderer; import darkknight.jewelrycraft.client.InventoryTabVanilla; +import darkknight.jewelrycraft.client.TabCurses; import darkknight.jewelrycraft.client.TabJewelry; import darkknight.jewelrycraft.client.TabRegistry; import darkknight.jewelrycraft.entities.EntityHalfHeart; @@ -106,6 +107,7 @@ public class ClientProxy extends CommonProxy TabRegistry.registerTab(new InventoryTabVanilla()); TabRegistry.registerTab(new TabJewelry()); + TabRegistry.registerTab(new TabCurses()); MinecraftForge.EVENT_BUS.register(new TabRegistry()); MinecraftForge.EVENT_BUS.register(new PlayerRenderHandler()); MinecraftForge.EVENT_BUS.register(new ScreenHandler(Minecraft.getMinecraft())); -- cgit v1.2.3