diff --git a/build.gradle b/build.gradle index dab6af1c..551e0b2b 100644 --- a/build.gradle +++ b/build.gradle @@ -31,7 +31,7 @@ group= "com.brandon3055.draconicevolution" // http://maven.apache.org/guides/min archivesBaseName = "Draconic-Evolution" minecraft { - version = "1.7.10-10.13.2.1236" + version = "1.7.10-10.13.2.1286" //assetDir = "run/assets" } diff --git a/src/main/java/com/brandon3055/draconicevolution/client/ClientProxy.java b/src/main/java/com/brandon3055/draconicevolution/client/ClientProxy.java index fa787d62..3bc87b5c 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/ClientProxy.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/ClientProxy.java @@ -2,7 +2,7 @@ package com.brandon3055.draconicevolution.client; import com.brandon3055.draconicevolution.DraconicEvolution; import com.brandon3055.draconicevolution.client.handler.ClientEventHandler; -import com.brandon3055.draconicevolution.client.handler.ToolHudHandler; +import com.brandon3055.draconicevolution.client.handler.HudHandler; import com.brandon3055.draconicevolution.client.keybinding.KeyBindings; import com.brandon3055.draconicevolution.client.keybinding.KeyInputHandler; import com.brandon3055.draconicevolution.client.render.block.RenderDraconiumChest; @@ -100,7 +100,7 @@ public class ClientProxy extends CommonProxy { super.init(event); FMLCommonHandler.instance().bus().register(new KeyInputHandler()); FMLCommonHandler.instance().bus().register(new ClientEventHandler()); - MinecraftForge.EVENT_BUS.register(new ToolHudHandler()); + MinecraftForge.EVENT_BUS.register(new HudHandler()); MinecraftForge.EVENT_BUS.register(new ClientEventHandler()); KeyBindings.init(); registerRenderIDs(); diff --git a/src/main/java/com/brandon3055/draconicevolution/client/handler/ClientEventHandler.java b/src/main/java/com/brandon3055/draconicevolution/client/handler/ClientEventHandler.java index 7c27228a..af32a45f 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/handler/ClientEventHandler.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/handler/ClientEventHandler.java @@ -31,7 +31,7 @@ public class ClientEventHandler { public void tickEnd(TickEvent event) { if (event.phase != TickEvent.Phase.START || event.side != Side.CLIENT) return; elapsedTicks++; - ToolHudHandler.clientTick(); + HudHandler.clientTick(); if (bowZoom && !lastTickBowZoom){ previousSensitivity = Minecraft.getMinecraft().gameSettings.mouseSensitivity; diff --git a/src/main/java/com/brandon3055/draconicevolution/client/handler/HudHandler.java b/src/main/java/com/brandon3055/draconicevolution/client/handler/HudHandler.java new file mode 100644 index 00000000..b02095fb --- /dev/null +++ b/src/main/java/com/brandon3055/draconicevolution/client/handler/HudHandler.java @@ -0,0 +1,194 @@ +package com.brandon3055.draconicevolution.client.handler; + +import com.brandon3055.draconicevolution.client.interfaces.componentguis.GUIToolConfig; +import com.brandon3055.draconicevolution.common.handler.ConfigHandler; +import com.brandon3055.draconicevolution.common.utills.IHudDisplayBlock; +import com.brandon3055.draconicevolution.common.utills.IHudDisplayItem; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.ScaledResolution; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.util.StatCollector; +import net.minecraftforge.client.event.RenderGameOverlayEvent; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL12; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +/** + * Created by Brandon on 26/01/2015. + */ +public class HudHandler { + + private static List hudList = null; + int width; + int height; + + @SubscribeEvent + @SideOnly(Side.CLIENT) + public void drawHUD(RenderGameOverlayEvent.Post event) { + if (event.type == RenderGameOverlayEvent.ElementType.ALL) { + if (hudList == null) return; + + Minecraft mc = Minecraft.getMinecraft(); + + if (mc.gameSettings.showDebugInfo) return; + + ScaledResolution resolution = event.resolution; + width = resolution.getScaledWidth(); + height = resolution.getScaledHeight(); + FontRenderer fontRenderer = mc.fontRenderer; + + int x = (int) (((float)ConfigHandler.hudX / 1000F) * (float) width); + int y = (int) (((float)ConfigHandler.hudY / 1000F) * (float) height); + + GL11.glPushMatrix(); + GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS); + drawHoveringText(hudList, x, y, fontRenderer); + GL11.glPopAttrib(); + GL11.glPopMatrix(); + } + } + + @SideOnly(Side.CLIENT) + public static void clientTick() { + + Minecraft mc = Minecraft.getMinecraft(); + if (mc == null || mc.thePlayer == null) return; + + hudList = null; + + if (mc.currentScreen != null) + { + if (mc.currentScreen instanceof GUIToolConfig) + { + hudList = new ArrayList(); + hudList.add(StatCollector.translateToLocal("info.de.hudDisplayConfigTxt1.txt")); + hudList.add(""); + hudList.add(StatCollector.translateToLocal("info.de.hudDisplayConfigTxt2.txt")); + hudList.add(""); + hudList.add(StatCollector.translateToLocal("info.de.hudDisplayConfigTxt3.txt")); + } + } + else if (mc.thePlayer.getHeldItem() != null && mc.thePlayer.getHeldItem().getItem() instanceof IHudDisplayItem) { + hudList = ((IHudDisplayItem) mc.thePlayer.getHeldItem().getItem()).getDisplayData( mc.thePlayer.getHeldItem()); + } + + MovingObjectPosition mop = mc.thePlayer.rayTrace(5, 0); + if (mop != null && mop.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK && mc.theWorld.getBlock(mop.blockX, mop.blockY, mop.blockZ) instanceof IHudDisplayBlock) + { + hudList = ((IHudDisplayBlock)mc.theWorld.getBlock(mop.blockX, mop.blockY, mop.blockZ)).getDisplayData(mc.theWorld, mop.blockX, mop.blockY, mop.blockZ); + } + } + + protected void drawHoveringText(List list, int x, int y, FontRenderer font) + { + if (!list.isEmpty()) + { + GL11.glDisable(GL12.GL_RESCALE_NORMAL); +// RenderHelper.disableStandardItemLighting(); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_DEPTH_TEST); + int k = 0; + Iterator iterator = list.iterator(); + + while (iterator.hasNext()) + { + String s = (String)iterator.next(); + int l = font.getStringWidth(s); + + if (l > k) + { + k = l; + } + } + + int adjX = x + 12; + int adjY = y - 12; + int i1 = 8; + + if (list.size() > 1) + { + i1 += 2 + (list.size() - 1) * 10; + } + + if (adjX + k > width) + { + adjX -= 28 + k; + } + + if (adjY + i1 + 6 > height) + { + adjY = height - i1 - 6; + } + + int j1 = -267386864; + this.drawGradientRect(adjX - 3, adjY - 4, adjX + k + 3, adjY - 3, j1, j1); + this.drawGradientRect(adjX - 3, adjY + i1 + 3, adjX + k + 3, adjY + i1 + 4, j1, j1); + this.drawGradientRect(adjX - 3, adjY - 3, adjX + k + 3, adjY + i1 + 3, j1, j1); + this.drawGradientRect(adjX - 4, adjY - 3, adjX - 3, adjY + i1 + 3, j1, j1); + this.drawGradientRect(adjX + k + 3, adjY - 3, adjX + k + 4, adjY + i1 + 3, j1, j1); + int k1 = 1347420415; + int l1 = (k1 & 16711422) >> 1 | k1 & -16777216; + this.drawGradientRect(adjX - 3, adjY - 3 + 1, adjX - 3 + 1, adjY + i1 + 3 - 1, k1, l1); + this.drawGradientRect(adjX + k + 2, adjY - 3 + 1, adjX + k + 3, adjY + i1 + 3 - 1, k1, l1); + this.drawGradientRect(adjX - 3, adjY - 3, adjX + k + 3, adjY - 3 + 1, k1, k1); + this.drawGradientRect(adjX - 3, adjY + i1 + 2, adjX + k + 3, adjY + i1 + 3, l1, l1); + + for (int i2 = 0; i2 < list.size(); ++i2) + { + String s1 = (String)list.get(i2); + font.drawStringWithShadow(s1, adjX, adjY, -1); + + if (i2 == 0) + { + adjY += 2; + } + + adjY += 10; + } + + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_DEPTH_TEST); +// RenderHelper.enableStandardItemLighting(); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + } + } + + protected void drawGradientRect(int x1, int y1, int x2, int y2, int colour1, int colour2) + { + float f = (float)(colour1 >> 24 & 255) / 255.0F; + float f1 = (float)(colour1 >> 16 & 255) / 255.0F; + float f2 = (float)(colour1 >> 8 & 255) / 255.0F; + float f3 = (float)(colour1 & 255) / 255.0F; + float f4 = (float)(colour2 >> 24 & 255) / 255.0F; + float f5 = (float)(colour2 >> 16 & 255) / 255.0F; + float f6 = (float)(colour2 >> 8 & 255) / 255.0F; + float f7 = (float)(colour2 & 255) / 255.0F; + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glEnable(GL11.GL_BLEND); + GL11.glDisable(GL11.GL_ALPHA_TEST); + OpenGlHelper.glBlendFunc(770, 771, 1, 0); + GL11.glShadeModel(GL11.GL_SMOOTH); + Tessellator tessellator = Tessellator.instance; + tessellator.startDrawingQuads(); + tessellator.setColorRGBA_F(f1, f2, f3, f); + tessellator.addVertex((double)x2, (double)y1, 300D); + tessellator.addVertex((double)x1, (double)y1, 300D); + tessellator.setColorRGBA_F(f5, f6, f7, f4); + tessellator.addVertex((double)x1, (double)y2, 300D); + tessellator.addVertex((double)x2, (double)y2, 300D); + tessellator.draw(); + GL11.glShadeModel(GL11.GL_FLAT); + GL11.glDisable(GL11.GL_BLEND); + GL11.glEnable(GL11.GL_ALPHA_TEST); + GL11.glEnable(GL11.GL_TEXTURE_2D); + } +} diff --git a/src/main/java/com/brandon3055/draconicevolution/client/handler/ToolHudHandler.java b/src/main/java/com/brandon3055/draconicevolution/client/handler/ToolHudHandler.java deleted file mode 100644 index 5d399eca..00000000 --- a/src/main/java/com/brandon3055/draconicevolution/client/handler/ToolHudHandler.java +++ /dev/null @@ -1,68 +0,0 @@ -package com.brandon3055.draconicevolution.client.handler; - -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.ScaledResolution; -import net.minecraft.util.MathHelper; -import net.minecraftforge.client.event.RenderGameOverlayEvent; -import org.lwjgl.opengl.GL11; - -import java.awt.*; - -/** - * This class is copied from Thaumic Tinkerer - */ -public class ToolHudHandler { - - private static String currentTooltip; - private static int tooltipDisplayTicks; - - @SubscribeEvent - @SideOnly(Side.CLIENT) - public void drawToolHUD(RenderGameOverlayEvent.Post event) { - if (event.type == RenderGameOverlayEvent.ElementType.ALL && tooltipDisplayTicks > 0 && !MathHelper.stringNullOrLengthZero(currentTooltip)) { - Minecraft mc = Minecraft.getMinecraft(); - ScaledResolution var5 = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight); - int var6 = var5.getScaledWidth(); - int var7 = var5.getScaledHeight(); - FontRenderer var8 = mc.fontRenderer; - - int tooltipStartX = (var6 - var8.getStringWidth(currentTooltip)) / 2; - int tooltipStartY = var7 - 72; - - int opacity = (int) (tooltipDisplayTicks * 256.0F / 10.0F); - - if (opacity > 160) - opacity = 160; - - if (opacity > 0) { - GL11.glPushMatrix(); - GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - int color = Color.getHSBColor((float) Math.cos(ClientEventHandler.elapsedTicks / 250D), 0.6F, 1F).getRGB(); - var8.drawStringWithShadow(currentTooltip, tooltipStartX, tooltipStartY, color + (opacity << 24)); - GL11.glDisable(GL11.GL_BLEND); - GL11.glPopAttrib(); - GL11.glPopMatrix(); - } - } - } - - public static void setTooltip(String tooltip) { - if (!tooltip.equals(currentTooltip)) { - currentTooltip = tooltip; - tooltipDisplayTicks = 500; - } - } - - @SideOnly(Side.CLIENT) - public static void clientTick() { - if (tooltipDisplayTicks > 0) - --tooltipDisplayTicks; - } - -} diff --git a/src/main/java/com/brandon3055/draconicevolution/client/interfaces/GUITeleporter.java b/src/main/java/com/brandon3055/draconicevolution/client/interfaces/GUITeleporter.java index 1e94bba8..d910469d 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/interfaces/GUITeleporter.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/interfaces/GUITeleporter.java @@ -87,6 +87,14 @@ public class GUITeleporter extends GuiScreen fontRendererObj.drawString(colour+"Fuel: " + fuel, posX + 115, posY + 87, 0x000000); super.drawScreen(x, y, f); + + for (int i = 0; i < Math.min(12, locations.size()); i++){ + if (GuiHelper.isInRect(17, 6+i*11, 80, 10, x - posX, y - posY)) { + List l = new ArrayList(); + l.add("Right click to teleport"); + drawHoveringText(l, x, y, fontRendererObj); + } + } } private void drawLocations(int x, int y){ @@ -94,7 +102,9 @@ public class GUITeleporter extends GuiScreen int posY = (this.height - ySize) / 2; for (int i = 0; i < Math.min(12, locations.size()); i++){ - if (GuiHelper.isInRect(17, 6+i*11, 80, 10, x, y)) drawTexturedModalRect(posX+19, posY+5+i*11, 0, 188, 80, 10); + if (GuiHelper.isInRect(17, 6+i*11, 80, 10, x, y)) { + drawTexturedModalRect(posX+19, posY+5+i*11, 0, 188, 80, 10); + } if (locations.get(i+selrctionOffset).getWriteProtected()){ if (GuiHelper.isInRect(102, 7+i*11, 6, 6, x, y)) drawTexturedModalRect(posX+102, posY+7+i*11, 26, 149, 6, 6); @@ -189,10 +199,25 @@ public class GUITeleporter extends GuiScreen //Check for location or lock clicked for (int i = 0; i < Math.min(12, locations.size()); i++){ if (GuiHelper.isInRect(17, 6+i*11, 80, 10, x-posX, y-posY)) { - if (!(locations.get(i+selrctionOffset).getWriteProtected() && editingExisting)) { + if (!(locations.get(i+selrctionOffset).getWriteProtected() && editingExisting) && button == 0) + { selected = i; selectionChanged = true; } + if (!(locations.get(i+selrctionOffset).getWriteProtected() && editingExisting) && button == 1) + { + if (locations.isEmpty()) return; + + if (!player.capabilities.isCreativeMode && fuel <= 0) + { + player.addChatMessage(new ChatComponentTranslation("msg.teleporterOutOfFuel.txt")); + } + + if (player.capabilities.isCreativeMode || fuel > 0) { + fuel--; + DraconicEvolution.network.sendToServer(new TeleporterPacket(TeleporterPacket.TELEPORT, i+selrctionOffset, false)); + } + } } if (GuiHelper.isInRect(99, 8+i*11, 8, 7, x-posX, y-posY)) { @@ -288,10 +313,14 @@ public class GUITeleporter extends GuiScreen buttonList.add(new GuiButtonAHeight(0, posX + 112, posY + 45, 66, 12, "Rename")); buttonList.add(new GuiButtonAHeight(1, posX + 112, posY + 58, 66, 12, "Set Here")); buttonList.add(new GuiButtonAHeight(2, posX + 112, posY + 71, 66, 12, "Remove")); - buttonList.add(new GuiButtonAHeight(3, posX + 112, posY + 99, 66, 12, "Teleport")); + + buttonList.add(new GuiButtonAHeight(3, posX + 112, posY + 99, 33, 12, "▲ ▲ ▲")); + buttonList.add(new GuiButtonAHeight(4, posX + 112, posY + 112, 66, 12, "Add New")); buttonList.add(new GuiButtonAHeight(5, posX + 112, posY + 125, 66, 12, "Add Fuel")); buttonList.add(new GuiButtonAHeight(6, posX+xSize-63, posY-15, 60, 15, "Cancel")); + + buttonList.add(new GuiButtonAHeight(7, posX + 112 + 34, posY + 99, 33, 12, "▼ ▼ ▼")); ((GuiButton) buttonList.get(6)).visible = false; textBeingEdited = new GuiTextField(fontRendererObj, posX+3, posY-14, xSize-67, 12); @@ -349,22 +378,30 @@ public class GUITeleporter extends GuiScreen if (selected >= locations.size()) selected--; } - if (button.id == 3){ - if (locations.isEmpty()) return; - if (player.isRiding()) + if (button.id == 3 || button.id == 7) + { + if (button.id == 3) { - return; + if (selected > 0) + { + TeleportLocation temp = locations.get(selected + selrctionOffset); + locations.set(selected + selrctionOffset, locations.get(selected + selrctionOffset - 1)); + locations.set(selected + selrctionOffset - 1, temp); + selected--; + } + } + else + { + if (selected < Math.min(11, locations.size())) + { + TeleportLocation temp = locations.get(selected + selrctionOffset); + locations.set(selected + selrctionOffset, locations.get(selected + selrctionOffset + 1)); + locations.set(selected + selrctionOffset + 1, temp); + selected++; + } } - if (!player.capabilities.isCreativeMode && fuel <= 0) - { - player.addChatMessage(new ChatComponentTranslation("msg.teleporterOutOfFuel.txt")); - } - - if (player.capabilities.isCreativeMode || fuel > 0) { - fuel--; - DraconicEvolution.network.sendToServer(new TeleporterPacket(TeleporterPacket.TELEPORT, selected+selrctionOffset, false)); - } + DraconicEvolution.network.sendToServer(new TeleporterPacket(TeleporterPacket.MOVELOCATION, selected+selrctionOffset, button.id == 3)); } if (button.id == 4 || button.id == 6 && !editingExisting){ diff --git a/src/main/java/com/brandon3055/draconicevolution/client/interfaces/componentguis/GUIToolConfig.java b/src/main/java/com/brandon3055/draconicevolution/client/interfaces/componentguis/GUIToolConfig.java index 1da94068..93669087 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/interfaces/componentguis/GUIToolConfig.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/interfaces/componentguis/GUIToolConfig.java @@ -2,15 +2,18 @@ package com.brandon3055.draconicevolution.client.interfaces.componentguis; import com.brandon3055.draconicevolution.client.interfaces.guicomponents.*; import com.brandon3055.draconicevolution.common.container.ContainerAdvTool; -import com.brandon3055.draconicevolution.common.items.tools.baseclasses.MiningTool; +import com.brandon3055.draconicevolution.common.handler.ConfigHandler; import com.brandon3055.draconicevolution.common.lib.References; import com.brandon3055.draconicevolution.common.utills.IConfigurableItem; +import com.brandon3055.draconicevolution.common.utills.IInventoryTool; import com.brandon3055.draconicevolution.common.utills.ItemConfigField; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiButton; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; +import net.minecraft.util.StatCollector; +import net.minecraftforge.common.config.Configuration; /** * Created by Brandon on 26/12/2014. @@ -22,11 +25,13 @@ public class GUIToolConfig extends GUIBase { private int screenLevel = 0; private ItemStack editingItem; private ContainerAdvTool container; + private boolean draggingHud = false; public GUIToolConfig(EntityPlayer player, ContainerAdvTool container) { super(container, 198, 89); this.container = container; this.player = player; + container.setSlotsActive(false); addDependentComponents(); } @@ -72,6 +77,16 @@ public class GUIToolConfig extends GUIBase { @Override protected void mouseClicked(int x, int y, int button) { super.mouseClicked(x, y, button); + + if (!collection.isMouseOver(x - guiLeft, y - guiTop)) { + draggingHud = true; + int x1 = (int) (((float) x / (float) width) * 1000f); + int y1 = (int) (((float) y / (float) height) * 1000f); + + ConfigHandler.hudX = x1; + ConfigHandler.hudY = y1; + } + if (buttonPressed) return; @@ -98,6 +113,30 @@ public class GUIToolConfig extends GUIBase { } } + @Override + protected void mouseClickMove(int x, int y, int button, long time) { + super.mouseClickMove(x, y, button, time); + if (draggingHud) + { + int x1 = (int) (((float) x / (float) width) * 1000f); + int y1 = (int) (((float) y / (float) height) * 1000f); + + ConfigHandler.hudX = x1; + ConfigHandler.hudY = y1; + } + } + + @Override + protected void mouseMovedOrUp(int x, int y, int button) { + super.mouseMovedOrUp(x, y, button); + if (draggingHud) { + draggingHud = false; + ConfigHandler.config.get(Configuration.CATEGORY_GENERAL, "Hud Display X pos", 7).set(ConfigHandler.hudX); + ConfigHandler.config.get(Configuration.CATEGORY_GENERAL, "Hud Display Y pos", 874).set(ConfigHandler.hudY); + ConfigHandler.config.save(); + } + } + @Override public void buttonClicked(int id) { super.buttonClicked(id); @@ -107,12 +146,18 @@ public class GUIToolConfig extends GUIBase { } else if (id == 1 && editingItem != null){//inventory button setLevel(3); - Minecraft.getMinecraft().displayGuiScreen(new GUIToolInventory(player, container)); + Minecraft.getMinecraft().displayGuiScreen(new GUIToolInventory(player, container, this)); // LogHelper.info("Pre send container " + Minecraft.getMinecraft().thePlayer.openContainer); // DraconicEvolution.network.sendToServer(new ButtonPacket(ButtonPacket.ID_TOOLINVENTORY, false)); } } + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { + super.drawGuiContainerForegroundLayer(mouseX, mouseY); + fontRendererObj.drawString(StatCollector.translateToLocal("info.de.hudDisplayConfigInfo1.txt") + " " + StatCollector.translateToLocal("info.de.hudDisplayConfigInfo2.txt"), 0, 91, 0xffffff); + } + public void setLevel(int level){ this.screenLevel = level; @@ -126,7 +171,7 @@ public class GUIToolConfig extends GUIBase { collection.setOnlyGroupEnabled("LIST_SCREEN"); collection.setGroupEnabled("BACKGROUND", true); collection.setComponentEnabled("BACK_BUTTON", true); - if (editingItem != null && editingItem.getItem() instanceof MiningTool) collection.setComponentEnabled("INVENTORY_BUTTON", true); + if (editingItem != null && editingItem.getItem() instanceof IInventoryTool) collection.setComponentEnabled("INVENTORY_BUTTON", true); if (collection.getComponent("BACK_BUTTON") != null) collection.getComponent("BACK_BUTTON").setY(26); } else if (level == 2){//field screen diff --git a/src/main/java/com/brandon3055/draconicevolution/client/interfaces/componentguis/GUIToolInventory.java b/src/main/java/com/brandon3055/draconicevolution/client/interfaces/componentguis/GUIToolInventory.java index 5291878b..e9cce3ef 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/interfaces/componentguis/GUIToolInventory.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/interfaces/componentguis/GUIToolInventory.java @@ -1,11 +1,9 @@ package com.brandon3055.draconicevolution.client.interfaces.componentguis; -import com.brandon3055.draconicevolution.client.interfaces.guicomponents.ComponentTexturedRect; -import com.brandon3055.draconicevolution.client.interfaces.guicomponents.ComponentCollection; -import com.brandon3055.draconicevolution.client.interfaces.guicomponents.ComponentSlotBackground; -import com.brandon3055.draconicevolution.client.interfaces.guicomponents.GUIBase; +import com.brandon3055.draconicevolution.client.interfaces.guicomponents.*; import com.brandon3055.draconicevolution.common.container.ContainerAdvTool; import com.brandon3055.draconicevolution.common.lib.References; +import net.minecraft.client.Minecraft; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.ResourceLocation; import org.lwjgl.opengl.GL11; @@ -19,20 +17,29 @@ public class GUIToolInventory extends GUIBase { private ContainerAdvTool container; private String inventoryName; + private EntityPlayer player; + private GUIToolConfig guiToolConfig; public GUIToolInventory(EntityPlayer player, ContainerAdvTool container) { super(container, 198, 130); this.container = container; this.container.setSlotsActive(true); this.inventoryName = container.inventoryTool.getInventoryName(); + this.player = player; addDependentComponents(); } + public GUIToolInventory(EntityPlayer player, ContainerAdvTool container, GUIToolConfig guiToolConfig) { + this(player, container); + this.guiToolConfig = guiToolConfig; + } + @Override protected ComponentCollection assembleComponents() { ComponentCollection c = new ComponentCollection(0, 0, xSize, ySize, this); c.addComponent(new ComponentTexturedRect(0, 130 - 89, 198, 89, inventoryTexture)).setGroup("BACKGROUND"); c.addComponent(new ComponentTexturedRect(0, 0, 198, 80, inventoryTexture)).setGroup("BACKGROUND"); + c.addComponent(new ComponentButton(172, 3, 18, 12, 0, this, "<=", "Back")); for (int i = 0; i < 5; i++) { @@ -42,10 +49,20 @@ public class GUIToolInventory extends GUIBase { return c; } + @Override + public void buttonClicked(int id) { + super.buttonClicked(id); + if (guiToolConfig == null) guiToolConfig = new GUIToolConfig(player, container); + Minecraft.getMinecraft().displayGuiScreen(guiToolConfig); + guiToolConfig.setLevel(1); + container.setSlotsActive(false); + } + @Override protected void addDependentComponents() { for (int x = 0; x < container.inventoryTool.size; x++) collection.addComponent(new ComponentSlotBackground(7 + x * 18, 18)).setGroup("INVENTORY"); ComponentSlotBackground.addInventorySlots(collection, 7, 44, container.inventoryItemSlot); + if (container.inventoryItemSlot > 35) collection.addComponent(new ComponentItemRenderer(6, 18, container.inventoryTool.inventoryItem)).setGroup("INVENTORY"); } @Override diff --git a/src/main/java/com/brandon3055/draconicevolution/client/interfaces/guicomponents/ComponentConfigItemButton.java b/src/main/java/com/brandon3055/draconicevolution/client/interfaces/guicomponents/ComponentConfigItemButton.java index e93e5fc4..42f5cde2 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/interfaces/guicomponents/ComponentConfigItemButton.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/interfaces/guicomponents/ComponentConfigItemButton.java @@ -2,6 +2,7 @@ package com.brandon3055.draconicevolution.client.interfaces.guicomponents; import com.brandon3055.draconicevolution.common.lib.References; import com.brandon3055.draconicevolution.common.utills.IConfigurableItem; +import com.brandon3055.draconicevolution.common.utills.IInventoryTool; import com.brandon3055.draconicevolution.common.utills.ItemConfigField; import net.minecraft.client.Minecraft; import net.minecraft.client.audio.PositionedSoundRecord; @@ -26,7 +27,7 @@ public class ComponentConfigItemButton extends ComponentBase { super(x, y); this.slot = slot; this.inventory = player.inventory; - if (inventory.getStackInSlot(slot) != null && inventory.getStackInSlot(slot).getItem() instanceof IConfigurableItem && !((IConfigurableItem) inventory.getStackInSlot(slot).getItem()).getFields(inventory.getStackInSlot(slot), slot).isEmpty()) hasValidItem = true;//todo && instanceof IConfigurableItem + if (inventory.getStackInSlot(slot) != null && ((inventory.getStackInSlot(slot).getItem() instanceof IConfigurableItem && !((IConfigurableItem) inventory.getStackInSlot(slot).getItem()).getFields(inventory.getStackInSlot(slot), slot).isEmpty()) || inventory.getStackInSlot(slot).getItem() instanceof IInventoryTool)) hasValidItem = true;//todo && instanceof IConfigurableItem } @Override diff --git a/src/main/java/com/brandon3055/draconicevolution/client/interfaces/guicomponents/ComponentItemRenderer.java b/src/main/java/com/brandon3055/draconicevolution/client/interfaces/guicomponents/ComponentItemRenderer.java index d370b321..fe0ac67c 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/interfaces/guicomponents/ComponentItemRenderer.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/interfaces/guicomponents/ComponentItemRenderer.java @@ -4,6 +4,7 @@ import com.brandon3055.draconicevolution.common.lib.References; import net.minecraft.client.Minecraft; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; /** * Created by Brandon on 31/12/2014. @@ -33,7 +34,9 @@ public class ComponentItemRenderer extends ComponentBase { } @Override - public void renderForground(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY) { + public void renderForground(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY) + { + GL11.glColor4f(1f, 1f, 1f, 1f); Minecraft.getMinecraft().renderEngine.bindTexture(texture); drawTexturedModalRect(x, y, 118, 0, getWidth(), getHeight()); drawItemStack(stack, x + 2, y + 2, "null"); diff --git a/src/main/java/com/brandon3055/draconicevolution/common/blocks/CustomSpawner.java b/src/main/java/com/brandon3055/draconicevolution/common/blocks/CustomSpawner.java index 56b52f09..f42c3fda 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/blocks/CustomSpawner.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/blocks/CustomSpawner.java @@ -5,11 +5,14 @@ import com.brandon3055.draconicevolution.common.ModBlocks; import com.brandon3055.draconicevolution.common.ModItems; import com.brandon3055.draconicevolution.common.lib.Strings; import com.brandon3055.draconicevolution.common.tileentities.TileCustomSpawner; +import com.brandon3055.draconicevolution.common.utills.IHudDisplayBlock; +import com.brandon3055.draconicevolution.common.utills.InfoHelper; import com.brandon3055.draconicevolution.common.utills.ItemNBTHelper; import com.brandon3055.draconicevolution.common.utills.LogHelper; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; @@ -17,20 +20,19 @@ import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ChatComponentText; -import net.minecraft.util.ChatComponentTranslation; -import net.minecraft.util.EnumChatFormatting; -import net.minecraft.util.MovingObjectPosition; +import net.minecraft.util.*; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; +import java.util.ArrayList; +import java.util.List; import java.util.Random; /** * Created by Brandon on 5/07/2014. */ -public class CustomSpawner extends BlockDE{ +public class CustomSpawner extends BlockDE implements IHudDisplayBlock { public CustomSpawner() { this.setBlockName(Strings.customSpawnerName); @@ -79,23 +81,23 @@ public class CustomSpawner extends BlockDE{ return true; }else { - if (world.isRemote && !player.isSneaking()) { - player.addChatMessage(new ChatComponentText(EnumChatFormatting.GOLD + "#################################")); - player.addChatMessage(new ChatComponentTranslation("msg.spawnerInfo1.txt").appendText(": " + EnumChatFormatting.DARK_AQUA + spawner.getBaseLogic().entityName)); - player.addChatMessage(new ChatComponentTranslation("msg.spawnerInfo2.txt").appendText(": " + EnumChatFormatting.DARK_AQUA + spawner.getBaseLogic().requiresPlayer)); - player.addChatMessage(new ChatComponentTranslation("msg.spawnerInfo3.txt").appendText(": " + EnumChatFormatting.DARK_AQUA + spawner.getBaseLogic().ignoreSpawnRequirements)); - player.addChatMessage(new ChatComponentTranslation("msg.spawnerInfo4.txt").appendText(": " + EnumChatFormatting.DARK_AQUA + spawner.getBaseLogic().spawnSpeed)); - player.addChatMessage(new ChatComponentTranslation("msg.spawnerInfo5.txt")); - player.addChatMessage(new ChatComponentText(EnumChatFormatting.GOLD + "#################################")); - }else if (world.isRemote && player.isSneaking()) - { - player.addChatMessage(new ChatComponentText(EnumChatFormatting.GOLD + "#################################")); - player.addChatMessage(new ChatComponentTranslation("msg.spawnerInfo6.txt")); - player.addChatMessage(new ChatComponentTranslation("msg.spawnerInfo7.txt")); - player.addChatMessage(new ChatComponentTranslation("msg.spawnerInfo8.txt")); - player.addChatMessage(new ChatComponentTranslation("msg.spawnerInfo9.txt")); - player.addChatMessage(new ChatComponentText(EnumChatFormatting.GOLD + "#################################")); - } +// if (world.isRemote && !player.isSneaking()) { +// player.addChatMessage(new ChatComponentText(EnumChatFormatting.GOLD + "#################################")); +// player.addChatMessage(new ChatComponentTranslation("msg.spawnerInfo1.txt").appendText(": " + EnumChatFormatting.DARK_AQUA + spawner.getBaseLogic().entityName)); +// player.addChatMessage(new ChatComponentTranslation("msg.spawnerInfo2.txt").appendText(": " + EnumChatFormatting.DARK_AQUA + spawner.getBaseLogic().requiresPlayer)); +// player.addChatMessage(new ChatComponentTranslation("msg.spawnerInfo3.txt").appendText(": " + EnumChatFormatting.DARK_AQUA + spawner.getBaseLogic().ignoreSpawnRequirements)); +// player.addChatMessage(new ChatComponentTranslation("msg.spawnerInfo4.txt").appendText(": " + EnumChatFormatting.DARK_AQUA + spawner.getBaseLogic().spawnSpeed)); +// player.addChatMessage(new ChatComponentTranslation("msg.spawnerInfo5.txt")); +// player.addChatMessage(new ChatComponentText(EnumChatFormatting.GOLD + "#################################")); +// }else if (world.isRemote && player.isSneaking()) +// { +// player.addChatMessage(new ChatComponentText(EnumChatFormatting.GOLD + "#################################")); +// player.addChatMessage(new ChatComponentTranslation("msg.spawnerInfo6.txt")); +// player.addChatMessage(new ChatComponentTranslation("msg.spawnerInfo7.txt")); +// player.addChatMessage(new ChatComponentTranslation("msg.spawnerInfo8.txt")); +// player.addChatMessage(new ChatComponentTranslation("msg.spawnerInfo9.txt")); +// player.addChatMessage(new ChatComponentText(EnumChatFormatting.GOLD + "#################################")); +// } return true; } } @@ -161,7 +163,7 @@ public class CustomSpawner extends BlockDE{ } @Override - public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) { + public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z, EntityPlayer player) { return new ItemStack(ModBlocks.customSpawner); } @@ -209,4 +211,31 @@ public class CustomSpawner extends BlockDE{ } super.breakBlock(world, x, y, z, p_149749_5_, p_149749_6_); } + + @Override + public List getDisplayData(World world, int x, int y, int z) { + TileCustomSpawner spawner = (world.getTileEntity(x, y, z) != null && world.getTileEntity(x, y, z) instanceof TileCustomSpawner) ? (TileCustomSpawner)world.getTileEntity(x, y, z) : null; + List list = new ArrayList(); + if (spawner != null) + { + list.add(InfoHelper.HITC()+getLocalizedName()); + if (world.isRemote && !Minecraft.getMinecraft().thePlayer.isSneaking()) + { + list.add(StatCollector.translateToLocal("msg.spawnerInfo1.txt") + ": " + EnumChatFormatting.DARK_AQUA + spawner.getBaseLogic().entityName); + list.add(StatCollector.translateToLocal("msg.spawnerInfo2.txt") + ": " + EnumChatFormatting.DARK_AQUA + spawner.getBaseLogic().requiresPlayer); + list.add(StatCollector.translateToLocal("msg.spawnerInfo3.txt") + ": " + EnumChatFormatting.DARK_AQUA + spawner.getBaseLogic().ignoreSpawnRequirements); + list.add(StatCollector.translateToLocal("msg.spawnerInfo4.txt") + ": " + EnumChatFormatting.DARK_AQUA + spawner.getBaseLogic().spawnSpeed); + list.add(StatCollector.translateToLocal("msg.spawnerInfo5.txt")); + } + else if (world.isRemote && Minecraft.getMinecraft().thePlayer.isSneaking()) + { + list.add(StatCollector.translateToLocal("msg.spawnerInfo6.txt")); + list.add(StatCollector.translateToLocal("msg.spawnerInfo7.txt")); + list.add(StatCollector.translateToLocal("msg.spawnerInfo8.txt")); + list.add(StatCollector.translateToLocal("msg.spawnerInfo9.txt")); + } + + } + return list; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/blocks/multiblock/EnergyStorageCore.java b/src/main/java/com/brandon3055/draconicevolution/common/blocks/multiblock/EnergyStorageCore.java index c5918cdb..36c03c57 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/blocks/multiblock/EnergyStorageCore.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/blocks/multiblock/EnergyStorageCore.java @@ -1,13 +1,15 @@ package com.brandon3055.draconicevolution.common.blocks.multiblock; import com.brandon3055.draconicevolution.DraconicEvolution; -import com.brandon3055.draconicevolution.common.blocks.BlockDE; import com.brandon3055.draconicevolution.common.ModBlocks; -import com.brandon3055.draconicevolution.common.utills.LogHelper; -import com.brandon3055.draconicevolution.common.utills.Utills; +import com.brandon3055.draconicevolution.common.blocks.BlockDE; import com.brandon3055.draconicevolution.common.lib.References; import com.brandon3055.draconicevolution.common.lib.Strings; import com.brandon3055.draconicevolution.common.tileentities.multiblocktiles.TileEnergyStorageCore; +import com.brandon3055.draconicevolution.common.utills.IHudDisplayBlock; +import com.brandon3055.draconicevolution.common.utills.InfoHelper; +import com.brandon3055.draconicevolution.common.utills.LogHelper; +import com.brandon3055.draconicevolution.common.utills.Utills; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.Block; @@ -16,16 +18,18 @@ import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.AxisAlignedBB; -import net.minecraft.util.ChatComponentText; import net.minecraft.util.StatCollector; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; +import java.util.ArrayList; +import java.util.List; + /** * Created by Brandon on 25/07/2014. */ -public class EnergyStorageCore extends BlockDE { +public class EnergyStorageCore extends BlockDE implements IHudDisplayBlock{ public EnergyStorageCore() { super(Material.iron); @@ -55,18 +59,18 @@ public class EnergyStorageCore extends BlockDE { @Override public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) { - TileEnergyStorageCore tile = (world.getTileEntity(x, y, z) != null && world.getTileEntity(x, y, z) instanceof TileEnergyStorageCore) ? (TileEnergyStorageCore) world.getTileEntity(x, y, z) : null; - if (tile == null) - { - LogHelper.error("Missing Tile Entity (EnergyStorageCore)"); - return false; - } - - if (!world.isRemote) { - player.addChatComponentMessage(new ChatComponentText("Tier:" + tile.getTier())); - String BN = String.valueOf(tile.getEnergyStored()); - if (BN.substring(BN.length() - 2).contentEquals(".0")) BN = BN.substring(0, BN.length() - 2); - player.addChatComponentMessage(new ChatComponentText(StatCollector.translateToLocal("info.de.charge.txt") + ": " + Utills.formatNumber(tile.getEnergyStored()) + " / " + Utills.formatNumber(tile.getMaxEnergyStored()) + " [" + BN + " RF]")); } +// TileEnergyStorageCore tile = (world.getTileEntity(x, y, z) != null && world.getTileEntity(x, y, z) instanceof TileEnergyStorageCore) ? (TileEnergyStorageCore) world.getTileEntity(x, y, z) : null; +// if (tile == null) +// { +// LogHelper.error("Missing Tile Entity (EnergyStorageCore)"); +// return false; +// } +// +// if (!world.isRemote) { +// player.addChatComponentMessage(new ChatComponentText("Tier:" + tile.getTier())); +// String BN = String.valueOf(tile.getEnergyStored()); +// if (BN.substring(BN.length() - 2).contentEquals(".0")) BN = BN.substring(0, BN.length() - 2); +// player.addChatComponentMessage(new ChatComponentText(StatCollector.translateToLocal("info.de.charge.txt") + ": " + Utills.formatNumber(tile.getEnergyStored()) + " / " + Utills.formatNumber(tile.getMaxEnergyStored()) + " [" + BN + " RF]")); } return true; } @@ -114,4 +118,24 @@ public class EnergyStorageCore extends BlockDE { } return super.getSelectedBoundingBoxFromPool(world, x, y, z); } + + @Override + public List getDisplayData(World world, int x, int y, int z) { + List list = new ArrayList(); + + TileEnergyStorageCore tile = (world.getTileEntity(x, y, z) != null && world.getTileEntity(x, y, z) instanceof TileEnergyStorageCore) ? (TileEnergyStorageCore) world.getTileEntity(x, y, z) : null; + if (tile == null) + { + LogHelper.error("Missing Tile Entity (EnergyStorageCore getDisplayData)"); + return list; + } + + list.add(InfoHelper.HITC()+getLocalizedName()); + list.add("Tier: " + InfoHelper.ITC() + tile.getTier()); + String BN = String.valueOf(tile.getEnergyStored()); + if (BN.substring(BN.length() - 2).contentEquals(".0")) BN = BN.substring(0, BN.length() - 2); + list.add(StatCollector.translateToLocal("info.de.charge.txt") + ": " + InfoHelper.ITC() + Utills.formatNumber(tile.getEnergyStored()) + " / " + Utills.formatNumber(tile.getMaxEnergyStored()) + " [" + BN + " RF]"); + + return list; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/blocks/multiblock/InvisibleMultiblock.java b/src/main/java/com/brandon3055/draconicevolution/common/blocks/multiblock/InvisibleMultiblock.java index a6346070..f87d67d8 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/blocks/multiblock/InvisibleMultiblock.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/blocks/multiblock/InvisibleMultiblock.java @@ -1,14 +1,16 @@ package com.brandon3055.draconicevolution.common.blocks.multiblock; -import com.brandon3055.draconicevolution.common.blocks.BlockDE; import com.brandon3055.draconicevolution.common.ModBlocks; -import com.brandon3055.draconicevolution.common.utills.LogHelper; -import com.brandon3055.draconicevolution.common.utills.Utills; +import com.brandon3055.draconicevolution.common.blocks.BlockDE; import com.brandon3055.draconicevolution.common.lib.References; import com.brandon3055.draconicevolution.common.lib.Strings; import com.brandon3055.draconicevolution.common.tileentities.multiblocktiles.TileEnergyPylon; import com.brandon3055.draconicevolution.common.tileentities.multiblocktiles.TileEnergyStorageCore; import com.brandon3055.draconicevolution.common.tileentities.multiblocktiles.TileInvisibleMultiblock; +import com.brandon3055.draconicevolution.common.utills.IHudDisplayBlock; +import com.brandon3055.draconicevolution.common.utills.InfoHelper; +import com.brandon3055.draconicevolution.common.utills.LogHelper; +import com.brandon3055.draconicevolution.common.utills.Utills; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.Block; @@ -20,17 +22,18 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.AxisAlignedBB; -import net.minecraft.util.ChatComponentText; import net.minecraft.util.MovingObjectPosition; import net.minecraft.util.StatCollector; import net.minecraft.world.World; +import java.util.ArrayList; +import java.util.List; import java.util.Random; /** * Created by Brandon on 25/07/2014. */ -public class InvisibleMultiblock extends BlockDE { +public class InvisibleMultiblock extends BlockDE implements IHudDisplayBlock { public InvisibleMultiblock() { super(Material.iron); @@ -89,23 +92,23 @@ public class InvisibleMultiblock extends BlockDE { public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) { int meta = world.getBlockMetadata(x, y, z); if (meta == 0 || meta == 1) { - TileInvisibleMultiblock thisTile = (world.getTileEntity(x, y, z) != null && world.getTileEntity(x, y, z) instanceof TileInvisibleMultiblock) ? (TileInvisibleMultiblock) world.getTileEntity(x, y, z) : null; - if (thisTile == null) { - LogHelper.error("Missing Tile Entity (TileInvisibleMultiblock)"); - return false; - } - TileEnergyStorageCore master = thisTile.getMaster(); - if (master == null) { - onNeighborBlockChange(world, x, y, z, this); - return false; - } - if (!world.isRemote) { - world.markBlockForUpdate(master.xCoord, master.yCoord, master.zCoord); - player.addChatComponentMessage(new ChatComponentText("Tier:" + master.getTier())); - String BN = String.valueOf(master.getEnergyStored()); - if (BN.substring(BN.length() - 2).contentEquals(".0")) BN = BN.substring(0, BN.length() - 2); - player.addChatComponentMessage(new ChatComponentText(StatCollector.translateToLocal("info.de.charge.txt") + ": " + Utills.formatNumber(master.getEnergyStored()) + " / " + Utills.formatNumber(master.getMaxEnergyStored()) + " [" + BN + " RF]")); - } +// TileInvisibleMultiblock thisTile = (world.getTileEntity(x, y, z) != null && world.getTileEntity(x, y, z) instanceof TileInvisibleMultiblock) ? (TileInvisibleMultiblock) world.getTileEntity(x, y, z) : null; +// if (thisTile == null) { +// LogHelper.error("Missing Tile Entity (TileInvisibleMultiblock)"); +// return false; +// } +// TileEnergyStorageCore master = thisTile.getMaster(); +// if (master == null) { +// onNeighborBlockChange(world, x, y, z, this); +// return false; +// } +// if (!world.isRemote) { +// world.markBlockForUpdate(master.xCoord, master.yCoord, master.zCoord); +// player.addChatComponentMessage(new ChatComponentText("Tier:" + master.getTier())); +// String BN = String.valueOf(master.getEnergyStored()); +// if (BN.substring(BN.length() - 2).contentEquals(".0")) BN = BN.substring(0, BN.length() - 2); +// player.addChatComponentMessage(new ChatComponentText(StatCollector.translateToLocal("info.de.charge.txt") + ": " + Utills.formatNumber(master.getEnergyStored()) + " / " + Utills.formatNumber(master.getMaxEnergyStored()) + " [" + BN + " RF]")); +// } return true; } else if (meta == 2) { TileEnergyPylon pylon = (world.getTileEntity(x, y+1, z) != null && world.getTileEntity(x, y+1, z) instanceof TileEnergyPylon) ? (TileEnergyPylon) world.getTileEntity(x, y+1, z) : (world.getTileEntity(x, y-1, z) != null && world.getTileEntity(x, y-1, z) instanceof TileEnergyPylon) ? (TileEnergyPylon) world.getTileEntity(x, y-1, z) : null; @@ -178,7 +181,7 @@ public class InvisibleMultiblock extends BlockDE { } @Override - public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) { + public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z, EntityPlayer player) { if (world.getBlockMetadata(x, y, z) == 0) return new ItemStack(ModBlocks.draconiumBlock); else if (world.getBlockMetadata(x, y, z) == 1) @@ -186,4 +189,33 @@ public class InvisibleMultiblock extends BlockDE { else return new ItemStack(Blocks.glass); } + + @Override + public List getDisplayData(World world, int x, int y, int z) { + List list = new ArrayList(); + + int meta = world.getBlockMetadata(x, y, z); + if (meta == 0 || meta == 1) + { + TileInvisibleMultiblock thisTile = (world.getTileEntity(x, y, z) != null && world.getTileEntity(x, y, z) instanceof TileInvisibleMultiblock) ? (TileInvisibleMultiblock) world.getTileEntity(x, y, z) : null; + if (thisTile == null) { + LogHelper.error("Missing Tile Entity (TileInvisibleMultiblock getDisplayData)"); + return list; + } + + TileEnergyStorageCore master = thisTile.getMaster(); + + if (master == null) { return list; } + + list.add(InfoHelper.HITC() + ModBlocks.energyStorageCore.getLocalizedName()); + list.add("Tier: " + InfoHelper.ITC() + master.getTier()); + String BN = String.valueOf(master.getEnergyStored()); + if (BN.substring(BN.length() - 2).contentEquals(".0")) BN = BN.substring(0, BN.length() - 2); + list.add(StatCollector.translateToLocal("info.de.charge.txt") + ": " + InfoHelper.ITC() + Utills.formatNumber(master.getEnergyStored()) + " / " + Utills.formatNumber(master.getMaxEnergyStored()) + " [" + BN + " RF]"); + + return list; + } + + return list; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/container/ContainerAdvTool.java b/src/main/java/com/brandon3055/draconicevolution/common/container/ContainerAdvTool.java index 31f99830..7bd5321a 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/container/ContainerAdvTool.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/container/ContainerAdvTool.java @@ -1,13 +1,17 @@ package com.brandon3055.draconicevolution.common.container; import com.brandon3055.draconicevolution.common.inventory.InventoryTool; -import com.brandon3055.draconicevolution.common.items.tools.baseclasses.MiningTool; +import com.brandon3055.draconicevolution.common.utills.IInventoryTool; +import net.minecraft.enchantment.Enchantment; +import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.init.Items; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagList; import java.util.ArrayList; @@ -49,7 +53,7 @@ public class ContainerAdvTool extends ContainerDataSync { } for (int y = 0; y < 5; y++) { - addSlotToContainer(new Slot(inventoryTool, inventoryTool.size + y, 173, 19 + y * 21)); + addSlotToContainer(new SlotEnchantment(inventoryTool, inventoryTool.size + y, 173, 19 + y * 21)); } } @@ -123,7 +127,7 @@ public class ContainerAdvTool extends ContainerDataSync { sendObjectToServer(null, 0, slot); } - if (player.inventory.getStackInSlot(slot) != null && player.inventory.getStackInSlot(slot).getItem() instanceof MiningTool){ + if (player.inventory.getStackInSlot(slot) != null && player.inventory.getStackInSlot(slot).getItem() instanceof IInventoryTool){ this.inventoryTool.setAndReadFromStack(player.inventory.getStackInSlot(slot), slot); } } @@ -152,5 +156,25 @@ public class ContainerAdvTool extends ContainerDataSync { public boolean isItemValid(ItemStack stack) { return stack != null && stack.getItem() instanceof ItemBlock && super.isItemValid(stack); } + + + } + + public class SlotEnchantment extends Slot { + InventoryTool inventory; + public SlotEnchantment(IInventory iInventory, int slot, int x, int y) { + super(iInventory, slot, x, y); + } + + @Override + public boolean isItemValid(ItemStack stack) { + if (stack == null || stack.getItem() != Items.enchanted_book || !stack.hasTagCompound()) return false; + NBTTagList list = stack.getTagCompound().getTagList("StoredEnchantments", 10); + if (list.tagCount() != 1) return false; + Enchantment enchant = Enchantment.enchantmentsList[list.getCompoundTagAt(0).getInteger("id")]; + if (inventoryTool.inventoryItem == null || !(inventoryTool.inventoryItem.getItem() instanceof IInventoryTool) || !((IInventoryTool) inventoryTool.inventoryItem.getItem()).isEnchantValid(enchant)) return false; + if (EnchantmentHelper.getEnchantments(inventoryTool.inventoryItem).containsKey(list.getCompoundTagAt(0).getInteger("id"))) return false; + return super.isItemValid(stack); + } } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/container/ContainerToolConfig.java b/src/main/java/com/brandon3055/draconicevolution/common/container/ContainerToolConfig.java deleted file mode 100644 index 4018a9b3..00000000 --- a/src/main/java/com/brandon3055/draconicevolution/common/container/ContainerToolConfig.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.brandon3055.draconicevolution.common.container; - -import com.brandon3055.draconicevolution.DraconicEvolution; -import net.minecraft.entity.player.EntityPlayer; - -/** - * Created by Brandon on 15/01/2015. - */ -public class ContainerToolConfig extends ContainerDataSync {//todo delete - public int slot = -1; - - @Override - public boolean canInteractWith(EntityPlayer p_75145_1_) { - return true; - } - - @Override - public void receiveSyncData(int index, int value) { - if (index == 0) slot = value; - } - - public void setSlot(int slot){ - if (DraconicEvolution.proxy.isDedicatedServer()){ - sendObjectToServer(null, 0, slot); - } - this.slot = slot; - } - -} diff --git a/src/main/java/com/brandon3055/draconicevolution/common/handler/ConfigHandler.java b/src/main/java/com/brandon3055/draconicevolution/common/handler/ConfigHandler.java index 5570274b..4860b58d 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/handler/ConfigHandler.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/handler/ConfigHandler.java @@ -16,6 +16,8 @@ public class ConfigHandler { public static int soulDropChance; public static int passiveSoulDropChance; public static int cometRarity; + public static int hudX; + public static int hudY; public static String[] obliterationList; public static boolean generateEnderComets; public static boolean generateChaosIslands; @@ -72,6 +74,9 @@ public class ConfigHandler { pigmenBloodRage = config.get(Configuration.CATEGORY_GENERAL, "Pigmen Blood Rage", true, "Is Pigmen blood rage active").getBoolean(true); disableLore = config.get(Configuration.CATEGORY_GENERAL, "Disable Item Lore", false, "Set to true to disable all item lore").getBoolean(false); invertDPDSB = config.get(Configuration.CATEGORY_GENERAL, "InvertDPDSB", false, "Invert Dislocator Pedestal display name shift behavior").getBoolean(false); + hudX = config.get(Configuration.CATEGORY_GENERAL, "Hud Display X pos", 7).getInt(7); + hudY = config.get(Configuration.CATEGORY_GENERAL, "Hud Display Y pos", 874).getInt(874); + //Spawner spawnerListType = config.get("spawner", "listType", false, "Sets weather the spawner list is a white list or a black list (true = white list false = black list)").getBoolean(false); diff --git a/src/main/java/com/brandon3055/draconicevolution/common/inventory/InventoryTool.java b/src/main/java/com/brandon3055/draconicevolution/common/inventory/InventoryTool.java index 178f5a76..0ad58d63 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/inventory/InventoryTool.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/inventory/InventoryTool.java @@ -1,7 +1,7 @@ package com.brandon3055.draconicevolution.common.inventory; import com.brandon3055.draconicevolution.common.container.ContainerAdvTool; -import com.brandon3055.draconicevolution.common.items.tools.baseclasses.MiningTool; +import com.brandon3055.draconicevolution.common.utills.IInventoryTool; import com.brandon3055.draconicevolution.common.utills.ItemNBTHelper; import com.brandon3055.draconicevolution.common.utills.LogHelper; import net.minecraft.entity.player.EntityPlayer; @@ -18,7 +18,7 @@ import net.minecraft.util.StringUtils; public class InventoryTool implements IInventory { public int size; - ItemStack inventoryItem; + public ItemStack inventoryItem; private ItemStack[] inventoryStacks; private EntityPlayer player; private ContainerAdvTool container; @@ -27,8 +27,8 @@ public class InventoryTool implements IInventory { public InventoryTool(EntityPlayer player, ItemStack stack){ this.inventoryItem = stack; this.player = player; - if (stack != null && stack.getItem() instanceof MiningTool){ - this.size = ((MiningTool) stack.getItem()).getInventorySlots(); + if (stack != null && stack.getItem() instanceof IInventoryTool){ + this.size = ((IInventoryTool) stack.getItem()).getInventorySlots(); readFromNBT(ItemNBTHelper.getCompound(inventoryItem)); } this.inventoryStacks = new ItemStack[size + 5]; @@ -37,7 +37,7 @@ public class InventoryTool implements IInventory { public void setAndReadFromStack(ItemStack stack, int slot){ this.slot = slot; this.inventoryItem = stack; - this.size = ((MiningTool) stack.getItem()).getInventorySlots(); + this.size = ((IInventoryTool) stack.getItem()).getInventorySlots(); this.inventoryStacks = new ItemStack[size + 5]; readFromNBT(ItemNBTHelper.getCompound(inventoryItem)); } @@ -100,7 +100,7 @@ public class InventoryTool implements IInventory { @Override public String getInventoryName() { - return inventoryItem != null && inventoryItem.getItem() instanceof MiningTool ? !StringUtils.isNullOrEmpty(((MiningTool) inventoryItem.getItem()).getInventoryName()) ? ((MiningTool) inventoryItem.getItem()).getInventoryName() : "" : ""; + return inventoryItem != null && inventoryItem.getItem() instanceof IInventoryTool ? !StringUtils.isNullOrEmpty(((IInventoryTool) inventoryItem.getItem()).getInventoryName()) ? ((IInventoryTool) inventoryItem.getItem()).getInventoryName() : "" : ""; } @Override @@ -112,7 +112,7 @@ public class InventoryTool implements IInventory { @Override public int getInventoryStackLimit() { - return 64; + return 1; } @Override @@ -152,7 +152,7 @@ public class InventoryTool implements IInventory { @Override public boolean isItemValidForSlot(int i, ItemStack itemstack) { - return itemstack.isItemEqual(new ItemStack(Items.emerald)); + return true; } public void writeToNBT(NBTTagCompound compound) @@ -205,6 +205,7 @@ public class InventoryTool implements IInventory { for (int i = 0; i < getSizeInventory(); i++) { + inventoryStacks[i] = null; if (i < size) { tag[i] = compound.getCompoundTag("Item" + i); diff --git a/src/main/java/com/brandon3055/draconicevolution/common/items/armor/DraconicArmor.java b/src/main/java/com/brandon3055/draconicevolution/common/items/armor/DraconicArmor.java index be9e053c..bec4d820 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/items/armor/DraconicArmor.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/items/armor/DraconicArmor.java @@ -5,16 +5,15 @@ import com.brandon3055.draconicevolution.DraconicEvolution; import com.brandon3055.draconicevolution.common.ModItems; import com.brandon3055.draconicevolution.common.entity.EntityPersistentItem; import com.brandon3055.draconicevolution.common.lib.References; -import com.brandon3055.draconicevolution.common.utills.IConfigurableItem; -import com.brandon3055.draconicevolution.common.utills.InfoHelper; -import com.brandon3055.draconicevolution.common.utills.ItemConfigField; -import com.brandon3055.draconicevolution.common.utills.ItemNBTHelper; +import com.brandon3055.draconicevolution.common.utills.*; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.ReflectionHelper; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.enchantment.Enchantment; +import net.minecraft.enchantment.EnumEnchantmentType; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; @@ -26,6 +25,7 @@ import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; import net.minecraft.util.DamageSource; import net.minecraft.util.IIcon; +import net.minecraft.util.StatCollector; import net.minecraft.world.World; import net.minecraftforge.common.ISpecialArmor; @@ -36,7 +36,7 @@ import java.util.List; /** * Created by Brandon on 3/07/2014. */ -public class DraconicArmor extends ItemArmor implements ISpecialArmor, IEnergyContainerItem, IConfigurableItem {//TODO Wings +public class DraconicArmor extends ItemArmor implements ISpecialArmor, IEnergyContainerItem, IConfigurableItem, IInventoryTool {//TODO Wings private IIcon helmIcon; private IIcon chestIcon; private IIcon leggsIcon; @@ -282,4 +282,19 @@ public class DraconicArmor extends ItemArmor implements ISpecialArmor, IEnergyCo } return list; } + + @Override + public String getInventoryName() { + return StatCollector.translateToLocal("info.de.toolInventoryEnch.txt"); + } + + @Override + public int getInventorySlots() { + return 0; + } + + @Override + public boolean isEnchantValid(Enchantment enchant) { + return enchant.type == EnumEnchantmentType.armor || (armorType == 0 && enchant.type == EnumEnchantmentType.armor_head) || (armorType == 1 && enchant.type == EnumEnchantmentType.armor_torso) || (armorType == 2 && enchant.type == EnumEnchantmentType.armor_legs) || (armorType == 3 && enchant.type == EnumEnchantmentType.armor_feet); + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/items/armor/WyvernArmor.java b/src/main/java/com/brandon3055/draconicevolution/common/items/armor/WyvernArmor.java index 6ef07fe1..c97a9141 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/items/armor/WyvernArmor.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/items/armor/WyvernArmor.java @@ -5,15 +5,14 @@ import com.brandon3055.draconicevolution.DraconicEvolution; import com.brandon3055.draconicevolution.common.ModItems; import com.brandon3055.draconicevolution.common.entity.EntityPersistentItem; import com.brandon3055.draconicevolution.common.lib.References; -import com.brandon3055.draconicevolution.common.utills.IConfigurableItem; -import com.brandon3055.draconicevolution.common.utills.InfoHelper; -import com.brandon3055.draconicevolution.common.utills.ItemConfigField; -import com.brandon3055.draconicevolution.common.utills.ItemNBTHelper; +import com.brandon3055.draconicevolution.common.utills.*; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.enchantment.Enchantment; +import net.minecraft.enchantment.EnumEnchantmentType; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; @@ -23,6 +22,7 @@ import net.minecraft.item.ItemArmor; import net.minecraft.item.ItemStack; import net.minecraft.util.DamageSource; import net.minecraft.util.IIcon; +import net.minecraft.util.StatCollector; import net.minecraft.world.World; import net.minecraftforge.common.ISpecialArmor; @@ -32,7 +32,7 @@ import java.util.List; /** * Created by Brandon on 3/07/2014. */ -public class WyvernArmor extends ItemArmor implements ISpecialArmor, IEnergyContainerItem, IConfigurableItem{ +public class WyvernArmor extends ItemArmor implements ISpecialArmor, IEnergyContainerItem, IConfigurableItem, IInventoryTool { private IIcon helmIcon; private IIcon chestIcon; private IIcon leggsIcon; @@ -244,4 +244,19 @@ public class WyvernArmor extends ItemArmor implements ISpecialArmor, IEnergyCont } return list; } + + @Override + public String getInventoryName() { + return StatCollector.translateToLocal("info.de.toolInventoryEnch.txt"); + } + + @Override + public int getInventorySlots() { + return 0; + } + + @Override + public boolean isEnchantValid(Enchantment enchant) { + return enchant.type == EnumEnchantmentType.armor || (armorType == 0 && enchant.type == EnumEnchantmentType.armor_head) || (armorType == 1 && enchant.type == EnumEnchantmentType.armor_torso) || (armorType == 2 && enchant.type == EnumEnchantmentType.armor_legs) || (armorType == 3 && enchant.type == EnumEnchantmentType.armor_feet); + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/items/tools/DraconicAxe.java b/src/main/java/com/brandon3055/draconicevolution/common/items/tools/DraconicAxe.java index f7634fa9..0226d09c 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/items/tools/DraconicAxe.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/items/tools/DraconicAxe.java @@ -4,13 +4,16 @@ import com.brandon3055.draconicevolution.common.ModItems; import com.brandon3055.draconicevolution.common.items.tools.baseclasses.MiningTool; import com.brandon3055.draconicevolution.common.lib.References; import com.brandon3055.draconicevolution.common.lib.Strings; +import com.brandon3055.draconicevolution.common.utills.IInventoryTool; import com.brandon3055.draconicevolution.common.utills.ItemConfigField; import net.minecraft.enchantment.Enchantment; +import net.minecraft.enchantment.EnumEnchantmentType; import net.minecraft.item.ItemStack; +import net.minecraft.util.StatCollector; import java.util.List; -public class DraconicAxe extends MiningTool { +public class DraconicAxe extends MiningTool implements IInventoryTool {//todo axe & fields public DraconicAxe() { super(ModItems.DRACONIUM_T1); @@ -33,7 +36,7 @@ public class DraconicAxe extends MiningTool { @Override public String getInventoryName() { - return ""; + return StatCollector.translateToLocal("info.de.toolInventoryEnch.txt"); } @Override @@ -43,7 +46,7 @@ public class DraconicAxe extends MiningTool { @Override public boolean isEnchantValid(Enchantment enchant) { - return false; + return enchant.type == EnumEnchantmentType.digger; } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/items/tools/DraconicDistructionStaff.java b/src/main/java/com/brandon3055/draconicevolution/common/items/tools/DraconicDistructionStaff.java index cb1caf46..a796cb13 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/items/tools/DraconicDistructionStaff.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/items/tools/DraconicDistructionStaff.java @@ -4,15 +4,17 @@ import com.brandon3055.draconicevolution.common.ModItems; import com.brandon3055.draconicevolution.common.items.tools.baseclasses.MiningTool; import com.brandon3055.draconicevolution.common.lib.References; import com.brandon3055.draconicevolution.common.lib.Strings; +import com.brandon3055.draconicevolution.common.utills.IInventoryTool; import com.brandon3055.draconicevolution.common.utills.ItemConfigField; import net.minecraft.block.Block; import net.minecraft.enchantment.Enchantment; +import net.minecraft.enchantment.EnumEnchantmentType; import net.minecraft.item.ItemStack; import net.minecraft.util.StatCollector; import java.util.List; -public class DraconicDistructionStaff extends MiningTool { +public class DraconicDistructionStaff extends MiningTool implements IInventoryTool { public DraconicDistructionStaff() { @@ -46,7 +48,7 @@ public class DraconicDistructionStaff extends MiningTool { @Override public String getInventoryName() { - return StatCollector.translateToLocal("info.de.toolInventory.txt"); + return StatCollector.translateToLocal("info.de.toolInventoryOblit.txt"); } @Override @@ -56,7 +58,7 @@ public class DraconicDistructionStaff extends MiningTool { @Override public boolean isEnchantValid(Enchantment enchant) { - return true; + return enchant.type == EnumEnchantmentType.digger || enchant.type == EnumEnchantmentType.weapon; } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/items/tools/DraconicPickaxe.java b/src/main/java/com/brandon3055/draconicevolution/common/items/tools/DraconicPickaxe.java index 6281a71d..734f3f20 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/items/tools/DraconicPickaxe.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/items/tools/DraconicPickaxe.java @@ -4,14 +4,16 @@ import com.brandon3055.draconicevolution.common.ModItems; import com.brandon3055.draconicevolution.common.items.tools.baseclasses.MiningTool; import com.brandon3055.draconicevolution.common.lib.References; import com.brandon3055.draconicevolution.common.lib.Strings; +import com.brandon3055.draconicevolution.common.utills.IInventoryTool; import com.brandon3055.draconicevolution.common.utills.ItemConfigField; import net.minecraft.enchantment.Enchantment; +import net.minecraft.enchantment.EnumEnchantmentType; import net.minecraft.item.ItemStack; import net.minecraft.util.StatCollector; import java.util.List; -public class DraconicPickaxe extends MiningTool { +public class DraconicPickaxe extends MiningTool implements IInventoryTool { public DraconicPickaxe() { @@ -36,7 +38,7 @@ public class DraconicPickaxe extends MiningTool { @Override public String getInventoryName() { - return StatCollector.translateToLocal("info.de.toolInventory.txt"); + return StatCollector.translateToLocal("info.de.toolInventoryOblit.txt"); } @Override @@ -46,7 +48,7 @@ public class DraconicPickaxe extends MiningTool { @Override public boolean isEnchantValid(Enchantment enchant) { - return false; + return enchant.type == EnumEnchantmentType.digger; } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/items/tools/DraconicShovel.java b/src/main/java/com/brandon3055/draconicevolution/common/items/tools/DraconicShovel.java index 3b83196b..02d56c98 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/items/tools/DraconicShovel.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/items/tools/DraconicShovel.java @@ -4,14 +4,16 @@ import com.brandon3055.draconicevolution.common.ModItems; import com.brandon3055.draconicevolution.common.items.tools.baseclasses.MiningTool; import com.brandon3055.draconicevolution.common.lib.References; import com.brandon3055.draconicevolution.common.lib.Strings; +import com.brandon3055.draconicevolution.common.utills.IInventoryTool; import com.brandon3055.draconicevolution.common.utills.ItemConfigField; import net.minecraft.enchantment.Enchantment; +import net.minecraft.enchantment.EnumEnchantmentType; import net.minecraft.item.ItemStack; import net.minecraft.util.StatCollector; import java.util.List; -public class DraconicShovel extends MiningTool { +public class DraconicShovel extends MiningTool implements IInventoryTool { // public IIcon itemIcon0; // public IIcon itemIcon1; // public IIcon itemIcon2; @@ -40,7 +42,7 @@ public class DraconicShovel extends MiningTool { @Override public String getInventoryName() { - return StatCollector.translateToLocal("info.de.toolInventory.txt"); + return StatCollector.translateToLocal("info.de.toolInventoryOblit.txt"); } @Override @@ -50,7 +52,7 @@ public class DraconicShovel extends MiningTool { @Override public boolean isEnchantValid(Enchantment enchant) { - return false; + return enchant.type == EnumEnchantmentType.digger; } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/items/tools/TeleporterMKII.java b/src/main/java/com/brandon3055/draconicevolution/common/items/tools/TeleporterMKII.java index 659d31c8..f2e5155f 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/items/tools/TeleporterMKII.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/items/tools/TeleporterMKII.java @@ -1,12 +1,12 @@ package com.brandon3055.draconicevolution.common.items.tools; import com.brandon3055.draconicevolution.DraconicEvolution; -import com.brandon3055.draconicevolution.client.handler.ToolHudHandler; import com.brandon3055.draconicevolution.client.interfaces.GuiHandler; import com.brandon3055.draconicevolution.common.ModItems; import com.brandon3055.draconicevolution.common.entity.EntityPersistentItem; import com.brandon3055.draconicevolution.common.lib.References; import com.brandon3055.draconicevolution.common.lib.Strings; +import com.brandon3055.draconicevolution.common.utills.IHudDisplayItem; import com.brandon3055.draconicevolution.common.utills.InfoHelper; import com.brandon3055.draconicevolution.common.utills.ItemNBTHelper; import com.brandon3055.draconicevolution.common.utills.Teleporter.TeleportLocation; @@ -26,9 +26,10 @@ import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; import net.minecraft.world.World; +import java.util.ArrayList; import java.util.List; -public class TeleporterMKII extends TeleporterMKI +public class TeleporterMKII extends TeleporterMKI implements IHudDisplayItem { public TeleporterMKII() { @@ -158,9 +159,9 @@ public class TeleporterMKII extends TeleporterMKI @Override public void onUpdate(ItemStack stack, World world, Entity entity, int p_77663_4_, boolean p_77663_5_) { - if (world.isRemote && entity instanceof EntityPlayer && ((EntityPlayer) entity).getHeldItem() != null && ((EntityPlayer) entity).getHeldItem().getItem() instanceof TeleporterMKII){ - if (getLocation(((EntityPlayer) entity).getHeldItem()) != null) ToolHudHandler.setTooltip(getLocation(((EntityPlayer) entity).getHeldItem()).getName()); - } +// if (world.isRemote && entity instanceof EntityPlayer && ((EntityPlayer) entity).getHeldItem() != null && ((EntityPlayer) entity).getHeldItem().getItem() instanceof TeleporterMKII){ +// if (getLocation(((EntityPlayer) entity).getHeldItem()) != null) HudHandler.setTooltip(getLocation(((EntityPlayer) entity).getHeldItem()).getName()); +// } } @Override @@ -178,4 +179,17 @@ public class TeleporterMKII extends TeleporterMKI return destination; } + + @Override + public List getDisplayData(ItemStack stack) { + List list = new ArrayList(); + TeleportLocation location = getLocation(stack); + if (location != null) + { + list.add(location.getName()); + } + list.add(StatCollector.translateToLocal("info.teleporterInfFuel.txt") + " " + ItemNBTHelper.getInteger(stack, "Fuel", 0)); + + return list; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/items/tools/WyvernPickaxe.java b/src/main/java/com/brandon3055/draconicevolution/common/items/tools/WyvernPickaxe.java index 421b39a1..d0c45cd3 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/items/tools/WyvernPickaxe.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/items/tools/WyvernPickaxe.java @@ -4,13 +4,16 @@ import com.brandon3055.draconicevolution.common.ModItems; import com.brandon3055.draconicevolution.common.items.tools.baseclasses.MiningTool; import com.brandon3055.draconicevolution.common.lib.References; import com.brandon3055.draconicevolution.common.lib.Strings; +import com.brandon3055.draconicevolution.common.utills.IInventoryTool; import com.brandon3055.draconicevolution.common.utills.ItemConfigField; import net.minecraft.enchantment.Enchantment; +import net.minecraft.enchantment.EnumEnchantmentType; import net.minecraft.item.ItemStack; +import net.minecraft.util.StatCollector; import java.util.List; -public class WyvernPickaxe extends MiningTool { +public class WyvernPickaxe extends MiningTool implements IInventoryTool { public WyvernPickaxe() { super(ModItems.DRACONIUM_T1); @@ -32,7 +35,7 @@ public class WyvernPickaxe extends MiningTool { @Override public String getInventoryName() { - return ""; + return StatCollector.translateToLocal("info.de.toolInventoryEnch.txt"); } @Override @@ -42,7 +45,7 @@ public class WyvernPickaxe extends MiningTool { @Override public boolean isEnchantValid(Enchantment enchant) { - return false; + return enchant.type == EnumEnchantmentType.digger; } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/items/tools/WyvernShovel.java b/src/main/java/com/brandon3055/draconicevolution/common/items/tools/WyvernShovel.java index f2d5aceb..4ca3aa51 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/items/tools/WyvernShovel.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/items/tools/WyvernShovel.java @@ -4,13 +4,16 @@ import com.brandon3055.draconicevolution.common.ModItems; import com.brandon3055.draconicevolution.common.items.tools.baseclasses.MiningTool; import com.brandon3055.draconicevolution.common.lib.References; import com.brandon3055.draconicevolution.common.lib.Strings; +import com.brandon3055.draconicevolution.common.utills.IInventoryTool; import com.brandon3055.draconicevolution.common.utills.ItemConfigField; import net.minecraft.enchantment.Enchantment; +import net.minecraft.enchantment.EnumEnchantmentType; import net.minecraft.item.ItemStack; +import net.minecraft.util.StatCollector; import java.util.List; -public class WyvernShovel extends MiningTool { +public class WyvernShovel extends MiningTool implements IInventoryTool { public WyvernShovel() { @@ -33,7 +36,7 @@ public class WyvernShovel extends MiningTool { @Override public String getInventoryName() { - return ""; + return StatCollector.translateToLocal("info.de.toolInventoryEnch.txt"); } @Override @@ -43,7 +46,7 @@ public class WyvernShovel extends MiningTool { @Override public boolean isEnchantValid(Enchantment enchant) { - return false; + return enchant.type == EnumEnchantmentType.digger; } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/items/tools/baseclasses/MiningTool.java b/src/main/java/com/brandon3055/draconicevolution/common/items/tools/baseclasses/MiningTool.java index 14a49e79..af87333b 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/items/tools/baseclasses/MiningTool.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/items/tools/baseclasses/MiningTool.java @@ -1,16 +1,17 @@ package com.brandon3055.draconicevolution.common.items.tools.baseclasses; -import com.brandon3055.draconicevolution.DraconicEvolution; import com.brandon3055.draconicevolution.common.lib.References; +import com.brandon3055.draconicevolution.common.utills.ItemConfigField; import com.brandon3055.draconicevolution.common.utills.ItemNBTHelper; import com.brandon3055.draconicevolution.common.utills.LogHelper; import net.minecraft.block.Block; import net.minecraft.client.Minecraft; -import net.minecraft.enchantment.Enchantment; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.play.client.C07PacketPlayerDigging; import net.minecraft.network.play.server.S18PacketEntityTeleport; import net.minecraft.network.play.server.S23PacketBlockChange; @@ -19,14 +20,14 @@ import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.World; import net.minecraftforge.common.ForgeHooks; -import java.util.HashSet; +import java.util.HashMap; import java.util.List; -import java.util.Set; +import java.util.Map; /** * Created by Brandon on 2/01/2015. */ -public abstract class MiningTool extends ToolBase {//todo add custom information to sub classes, +public abstract class MiningTool extends ToolBase {//todo add custom information to sub classes, Update documentation and add doc for hud public MiningTool(ToolMaterial material) { @@ -34,8 +35,25 @@ public abstract class MiningTool extends ToolBase {//todo add custom information } - public Set getObliterationList(ItemStack stack){ - return new HashSet(); + public Map getObliterationList(ItemStack stack){ + Map blockMap = new HashMap(); + + NBTTagCompound compound = ItemNBTHelper.getCompound(stack); + + if (compound.hasNoTags()) return blockMap; + for (int i = 0; i < 9; i++) + { + NBTTagCompound tag = new NBTTagCompound(); + if (compound.hasKey("Item" + i)) tag = compound.getCompoundTag("Item" + i); + + if (tag.hasNoTags()) continue; + + ItemStack stack1 = ItemStack.loadItemStackFromNBT(tag); + + if (stack1 != null && stack1.getItem() instanceof ItemBlock) blockMap.put(Block.getBlockFromItem(stack1.getItem()), stack1.getItemDamage()); + } + + return blockMap; } @Override @@ -43,22 +61,37 @@ public abstract class MiningTool extends ToolBase {//todo add custom information int radius = ItemNBTHelper.getInteger(stack, References.DIG_AOE, 0); int depth = ItemNBTHelper.getInteger(stack, References.DIG_DEPTH, 1) - 1; - return getEnergyStored(stack) >= energyPerOperation && (radius > 0 || depth > 0) ? breakAOEBlocks(stack, x, y, z, radius, depth, player) : super.onBlockStartBreak(stack, x, y, z, player); } @Override public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { ToolHandler.updateGhostBlocks(player, world); - LogHelper.info(DraconicEvolution.proxy.isDedicatedServer()); - return super.onItemRightClick(stack, world, player); + LogHelper.info(getDisplayData(stack)); + if (player.isSneaking()) + { + List fields = getFields(stack, player.inventory.currentItem); + for (ItemConfigField field : fields) + { + if (!world.isRemote && field.name.equals(References.DIG_AOE)) + { + int aoe = (Integer) field.value; + aoe++; + if (aoe > (Integer)field.max) aoe = (Integer) field.min; + field.value = aoe; + field.sendChanges(); + } + } + } + + return super.onItemRightClick(stack, world, player); } - //todo power, oblit, optimization, collection, Hud, Hud Config, shift right click, attack + //todo Hud, Hud Config, shift right click, attack, axe, hoe //This method is basses on tinkerers construct - public boolean breakAOEBlocks(ItemStack stack, int x, int y, int z, int breakRadius, int breakDepth, EntityPlayer player) { - - // only effective materials matter. We don't want to aoe when beraking dirt with a hammer. + public boolean breakAOEBlocks(ItemStack stack, int x, int y, int z, int breakRadius, int breakDepth, EntityPlayer player) + { + Map blockMap = getObliterationList(stack); Block block = player.worldObj.getBlock(x,y,z); int meta = player.worldObj.getBlockMetadata(x,y,z); boolean effective = false; @@ -82,7 +115,6 @@ public abstract class MiningTool extends ToolBase {//todo add custom information } int sideHit = mop.sideHit; - // we successfully destroyed a block. time to do AOE! int xRange = breakRadius; int yRange = breakRadius; int zRange = breakDepth; @@ -113,7 +145,7 @@ public abstract class MiningTool extends ToolBase {//todo add custom information { for (int zPos = z - zRange; zPos <= z + zRange; zPos++) { - breakExtraBlock(stack, player.worldObj, xPos, yPos, zPos, sideHit, player, refStrength, Math.abs(x - xPos) <= 1 && Math.abs(y - yPos) <= 1 && Math.abs(z - zPos) <= 1); + breakExtraBlock(stack, player.worldObj, xPos, yPos, zPos, sideHit, player, refStrength, Math.abs(x - xPos) <= 1 && Math.abs(y - yPos) <= 1 && Math.abs(z - zPos) <= 1, blockMap); } } } @@ -133,8 +165,8 @@ public abstract class MiningTool extends ToolBase {//todo add custom information } //This method is basses on tinkerers construct - protected void breakExtraBlock(ItemStack stack, World world, int x, int y, int z, int sidehit, EntityPlayer player, float refStrength, boolean breakSound) { - // prevent calling that stuff for air blocks, could lead to unexpected behaviour since it fires events + protected void breakExtraBlock(ItemStack stack, World world, int x, int y, int z, int sidehit, EntityPlayer player, float refStrength, boolean breakSound, Map blockMap) + { if (world.isAirBlock(x, y, z)) return; @@ -153,16 +185,14 @@ public abstract class MiningTool extends ToolBase {//todo add custom information float strength = ForgeHooks.blockStrength(block, player, world, x,y,z); - // only harvestable blocks that aren't impossibly slow to harvest if (!player.canHarvestBlock(block) || !ForgeHooks.canHarvestBlock(block, player, meta) || refStrength/strength > 10f) return; - if (player.capabilities.isCreativeMode || getObliterationList(stack).contains(block)) { + if (player.capabilities.isCreativeMode || (blockMap.containsKey(block) && blockMap.get(block) == meta)) { block.onBlockHarvested(world, x, y, z, meta, player); if (block.removedByPlayer(world, player, x, y, z, false)) block.onBlockDestroyedByPlayer(world, x, y, z, meta); - // send update to client if (!world.isRemote) { ((EntityPlayerMP)player).playerNetServerHandler.sendPacket(new S23PacketBlockChange(x, y, z, world)); } @@ -171,7 +201,6 @@ public abstract class MiningTool extends ToolBase {//todo add custom information extractEnergy(stack, energyPerOperation, false); - // server sided handling if (!world.isRemote) { block.onBlockHarvested(world, x, y, z, meta, player); @@ -183,13 +212,11 @@ public abstract class MiningTool extends ToolBase {//todo add custom information player.addExhaustion(-0.025F); } - // always send block update to client EntityPlayerMP mpPlayer = (EntityPlayerMP) player; mpPlayer.playerNetServerHandler.sendPacket(new S23PacketBlockChange(x, y, z, world)); } - // client sided handlinge - else { - + else + { if (breakSound) world.playAuxSFX(2001, x, y, z, Block.getIdFromBlock(block) + (meta << 12)); if(block.removedByPlayer(world, player, x,y,z, true)) { @@ -199,12 +226,6 @@ public abstract class MiningTool extends ToolBase {//todo add custom information Minecraft.getMinecraft().getNetHandler().addToSendQueue(new C07PacketPlayerDigging(2, x,y,z, Minecraft.getMinecraft().objectMouseOver.sideHit)); } } - - public abstract String getInventoryName(); - - public abstract int getInventorySlots(); - - public abstract boolean isEnchantValid(Enchantment enchant); } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/items/tools/baseclasses/RFItemBase.java b/src/main/java/com/brandon3055/draconicevolution/common/items/tools/baseclasses/RFItemBase.java index d666be91..2dd5a81f 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/items/tools/baseclasses/RFItemBase.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/items/tools/baseclasses/RFItemBase.java @@ -4,15 +4,14 @@ import cofh.api.energy.IEnergyContainerItem; import com.brandon3055.draconicevolution.DraconicEvolution; import com.brandon3055.draconicevolution.common.entity.EntityPersistentItem; import com.brandon3055.draconicevolution.common.items.ItemDE; -import com.brandon3055.draconicevolution.common.utills.IConfigurableItem; -import com.brandon3055.draconicevolution.common.utills.ItemConfigField; -import com.brandon3055.draconicevolution.common.utills.ItemNBTHelper; +import com.brandon3055.draconicevolution.common.utills.*; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.Entity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.util.StatCollector; import net.minecraft.world.World; import java.util.ArrayList; @@ -21,7 +20,7 @@ import java.util.List; /** * Created by Brandon on 8/01/2015. */ -public class RFItemBase extends ItemDE implements IEnergyContainerItem, IConfigurableItem { +public class RFItemBase extends ItemDE implements IEnergyContainerItem, IConfigurableItem, IHudDisplayItem { private int capacity = 0; /**Max Receive*/ private int maxReceive = 0; @@ -124,4 +123,14 @@ public class RFItemBase extends ItemDE implements IEnergyContainerItem, IConfigu public List getFields(ItemStack stack, int slot) { return new ArrayList(); } + + @Override + public List getDisplayData(ItemStack stack) { + List list = new ArrayList(); + for (ItemConfigField field : getFields(stack, 0)) list.add(field.getLocalizedName() + ": " + field.getFormatedValue()); + if (capacity > 0) list.add(StatCollector.translateToLocal("info.de.charge.txt") + ": " + Utills.formatNumber(getEnergyStored(stack)) + " / " + Utills.formatNumber(capacity)); + + return list; + } + } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/items/tools/baseclasses/ToolBase.java b/src/main/java/com/brandon3055/draconicevolution/common/items/tools/baseclasses/ToolBase.java index 4194e781..c8b805cc 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/items/tools/baseclasses/ToolBase.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/items/tools/baseclasses/ToolBase.java @@ -129,7 +129,12 @@ public class ToolBase extends RFItemBase { @Override public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean extended) { boolean show = InfoHelper.holdShiftForDetails(list); - if (show) InfoHelper.addEnergyInfo(stack, list); + //if (show) InfoHelper.addEnergyInfo(stack, list); + if (show){ + List l = getFields(stack, 0); + for (ItemConfigField f : l) list.add(f.getTooltipInfo()); + } + addAditionalInformation(stack, player, list, extended); if (show) InfoHelper.addLore(stack, list, true); } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/items/tools/baseclasses/ToolHandler.java b/src/main/java/com/brandon3055/draconicevolution/common/items/tools/baseclasses/ToolHandler.java index ba2102b5..d298657c 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/items/tools/baseclasses/ToolHandler.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/items/tools/baseclasses/ToolHandler.java @@ -17,6 +17,7 @@ import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.network.play.server.S23PacketBlockChange; import net.minecraft.util.*; import net.minecraft.world.World; @@ -294,6 +295,7 @@ public class ToolHandler { } public static void updateGhostBlocks(EntityPlayer player, World world) { + if (world.isRemote) return; int xPos = (int) player.posX; int yPos = (int) player.posY; int zPos = (int) player.posZ; @@ -301,7 +303,8 @@ public class ToolHandler { for (int x = xPos - 6; x < xPos + 6; x++) { for (int y = yPos - 6; y < yPos + 6; y++) { for (int z = zPos - 6; z < zPos + 6; z++) { - world.markBlockForUpdate(x, y, z); + ((EntityPlayerMP)player).playerNetServerHandler.sendPacket(new S23PacketBlockChange(x, y, z, world)); + //world.markBlockForUpdate(x, y, z); } } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/items/weapons/DraconicBow.java b/src/main/java/com/brandon3055/draconicevolution/common/items/weapons/DraconicBow.java index 0f2390d4..f6442c7e 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/items/weapons/DraconicBow.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/items/weapons/DraconicBow.java @@ -5,12 +5,16 @@ import com.brandon3055.draconicevolution.common.ModItems; import com.brandon3055.draconicevolution.common.entity.EntityPersistentItem; import com.brandon3055.draconicevolution.common.lib.References; import com.brandon3055.draconicevolution.common.lib.Strings; +import com.brandon3055.draconicevolution.common.utills.IInventoryTool; import com.brandon3055.draconicevolution.common.utills.InfoHelper; +import com.brandon3055.draconicevolution.common.utills.ItemConfigField; import com.brandon3055.draconicevolution.common.utills.ItemNBTHelper; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.enchantment.Enchantment; +import net.minecraft.enchantment.EnumEnchantmentType; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Items; @@ -23,9 +27,10 @@ import net.minecraft.world.World; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.player.ArrowNockEvent; +import java.util.ArrayList; import java.util.List; -public class DraconicBow extends ItemBow +public class DraconicBow extends ItemBow implements IInventoryTool { public static final String[] bowPullIconNameArray = new String[] { "pulling_0", "pulling_1", "pulling_2" }; @SideOnly(Side.CLIENT) @@ -216,4 +221,24 @@ public class DraconicBow extends ItemBow public Entity createEntity(World world, Entity location, ItemStack itemstack) { return new EntityPersistentItem(world, location, itemstack); } + + @Override + public String getInventoryName() { + return StatCollector.translateToLocal("info.de.toolInventoryEnch.txt"); + } + + @Override + public int getInventorySlots() { + return 0; + } + + @Override + public boolean isEnchantValid(Enchantment enchant) { + return enchant.type == EnumEnchantmentType.bow || enchant.effectId == DraconicEvolution.reaperEnchant.effectId; + } + + @Override + public List getFields(ItemStack stack, int slot) { + return new ArrayList(); + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/items/weapons/DraconicSword.java b/src/main/java/com/brandon3055/draconicevolution/common/items/weapons/DraconicSword.java index 1756d1a1..41f19cde 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/items/weapons/DraconicSword.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/items/weapons/DraconicSword.java @@ -7,13 +7,17 @@ import com.brandon3055.draconicevolution.common.entity.EntityPersistentItem; import com.brandon3055.draconicevolution.common.items.tools.baseclasses.ToolHandler; import com.brandon3055.draconicevolution.common.lib.References; import com.brandon3055.draconicevolution.common.lib.Strings; +import com.brandon3055.draconicevolution.common.utills.IInventoryTool; import com.brandon3055.draconicevolution.common.utills.InfoHelper; +import com.brandon3055.draconicevolution.common.utills.ItemConfigField; import com.brandon3055.draconicevolution.common.utills.ItemNBTHelper; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.enchantment.Enchantment; +import net.minecraft.enchantment.EnumEnchantmentType; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.EnumRarity; @@ -24,9 +28,10 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.StatCollector; import net.minecraft.world.World; +import java.util.ArrayList; import java.util.List; -public class DraconicSword extends ItemSword implements IEnergyContainerItem{ +public class DraconicSword extends ItemSword implements IEnergyContainerItem, IInventoryTool { protected int capacity = References.DRACONICCAPACITY; protected int maxReceive = References.DRACONICTRANSFER; protected int maxExtract = References.DRACONICTRANSFER * 50; @@ -157,4 +162,24 @@ public class DraconicSword extends ItemSword implements IEnergyContainerItem{ public Entity createEntity(World world, Entity location, ItemStack itemstack) { return new EntityPersistentItem(world, location, itemstack); } + + @Override + public String getInventoryName() { + return StatCollector.translateToLocal("info.de.toolInventoryEnch.txt"); + } + + @Override + public int getInventorySlots() { + return 0; + } + + @Override + public boolean isEnchantValid(Enchantment enchant) { + return enchant.type == EnumEnchantmentType.weapon; + } + + @Override + public List getFields(ItemStack stack, int slot) { + return new ArrayList(); + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/items/weapons/WyvernBow.java b/src/main/java/com/brandon3055/draconicevolution/common/items/weapons/WyvernBow.java index 6980eb1b..94ae37b4 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/items/weapons/WyvernBow.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/items/weapons/WyvernBow.java @@ -5,12 +5,16 @@ import com.brandon3055.draconicevolution.common.ModItems; import com.brandon3055.draconicevolution.common.entity.EntityPersistentItem; import com.brandon3055.draconicevolution.common.lib.References; import com.brandon3055.draconicevolution.common.lib.Strings; +import com.brandon3055.draconicevolution.common.utills.IInventoryTool; import com.brandon3055.draconicevolution.common.utills.InfoHelper; +import com.brandon3055.draconicevolution.common.utills.ItemConfigField; import com.brandon3055.draconicevolution.common.utills.ItemNBTHelper; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.enchantment.Enchantment; +import net.minecraft.enchantment.EnumEnchantmentType; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Items; @@ -23,9 +27,11 @@ import net.minecraft.world.World; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.player.ArrowNockEvent; +import java.util.ArrayList; import java.util.List; -public class WyvernBow extends ItemBow { +public class WyvernBow extends ItemBow implements IInventoryTool { + public static final String[] bowPullIconNameArray = new String[] { "pulling_0", "pulling_1", "pulling_2" }; @SideOnly(Side.CLIENT) private IIcon[] iconArray; @@ -183,5 +189,25 @@ public class WyvernBow extends ItemBow { public Entity createEntity(World world, Entity location, ItemStack itemstack) { return new EntityPersistentItem(world, location, itemstack); } + + @Override + public String getInventoryName() { + return StatCollector.translateToLocal("info.de.toolInventoryEnch.txt"); + } + + @Override + public int getInventorySlots() { + return 0; + } + + @Override + public boolean isEnchantValid(Enchantment enchant) { + return enchant.type == EnumEnchantmentType.bow || enchant.effectId == DraconicEvolution.reaperEnchant.effectId; + } + + @Override + public List getFields(ItemStack stack, int slot) { + return new ArrayList(); + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/items/weapons/WyvernSword.java b/src/main/java/com/brandon3055/draconicevolution/common/items/weapons/WyvernSword.java index 88dd9f14..032b46d7 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/items/weapons/WyvernSword.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/items/weapons/WyvernSword.java @@ -7,13 +7,17 @@ import com.brandon3055.draconicevolution.common.entity.EntityPersistentItem; import com.brandon3055.draconicevolution.common.items.tools.baseclasses.ToolHandler; import com.brandon3055.draconicevolution.common.lib.References; import com.brandon3055.draconicevolution.common.lib.Strings; +import com.brandon3055.draconicevolution.common.utills.IInventoryTool; import com.brandon3055.draconicevolution.common.utills.InfoHelper; +import com.brandon3055.draconicevolution.common.utills.ItemConfigField; import com.brandon3055.draconicevolution.common.utills.ItemNBTHelper; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.enchantment.Enchantment; +import net.minecraft.enchantment.EnumEnchantmentType; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; @@ -25,9 +29,10 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.StatCollector; import net.minecraft.world.World; +import java.util.ArrayList; import java.util.List; -public class WyvernSword extends ItemSword implements IEnergyContainerItem{ +public class WyvernSword extends ItemSword implements IEnergyContainerItem, IInventoryTool { protected int capacity = References.WYVERNCAPACITY; protected int maxReceive = References.WYVERNTRANSFER; @@ -170,5 +175,25 @@ public class WyvernSword extends ItemSword implements IEnergyContainerItem{ public Entity createEntity(World world, Entity location, ItemStack itemstack) { return new EntityPersistentItem(world, location, itemstack); } + + @Override + public String getInventoryName() { + return StatCollector.translateToLocal("info.de.toolInventoryEnch.txt"); + } + + @Override + public int getInventorySlots() { + return 0; + } + + @Override + public boolean isEnchantValid(Enchantment enchant) { + return enchant.type == EnumEnchantmentType.weapon; + } + + @Override + public List getFields(ItemStack stack, int slot) { + return new ArrayList(); + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/network/TeleporterPacket.java b/src/main/java/com/brandon3055/draconicevolution/common/network/TeleporterPacket.java index b464acde..97eab68e 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/network/TeleporterPacket.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/network/TeleporterPacket.java @@ -26,6 +26,7 @@ public class TeleporterPacket implements IMessage public static final int UPDATEDESTINATION = 7; public static final int TELEPORT = 8; public static final int SCROLL = 9; + public static final int MOVELOCATION = 10; private int data = 0; private boolean dataB; @@ -66,7 +67,7 @@ public class TeleporterPacket implements IMessage if (function == UPDATEDESTINATION) bytes.writeInt(data); } - if (function == UPDATELOCK){ + if (function == UPDATELOCK || function == MOVELOCATION){ bytes.writeInt(data); bytes.writeBoolean(dataB); } @@ -100,7 +101,7 @@ public class TeleporterPacket implements IMessage if (function == UPDATEDESTINATION) data = bytes.readInt(); } - if (function == UPDATELOCK){ + if (function == UPDATELOCK || function == MOVELOCATION){ data = bytes.readInt(); dataB = bytes.readBoolean(); } @@ -199,6 +200,39 @@ public class TeleporterPacket implements IMessage destination.sendEntityToCoords(ctx.getServerHandler().playerEntity); } + if (message.function == MOVELOCATION) + { + int selected = ItemNBTHelper.getShort(teleporter, "Selection", (short) 0); + int selectionOffset = ItemNBTHelper.getInteger(teleporter, "SelectionOffset", 0); + int maxSelect = Math.min(list.tagCount()-1, 11); + int maxOffset = Math.max(list.tagCount() - 12, 0); + + if (message.dataB) //up + { + if (selected > 0) + { + NBTTagCompound temp = list.getCompoundTagAt(selected+selectionOffset); + list.func_150304_a(selected+selectionOffset, list.getCompoundTagAt(selected+selectionOffset - 1)); + list.func_150304_a(selected+selectionOffset - 1, temp); + compound.setTag("Locations", list); + teleporter.setTagCompound(compound); + ItemNBTHelper.setShort(teleporter, "Selection", (short) (ItemNBTHelper.getShort(teleporter, "Selection", (short) 0) - 1)); + } + } + else //down + { + if (selected < maxSelect) + { + NBTTagCompound temp = list.getCompoundTagAt(selected+selectionOffset); + list.func_150304_a(selected+selectionOffset, list.getCompoundTagAt(selected+selectionOffset + 1)); + list.func_150304_a(selected+selectionOffset + 1, temp); + compound.setTag("Locations", list); + teleporter.setTagCompound(compound); + ItemNBTHelper.setShort(teleporter, "Selection", (short) (ItemNBTHelper.getShort(teleporter, "Selection", (short) 0) + 1)); + } + } + } + if (message.function == ADDFUEL){ int fuel = ItemNBTHelper.getInteger(teleporter, "Fuel", 0); int count = 0; diff --git a/src/main/java/com/brandon3055/draconicevolution/common/utills/IHudDisplayBlock.java b/src/main/java/com/brandon3055/draconicevolution/common/utills/IHudDisplayBlock.java new file mode 100644 index 00000000..d89bb51a --- /dev/null +++ b/src/main/java/com/brandon3055/draconicevolution/common/utills/IHudDisplayBlock.java @@ -0,0 +1,12 @@ +package com.brandon3055.draconicevolution.common.utills; + +import net.minecraft.world.World; + +import java.util.List; + +/** + * Created by Brandon on 27/01/2015. + */ +public interface IHudDisplayBlock { + List getDisplayData(World world, int x, int y, int z); +} diff --git a/src/main/java/com/brandon3055/draconicevolution/common/utills/IHudDisplayItem.java b/src/main/java/com/brandon3055/draconicevolution/common/utills/IHudDisplayItem.java new file mode 100644 index 00000000..55d78273 --- /dev/null +++ b/src/main/java/com/brandon3055/draconicevolution/common/utills/IHudDisplayItem.java @@ -0,0 +1,12 @@ +package com.brandon3055.draconicevolution.common.utills; + +import net.minecraft.item.ItemStack; + +import java.util.List; + +/** + * Created by Brandon on 26/01/2015. + */ +public interface IHudDisplayItem {//todo create and implement block version + List getDisplayData(ItemStack stack); +} diff --git a/src/main/java/com/brandon3055/draconicevolution/common/utills/IInventoryTool.java b/src/main/java/com/brandon3055/draconicevolution/common/utills/IInventoryTool.java new file mode 100644 index 00000000..499672a0 --- /dev/null +++ b/src/main/java/com/brandon3055/draconicevolution/common/utills/IInventoryTool.java @@ -0,0 +1,14 @@ +package com.brandon3055.draconicevolution.common.utills; + +import net.minecraft.enchantment.Enchantment; + +/** + * Created by Brandon on 17/01/2015. + */ +public interface IInventoryTool extends IConfigurableItem { + public abstract String getInventoryName(); + + public abstract int getInventorySlots(); + + public abstract boolean isEnchantValid(Enchantment enchant); +} diff --git a/src/main/java/com/brandon3055/draconicevolution/common/utills/ItemConfigField.java b/src/main/java/com/brandon3055/draconicevolution/common/utills/ItemConfigField.java index ff0969eb..360bd1c6 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/utills/ItemConfigField.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/utills/ItemConfigField.java @@ -71,6 +71,11 @@ public class ItemConfigField { } } + public String getTooltipInfo() + { + return InfoHelper.ITC() + getLocalizedName() + ": " + InfoHelper.HITC() + getFormatedValue(); + } + public void sendChanges(){ DraconicEvolution.network.sendToServer(new ItemConfigPacket(this)); } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/utills/ItemNBTHelper.java b/src/main/java/com/brandon3055/draconicevolution/common/utills/ItemNBTHelper.java index f13f748f..c6d4e813 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/utills/ItemNBTHelper.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/utills/ItemNBTHelper.java @@ -10,10 +10,8 @@ public final class ItemNBTHelper { // SETTERS /////////////////////////////////////////////////////////////////// public static NBTTagCompound getCompound(ItemStack stack){ - if (stack.getTagCompound() == null) - return new NBTTagCompound(); - else - return stack.getTagCompound(); + if (stack.getTagCompound() == null) stack.setTagCompound(new NBTTagCompound()); + return stack.getTagCompound(); } public static ItemStack setByte(ItemStack stack, String tag, byte b) diff --git a/src/main/java/com/brandon3055/draconicevolution/common/utills/Teleporter.java b/src/main/java/com/brandon3055/draconicevolution/common/utills/Teleporter.java index 7bac7838..4d7d6436 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/utills/Teleporter.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/utills/Teleporter.java @@ -1,6 +1,7 @@ package com.brandon3055.draconicevolution.common.utills; import com.brandon3055.draconicevolution.DraconicEvolution; +import cpw.mods.fml.common.FMLCommonHandler; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityList; import net.minecraft.entity.player.EntityPlayer; @@ -189,11 +190,12 @@ public class Teleporter boolean interDimensional = startWorld.provider.dimensionId != destinationWorld.provider.dimensionId; - //startWorld.updateEntityWithOptionalForce(entity, false); + startWorld.updateEntityWithOptionalForce(entity, false);//added if ((entity instanceof EntityPlayerMP) && interDimensional) { EntityPlayerMP player = (EntityPlayerMP)entity; + player.closeScreen();//added player.dimension = destination.dimension; player.playerNetServerHandler.sendPacket(new S07PacketRespawn(player.dimension, player.worldObj.difficultySetting, destinationWorld.getWorldInfo().getTerrainType(), player.theItemInWorldManager.getGameType())); ((WorldServer)startWorld).getPlayerManager().removePlayer(player); @@ -265,6 +267,7 @@ public class Teleporter } player.playerNetServerHandler.sendPacket(new S1FPacketSetExperience(player.experience, player.experienceTotal, player.experienceLevel)); + FMLCommonHandler.instance().firePlayerChangedDimensionEvent(player, startWorld.provider.dimensionId, destinationWorld.provider.dimensionId); } entity.setLocationAndAngles(destination.xCoord, destination.yCoord, destination.zCoord, destination.yaw, entity.rotationPitch); diff --git a/src/main/resources/assets/draconicevolution/lang/en_US.lang b/src/main/resources/assets/draconicevolution/lang/en_US.lang index a0eb72de..99b0130f 100644 --- a/src/main/resources/assets/draconicevolution/lang/en_US.lang +++ b/src/main/resources/assets/draconicevolution/lang/en_US.lang @@ -236,11 +236,11 @@ msg.spawnerInfo1.txt=Mob Type msg.spawnerInfo2.txt=Requires Player msg.spawnerInfo3.txt=Ignore Spawn Requirements msg.spawnerInfo4.txt=Spawner Tier -msg.spawnerInfo5.txt=Shift Right click for upgrade info -msg.spawnerInfo6.txt=Requires players : Nether Star -msg.spawnerInfo7.txt=Ignore Spawn Requirements : Notch Apple -msg.spawnerInfo8.txt=Tier 2 : Wyvern Core -msg.spawnerInfo9.txt=Tier 3 : Awakened Core +msg.spawnerInfo5.txt=§3Hold shift for upgrade info +msg.spawnerInfo6.txt=Requires players: §3Nether Star +msg.spawnerInfo7.txt=Ignore Spawn Requirements: §3Notch Apple +msg.spawnerInfo8.txt=Tier 2: §3Wyvern Core +msg.spawnerInfo9.txt=Tier 3:§3 Awakened Core msg.dislocatorUnsafe.txt=Destination Unsafe Please Try Again msg.dislocatorNoGround.txt=Error world not found msg.range.txt=Range: @@ -312,7 +312,14 @@ info.de.capacitorMode2.txt=Charge Armor & Held Item info.de.capacitorMode3.txt=Charge Armor & Hotbar info.de.changwMode.txt=Shift Right click to change mode -info.de.toolInventory.txt=Obliteration filter +info.de.toolInventoryOblit.txt=Junk filter & Enchants +info.de.toolInventoryEnch.txt=Enchants + +info.de.hudDisplayConfigTxt1.txt=#### HUD Display #### +info.de.hudDisplayConfigTxt2.txt=Click and drag to move +info.de.hudDisplayConfigTxt3.txt=################### +info.de.hudDisplayConfigInfo1.txt=Click and drag HUD +info.de.hudDisplayConfigInfo2.txt=to change location enchantment.draconicevolution.reaperEnchant=Reaper