aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/com/github/technus/tectech/TecTech.java4
-rw-r--r--src/main/java/com/github/technus/tectech/loader/ModGuiHandler.java27
-rw-r--r--src/main/java/com/github/technus/tectech/thing/item/ElementalDefinitionScanStorage_EM.java39
-rw-r--r--src/main/java/com/github/technus/tectech/thing/item/gui/ScanDisplayScreen.java110
-rw-r--r--src/main/resources/assets/tectech/textures/gui/scanDisplayItem.pngbin0 -> 262972 bytes
-rw-r--r--src/main/resources/assets/tectech/textures/gui/scanDisplayScreen.pngbin0 -> 262972 bytes
6 files changed, 174 insertions, 6 deletions
diff --git a/src/main/java/com/github/technus/tectech/TecTech.java b/src/main/java/com/github/technus/tectech/TecTech.java
index df45b6585a..59c68e4aab 100644
--- a/src/main/java/com/github/technus/tectech/TecTech.java
+++ b/src/main/java/com/github/technus/tectech/TecTech.java
@@ -3,6 +3,7 @@ package com.github.technus.tectech;
import com.github.technus.tectech.auxiliary.Reference;
import com.github.technus.tectech.auxiliary.TecTechConfig;
import com.github.technus.tectech.loader.MainLoader;
+import com.github.technus.tectech.loader.ModGuiHandler;
import com.github.technus.tectech.proxy.CommonProxy;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.Mod;
@@ -10,6 +11,7 @@ import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.*;
+import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.registry.GameData;
import cpw.mods.fml.common.registry.GameRegistry;
import eu.usrv.yamcore.auxiliary.IngameErrorLog;
@@ -81,6 +83,8 @@ public class TecTech {
GTCustomLoader.load();
+
+ NetworkRegistry.INSTANCE.registerGuiHandler(instance, new ModGuiHandler());
proxy.registerRenderInfo();
}
diff --git a/src/main/java/com/github/technus/tectech/loader/ModGuiHandler.java b/src/main/java/com/github/technus/tectech/loader/ModGuiHandler.java
new file mode 100644
index 0000000000..5a3ca7a877
--- /dev/null
+++ b/src/main/java/com/github/technus/tectech/loader/ModGuiHandler.java
@@ -0,0 +1,27 @@
+package com.github.technus.tectech.loader;
+
+import com.github.technus.tectech.thing.item.gui.ScanDisplayScreen;
+import cpw.mods.fml.common.network.IGuiHandler;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.world.World;
+
+/**
+ * Created by danie_000 on 17.12.2017.
+ */
+public class ModGuiHandler implements IGuiHandler {
+ public static final int SCAN_DISPLAY_SCREEN_ID =0;
+
+ @Override
+ public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
+ return null;
+ }
+
+ @Override
+ public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
+ switch (ID){
+ case SCAN_DISPLAY_SCREEN_ID:
+ return new ScanDisplayScreen(player);
+ default: return null;
+ }
+ }
+}
diff --git a/src/main/java/com/github/technus/tectech/thing/item/ElementalDefinitionScanStorage_EM.java b/src/main/java/com/github/technus/tectech/thing/item/ElementalDefinitionScanStorage_EM.java
index a64a639c11..3b307fb081 100644
--- a/src/main/java/com/github/technus/tectech/thing/item/ElementalDefinitionScanStorage_EM.java
+++ b/src/main/java/com/github/technus/tectech/thing/item/ElementalDefinitionScanStorage_EM.java
@@ -4,17 +4,20 @@ import com.github.technus.tectech.CommonValues;
import com.github.technus.tectech.TecTech;
import com.github.technus.tectech.Util;
import com.github.technus.tectech.elementalMatter.core.cElementalInstanceStackMap;
+import com.github.technus.tectech.loader.ModGuiHandler;
import com.github.technus.tectech.thing.CustomItemList;
+import com.github.technus.tectech.thing.item.gui.ScanDisplayScreen;
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.entity.player.EntityPlayer;
-import net.minecraft.item.Item;
-import net.minecraft.item.ItemStack;
+import net.minecraft.init.Items;
+import net.minecraft.item.*;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.IIcon;
+import net.minecraft.world.World;
import java.util.Collections;
import java.util.List;
@@ -53,16 +56,22 @@ public class ElementalDefinitionScanStorage_EM extends Item {
return;
}
+ public static String[] getLines(ItemStack containerItem){
+ if(containerItem.stackTagCompound!=null && containerItem.stackTagCompound.hasKey("elementalInfo"))
+ return Util.infoFromNBT(containerItem.stackTagCompound.getCompoundTag("elementalInfo"));
+ return null;
+ }
+
@Override
public void addInformation(ItemStack aStack, EntityPlayer ep, List aList, boolean boo) {
aList.add(CommonValues.TEC_MARK_EM);
try {
if (aStack.stackTagCompound != null && aStack.stackTagCompound.hasKey("elementalInfo")) {
aList.add("Contains scan result");
- if(DEBUG_MODE) {
- aList.add("DEBUG MODE INFO - U CHEATER");
- Collections.addAll(aList, Util.infoFromNBT(aStack.stackTagCompound.getCompoundTag("elementalInfo")));
- }
+ //if(DEBUG_MODE) {
+ // aList.add("DEBUG MODE INFO - U CHEATER");
+ // Collections.addAll(aList, Util.infoFromNBT(aStack.stackTagCompound.getCompoundTag("elementalInfo")));
+ //}
} else {
aList.add("Storage for matter scan data");
}
@@ -93,8 +102,26 @@ public class ElementalDefinitionScanStorage_EM extends Item {
}
@Override
+ public IIcon getIcon(ItemStack itemStack, int pass) {
+ NBTTagCompound tagCompound=itemStack.stackTagCompound;
+ if(tagCompound!=null && tagCompound.hasKey("elementalInfo"))
+ return online;
+ return offline;
+ }
+
+ @Override
public void getSubItems(Item item, CreativeTabs tab, List list) {
ItemStack that = new ItemStack(this, 1);
list.add(that);
}
+
+ @Override
+ public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player) {
+ if(world.isRemote){
+ NBTTagCompound tagCompound=itemStack.stackTagCompound;
+ if(tagCompound!=null && tagCompound.hasKey("elementalInfo"))
+ player.openGui(TecTech.instance, ModGuiHandler.SCAN_DISPLAY_SCREEN_ID,world,0,0,0);
+ }
+ return itemStack;
+ }
}
diff --git a/src/main/java/com/github/technus/tectech/thing/item/gui/ScanDisplayScreen.java b/src/main/java/com/github/technus/tectech/thing/item/gui/ScanDisplayScreen.java
new file mode 100644
index 0000000000..e7d3122872
--- /dev/null
+++ b/src/main/java/com/github/technus/tectech/thing/item/gui/ScanDisplayScreen.java
@@ -0,0 +1,110 @@
+package com.github.technus.tectech.thing.item.gui;
+
+import com.github.technus.tectech.TecTech;
+import com.github.technus.tectech.thing.item.ElementalDefinitionScanStorage_EM;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.GuiButton;
+import net.minecraft.client.gui.GuiScreen;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.util.ResourceLocation;
+import org.lwjgl.opengl.GL11;
+
+import static org.lwjgl.opengl.GL11.*;
+import static org.lwjgl.opengl.GL11.GL_ONE_MINUS_SRC_ALPHA;
+
+/**
+ * Created by danie_000 on 17.12.2017.
+ */
+public class ScanDisplayScreen extends GuiScreen {
+ private static final int sizeX=240,sizeY=220;
+ private int baseX,baseY;
+ private Button up,down,pgUp,pgDown;
+ private String[] lines;
+ private int firstLine =0;
+
+ private static final ResourceLocation BACKGROUND =new ResourceLocation("tectech:textures/gui/scanDisplayScreen.png");
+ private static final ResourceLocation ITEM =new ResourceLocation("tectech:textures/gui/scanDisplayItem.png");
+
+ public ScanDisplayScreen(EntityPlayer player){
+ super();
+ lines= ElementalDefinitionScanStorage_EM.getLines(player.getHeldItem());
+ }
+
+ @Override
+ public void drawScreen(int x, int y, float partialTicks) {
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ this.mc.getTextureManager().bindTexture(ITEM);
+ long tick=System.currentTimeMillis()/150;
+ int itick=(int)(tick%12);
+ drawTexturedModalRect(baseX+99,baseY+189,32*(itick/6),32*(itick%6), 32, 32);
+ this.mc.getTextureManager().bindTexture(BACKGROUND);
+ drawTexturedModalRect(baseX,baseY,0,0, sizeX, sizeY);
+ glDisable(GL_BLEND);
+ super.drawScreen(x,y,partialTicks);
+
+ int textBaseX=baseX+20;
+ int textBaseY=baseY+20;
+
+ for(int i=firstLine;i<lines.length && i<=firstLine+8;i++){
+ TecTech.proxy.renderUnicodeString(lines[i],textBaseX,textBaseY+i*9,200,0xDDEEFF);
+ }
+ }
+
+ @Override
+ public boolean doesGuiPauseGame() {
+ return false;
+ }
+
+ @Override
+ public void initGui() {
+ baseX=(width-sizeX)/2;
+ baseY=(height-sizeY)/2-12;
+ int buttonBaseY=baseY+145;
+ this.buttonList.add(up=new Button(0,baseX+77,buttonBaseY,0,220));
+ this.buttonList.add(down=new Button(1,baseX+99,buttonBaseY,20,220));
+ this.buttonList.add(pgUp=new Button(2,baseX+121,buttonBaseY,40,220));
+ this.buttonList.add(pgDown=new Button(3,baseX+143,buttonBaseY,60,220));
+ }
+
+ @Override
+ protected void actionPerformed(GuiButton button) {
+ if (lines.length <= 8) return;
+ if (button == pgUp) {
+ firstLine -= 8;
+ } else if (button == up) {
+ firstLine--;
+ } else if (button == down) {
+ firstLine++;
+ } else if (button == pgDown) {
+ firstLine += 8;
+ }
+ if (firstLine > lines.length - 8) firstLine = lines.length - 8;
+ if (firstLine < 0) firstLine = 0;
+ }
+
+ private class Button extends GuiButton{
+ int u,v;
+ Button(int id,int x,int y,int u,int v){
+ super(id,x,y,20,20,"");
+ this.u=u;
+ this.v=v;
+ }
+
+ @Override
+ public void drawButton(Minecraft mc, int xPos, int yPos)
+ {
+ if (this.visible)
+ {
+ this.field_146123_n = xPos >= this.xPosition && yPos >= this.yPosition && xPos < this.xPosition + this.width && yPos < this.yPosition + this.height;
+ mc.getTextureManager().bindTexture(BACKGROUND);
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ mc.getTextureManager().bindTexture(BACKGROUND);
+ drawTexturedModalRect(this.xPosition, this.yPosition, u + this.getHoverState(this.field_146123_n) * 80, v, this.width, this.height);
+ glDisable(GL_BLEND);
+ GL11.glEnable(GL11.GL_BLEND);
+ }
+ }
+ }
+}
diff --git a/src/main/resources/assets/tectech/textures/gui/scanDisplayItem.png b/src/main/resources/assets/tectech/textures/gui/scanDisplayItem.png
new file mode 100644
index 0000000000..dc9794a424
--- /dev/null
+++ b/src/main/resources/assets/tectech/textures/gui/scanDisplayItem.png
Binary files differ
diff --git a/src/main/resources/assets/tectech/textures/gui/scanDisplayScreen.png b/src/main/resources/assets/tectech/textures/gui/scanDisplayScreen.png
new file mode 100644
index 0000000000..cf73f8098a
--- /dev/null
+++ b/src/main/resources/assets/tectech/textures/gui/scanDisplayScreen.png
Binary files differ