aboutsummaryrefslogtreecommitdiff
path: root/src/Java/gtPlusPlus
diff options
context:
space:
mode:
Diffstat (limited to 'src/Java/gtPlusPlus')
-rw-r--r--src/Java/gtPlusPlus/core/container/Container_Grindle.java175
-rw-r--r--src/Java/gtPlusPlus/core/gui/item/GuiBaseGrindle.java274
-rw-r--r--src/Java/gtPlusPlus/core/handler/GuiHandler.java3
-rw-r--r--src/Java/gtPlusPlus/core/inventories/BaseInventoryGrindle.java111
-rw-r--r--src/Java/gtPlusPlus/core/item/general/BaseItemGrindle.java36
-rw-r--r--src/Java/gtPlusPlus/core/recipe/common/CI.java10
-rw-r--r--src/Java/gtPlusPlus/core/slots/SlotDataStick.java32
7 files changed, 367 insertions, 274 deletions
diff --git a/src/Java/gtPlusPlus/core/container/Container_Grindle.java b/src/Java/gtPlusPlus/core/container/Container_Grindle.java
index ecda81a5f0..4ab79322c9 100644
--- a/src/Java/gtPlusPlus/core/container/Container_Grindle.java
+++ b/src/Java/gtPlusPlus/core/container/Container_Grindle.java
@@ -9,155 +9,131 @@ import net.minecraft.item.ItemStack;
import gtPlusPlus.core.inventories.BaseInventoryGrindle;
import gtPlusPlus.core.slots.SlotDataStick;
-public class Container_Grindle extends Container
-{
- /** The Item Inventory for this Container, only needed if you want to reference isUseableByPlayer */
+public class Container_Grindle extends Container {
+ /**
+ * The Item Inventory for this Container, only needed if you want to reference
+ * isUseableByPlayer
+ */
public final BaseInventoryGrindle inventory;
- /** Using these will make transferStackInSlot easier to understand and implement
+ /**
+ * Using these will make transferStackInSlot easier to understand and implement
* INV_START is the index of the first slot in the Player's Inventory, so our
- * BaseInventoryBackpack's number of slots (e.g. 5 slots is array indices 0-4, so start at 5)
- * Notice how we don't have to remember how many slots we made? We can just use
- * BaseInventoryBackpack.INV_SIZE and if we ever change it, the Container updates automatically. */
- private static final int INV_START = BaseInventoryGrindle.INV_SIZE, INV_END = INV_START+0,
- HOTBAR_START = INV_END, HOTBAR_END = HOTBAR_START+8;
-
- // If you're planning to add armor slots, put those first like this:
- // ARMOR_START = BaseInventoryBackpack.INV_SIZE, ARMOR_END = ARMOR_START+3,
- // INV_START = ARMOR_END+1, and then carry on like above.
-
- public Container_Grindle(final EntityPlayer par1Player, final InventoryPlayer inventoryPlayer, final BaseInventoryGrindle inventoryItem)
- {
+ * BaseInventoryBackpack's number of slots (e.g. 5 slots is array indices 0-4,
+ * so start at 5) Notice how we don't have to remember how many slots we made?
+ * We can just use BaseInventoryBackpack.INV_SIZE and if we ever change it, the
+ * Container updates automatically.
+ */
+ private static final int
+ INV_START = BaseInventoryGrindle.INV_SIZE,
+ INV_END = INV_START + 0,
+ HOTBAR_START = INV_END,
+ HOTBAR_END = HOTBAR_START + 8;
+
+ public Container_Grindle(final EntityPlayer par1Player, final InventoryPlayer inventoryPlayer,
+ final BaseInventoryGrindle inventoryItem) {
this.inventory = inventoryItem;
int i;
-
- //Actual Scan Slot
+
+ // Actual Scan Slot
this.addSlotToContainer(new SlotDataStick(this.inventory, 0, 152, 5));
-
- for (i = 1; i < BaseInventoryGrindle.INV_SIZE; ++i){
- this.addSlotToContainer(new SlotDataStick(this.inventory, i, 153, 30+(18*i)));
+
+ for (i = 1; i < BaseInventoryGrindle.INV_SIZE; ++i) {
+ this.addSlotToContainer(new SlotDataStick(this.inventory, i, 153, 30 + (18 * i)));
}
- // PLAYER ACTION BAR - uses default locations for standard action bar texture file
- for (i = 0; i < 9; ++i)
- {
+ // PLAYER ACTION BAR - uses default locations for standard action bar texture
+ // file
+ for (i = 0; i < 9; ++i) {
this.addSlotToContainer(new Slot(inventoryPlayer, i, 8 + (i * 18), 142));
}
}
@Override
- public boolean canInteractWith(final EntityPlayer entityplayer)
- {
- // be sure to return the inventory's isUseableByPlayer method
- // if you defined special behavior there:
+ public boolean canInteractWith(final EntityPlayer entityplayer) {
return this.inventory.isUseableByPlayer(entityplayer);
}
/**
- * Called when a player shift-clicks on a slot. You must override this or you will crash when someone does that.
+ * Called when a player shift-clicks on a slot. You must override this or you
+ * will crash when someone does that.
*/
@Override
- public ItemStack transferStackInSlot(final EntityPlayer par1EntityPlayer, final int index)
- {
+ public ItemStack transferStackInSlot(final EntityPlayer par1EntityPlayer, final int index) {
ItemStack itemstack = null;
final Slot slot = (Slot) this.inventorySlots.get(index);
- if ((slot != null) && slot.getHasStack())
- {
+ if ((slot != null) && slot.getHasStack()) {
final ItemStack itemstack1 = slot.getStack();
itemstack = itemstack1.copy();
// If item is in our custom Inventory or armor slot
- if (index < INV_START)
- {
+ if (index < INV_START) {
// try to place in player inventory / action bar
- if (!this.mergeItemStack(itemstack1, INV_START, HOTBAR_END+1, true))
- {
+ if (!this.mergeItemStack(itemstack1, INV_START, HOTBAR_END + 1, true)) {
return null;
}
slot.onSlotChange(itemstack1, itemstack);
}
- // Item is in inventory / hotbar, try to place in custom inventory or armor slots
- else
- {
- /*
- If your inventory only stores certain instances of Items,
- you can implement shift-clicking to your inventory like this:
-
- // Check that the item is the right type
- if (itemstack1.getItem() instanceof ItemCustom)
- {
- // Try to merge into your custom inventory slots
- // We use 'BaseInventoryBackpack.INV_SIZE' instead of INV_START just in case
- // you also add armor or other custom slots
- if (!this.mergeItemStack(itemstack1, 0, BaseInventoryBackpack.INV_SIZE, false))
- {
- return null;
- }
- }
- // If you added armor slots, check them here as well:
- // Item being shift-clicked is armor - try to put in armor slot
- if (itemstack1.getItem() instanceof ItemArmor)
- {
- int type = ((ItemArmor) itemstack1.getItem()).armorType;
- if (!this.mergeItemStack(itemstack1, ARMOR_START + type, ARMOR_START + type + 1, false))
- {
- return null;
- }
- }
- Otherwise, you have basically 2 choices:
- 1. shift-clicking between player inventory and custom inventory
- 2. shift-clicking between action bar and inventory
-
- Be sure to choose only ONE of the following implementations!!!
- */
- /**
+ // Item is in inventory / hotbar, try to place in custom inventory or armor
+ // slots
+ else {/*
+
+ * If your inventory only stores certain instances of Items, you can implement
+ * shift-clicking to your inventory like this:
+ *
+ * // Check that the item is the right type if (itemstack1.getItem() instanceof
+ * ItemCustom) { // Try to merge into your custom inventory slots // We use
+ * 'BaseInventoryBackpack.INV_SIZE' instead of INV_START just in case // you
+ * also add armor or other custom slots if (!this.mergeItemStack(itemstack1, 0,
+ * BaseInventoryBackpack.INV_SIZE, false)) { return null; } } // If you added
+ * armor slots, check them here as well: // Item being shift-clicked is armor -
+ * try to put in armor slot if (itemstack1.getItem() instanceof ItemArmor) { int
+ * type = ((ItemArmor) itemstack1.getItem()).armorType; if
+ * (!this.mergeItemStack(itemstack1, ARMOR_START + type, ARMOR_START + type + 1,
+ * false)) { return null; } } Otherwise, you have basically 2 choices: 1.
+ * shift-clicking between player inventory and custom inventory 2.
+ * shift-clicking between action bar and inventory
+ *
+ * Be sure to choose only ONE of the following implementations!!!
+
+ *//**
* Implementation number 1: Shift-click into your custom inventory
- */
- if (index >= INV_START)
- {
+ *//*
+ if (index >= INV_START) {
// place in custom inventory
- if (!this.mergeItemStack(itemstack1, 0, INV_START, false))
- {
+ if (!this.mergeItemStack(itemstack1, 0, INV_START, false)) {
return null;
}
}
- /**
+ *//**
* Implementation number 2: Shift-click items between action bar and inventory
- */
+ *//*
// item is in player's inventory, but not in action bar
- if ((index >= INV_START) && (index < HOTBAR_START))
- {
+ if ((index >= INV_START) && (index < HOTBAR_START)) {
// place in action bar
- if (!this.mergeItemStack(itemstack1, HOTBAR_START, HOTBAR_END+1, false))
- {
+ if (!this.mergeItemStack(itemstack1, HOTBAR_START, HOTBAR_END + 1, false)) {
return null;
}
}
// item in action bar - place in player inventory
- else if ((index >= HOTBAR_START) && (index < (HOTBAR_END+1)))
- {
- if (!this.mergeItemStack(itemstack1, INV_START, INV_END+1, false))
- {
+ else if ((index >= HOTBAR_START) && (index < (HOTBAR_END + 1))) {
+ if (!this.mergeItemStack(itemstack1, INV_START, INV_END + 1, false)) {
return null;
}
}
- }
+ */}
- if (itemstack1.stackSize == 0)
- {
+ if (itemstack1.stackSize == 0) {
slot.putStack((ItemStack) null);
- }
- else
- {
+ } else {
slot.onSlotChanged();
}
- if (itemstack1.stackSize == itemstack.stackSize)
- {
+ if (itemstack1.stackSize == itemstack.stackSize) {
return null;
}
@@ -168,13 +144,14 @@ public class Container_Grindle extends Container
}
/**
- * You should override this method to prevent the player from moving the stack that
- * opened the inventory, otherwise if the player moves it, the inventory will not
- * be able to save properly
+ * You should override this method to prevent the player from moving the stack
+ * that opened the inventory, otherwise if the player moves it, the inventory
+ * will not be able to save properly
*/
@Override
public ItemStack slotClick(final int slot, final int button, final int flag, final EntityPlayer player) {
- // this will prevent the player from interacting with the item that opened the inventory:
+ // this will prevent the player from interacting with the item that opened the
+ // inventory:
if ((slot >= 0) && (this.getSlot(slot) != null) && (this.getSlot(slot).getStack() == player.getHeldItem())) {
return null;
}
diff --git a/src/Java/gtPlusPlus/core/gui/item/GuiBaseGrindle.java b/src/Java/gtPlusPlus/core/gui/item/GuiBaseGrindle.java
index 9272d462df..fd88531e0b 100644
--- a/src/Java/gtPlusPlus/core/gui/item/GuiBaseGrindle.java
+++ b/src/Java/gtPlusPlus/core/gui/item/GuiBaseGrindle.java
@@ -1,20 +1,22 @@
package gtPlusPlus.core.gui.item;
+import java.util.LinkedHashSet;
+import java.util.Set;
+
import org.lwjgl.opengl.GL11;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.resources.I18n;
+import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
-import net.minecraft.nbt.NBTTagList;
-import net.minecraft.nbt.NBTTagString;
import net.minecraft.util.ResourceLocation;
-
-import gregtech.api.util.GT_Utility.ItemNBT;
-
+import gregtech.api.util.GT_Utility;
+import gtPlusPlus.api.objects.data.AutoMap;
import gtPlusPlus.core.container.Container_Grindle;
import gtPlusPlus.core.inventories.BaseInventoryGrindle;
import gtPlusPlus.core.lib.CORE;
+import gtPlusPlus.core.recipe.common.CI;
import gtPlusPlus.core.util.Utils;
import gtPlusPlus.core.util.minecraft.NBTUtils;
@@ -23,12 +25,13 @@ public class GuiBaseGrindle extends GuiContainer {
/** The FontRenderer used by GuiScreen */
protected FontRenderer fontRenderer;
- private static final ResourceLocation iconLocation = new ResourceLocation(CORE.MODID, "textures/gui/itemGrindle.png");
+ private static final ResourceLocation iconLocation = new ResourceLocation(CORE.MODID,
+ "textures/gui/itemGrindle.png");
/** The inventory to render on screen */
private final BaseInventoryGrindle inventory;
- public GuiBaseGrindle(final Container_Grindle containerItem){
+ public GuiBaseGrindle(final Container_Grindle containerItem) {
super(containerItem);
this.inventory = containerItem.inventory;
}
@@ -37,98 +40,225 @@ public class GuiBaseGrindle extends GuiContainer {
* Draws the screen and all the components in it.
*/
@Override
- public void drawScreen(final int par1, final int par2, final float par3){
+ public void drawScreen(final int par1, final int par2, final float par3) {
super.drawScreen(par1, par2, par3);
}
/**
- * Draw the foreground layer for the GuiContainer (everything in front of the items)
+ * Draw the foreground layer for the GuiContainer (everything in front of the
+ * items)
*/
@Override
- protected void drawGuiContainerForegroundLayer(final int par1, final int par2){
- final String s = "Git";
- //Title
- this.fontRendererObj.drawStringWithShadow(I18n.format("Gregtech Information Transponder", new Object[0]), 0, -12, Utils.rgbtoHexValue(255, 255, 255));
-
- if (this.inventory.getStackInSlot(0) != null){
- this.fontRendererObj.drawString(I18n.format(""+NBTUtils.getBookTitle(this.inventory.getStackInSlot(0)), new Object[0]), 10, 8, Utils.rgbtoHexValue(125, 255, 125));
-
- //if (!NBTUtils.tryIterateNBTData(this.inventory.getStackInSlot(0))){
- // this.fontRendererObj.drawString(I18n.format("Very Bad prospection data.", new Object[0]), 10, 38, Utils.rgbtoHexValue(255, 125, 125));
- //}
-
- NBTTagCompound tNBT = ItemNBT.getNBT(this.inventory.getStackInSlot(0));
- byte tTier = tNBT.getByte("prospection_tier");
- //List Tier
- //this.fontRendererObj.drawStringWithShadow(I18n.format("Tier: "+tTier, new Object[0]), 10, 18, Utils.rgbtoHexValue(125, 255, 125));
-
- if (tTier == 0) { // basic prospection data
- String tData = tNBT.getString("prospection");
- //List prospection
- //this.fontRendererObj.drawStringWithShadow(I18n.format("Prospection : "+tData, new Object[0]), 10, 28, Utils.rgbtoHexValue(125, 255, 125));
-
- String[] tDataArray = tData.split(",");
- if (tDataArray.length > 6) {
- tNBT.setString("author", "X: " + tDataArray[0] + " Y: " + tDataArray[1] + " Z: " + tDataArray[2] + " Dim: " + tDataArray[3]);
- //List prospection
- this.fontRendererObj.drawString(I18n.format("X: " + tDataArray[0], new Object[0]), 10, 28, Utils.rgbtoHexValue(125, 125, 255));
- this.fontRendererObj.drawString(I18n.format("Y: " + tDataArray[1], new Object[0]), 10, 38, Utils.rgbtoHexValue(125, 125, 255));
- this.fontRendererObj.drawString(I18n.format("Z: " + tDataArray[2], new Object[0]), 10, 48, Utils.rgbtoHexValue(125, 125, 255));
- this.fontRendererObj.drawString(I18n.format("Dim: " + tDataArray[3], new Object[0]), 10, 58, Utils.rgbtoHexValue(125, 125, 255));
-
- //Divider
- this.fontRendererObj.drawString(I18n.format("-------------------", new Object[0]), 10, 63, Utils.rgbtoHexValue(125, 125, 255));
-
- NBTTagList tNBTList = new NBTTagList();
- String[] mOreTypes = new String[50];
- String tOres = " Prospected Ores: ";
+ protected void drawGuiContainerForegroundLayer(final int par1, final int par2) {
+
+ // Title
+ this.fontRendererObj.drawStringWithShadow(I18n.format("Gregtech Information Transponder", new Object[0]), 0,
+ -12, Utils.rgbtoHexValue(255, 255, 255));
+ ItemStack aStack = this.inventory.getStackInSlot(0);
+ if (aStack != null) {
+
+ int aType = -1;
+ boolean isProspecting = false;
+ if (GT_Utility.areStacksEqual(aStack, CI.getDataStick(), true)) {
+ aType = 0;
+ } else if (GT_Utility.areStacksEqual(aStack, CI.getDataOrb(), true)) {
+ aType = 1;
+ }
+
+ NBTTagCompound tNBT = this.inventory.getStackInSlot(0).getTagCompound();
+ if (tNBT == null) {
+ tNBT = new NBTTagCompound();
+ }
+
+ String aName = tNBT.hasKey("title") ? tNBT.getString("title")
+ : (aType == 0 ? "Empty Data Stick" : (aType == 1 ? "Empty Data Orb" : "Unknown Item"));
+
+ this.fontRendererObj.drawString(I18n.format(aName), 10, 8, Utils.rgbtoHexValue(125, 255, 125));
+
+ if (aName.toLowerCase().contains("raw prospection data")) {
+ isProspecting = true;
+ }
+
+ // Debug NBT Information
+ //NBTUtils.tryIterateNBTData(aStack);
+
+ byte tTier = -1;
+ if (isProspecting) {
+ if (!tNBT.hasKey("prospection_tier") && tNBT.hasKey("prospection")) {
+ tTier = 0;
+ } else if (tNBT.hasKey("prospection_tier") && !tNBT.hasKey("prospection")) {
+ tTier = tNBT.getByte("prospection_tier");
+ }
+ }
+
+ if (tTier >= 0) {
+
+ String xPos, yPos, zPos, aDim;
+ String aPositionString, aInfoString;
+ Set<String> aOreTypes = new LinkedHashSet<String>();
+ Set<String> aOilTypes = new LinkedHashSet<String>();
+
+ //Set variables that are shared between prospection types.
+ if (tTier == 0) {
+ String tData = tNBT.getString("prospection");
+ String[] tDataArray = tData.split(",");
+ xPos = tDataArray[0];
+ yPos = tDataArray[1];
+ zPos = tDataArray[2];
+ aDim = tDataArray[3];
+ aOilTypes.add("Oil Type: "+tDataArray[5]);
+ aOreTypes.add("Ore Types: ");
for (int i = 6; tDataArray.length > i; i++) {
- mOreTypes[i] = (tDataArray[i] + " ");
- if ((68+(i-6)*8) < (68+56)){
- this.fontRendererObj.drawString(I18n.format(mOreTypes[i], new Object[0]), 10, 68+((i-6)*8), Utils.rgbtoHexValue(125, 255, 125));
- }
+ aOreTypes.add("-"+tDataArray[i]);
}
- tNBTList.appendTag(new NBTTagString("Prospection Data From: X" + tDataArray[0] + " Z:" + tDataArray[2] + " Dim:" + tDataArray[3] + " Produces " + tDataArray[4] + "L " + tDataArray[5] + " " + tOres));
- tNBT.setTag("pages", tNBTList);
-
-
- //List prospection
- this.fontRendererObj.drawString(I18n.format("Tier: "+tTier+ " | Pages: "+tNBTList.tagCount(), new Object[0]), 10, 18, Utils.rgbtoHexValue(125, 255, 125));
- //Divider
- this.fontRendererObj.drawString(I18n.format("-------------------", new Object[0]), 10, 23, Utils.rgbtoHexValue(125, 125, 255));
-
}
else {
- this.fontRendererObj.drawString(I18n.format("Bad prospection data.", new Object[0]), 10, 68, Utils.rgbtoHexValue(255, 125, 125));
+ String tPos = tNBT.getString("prospection_pos");
+ String[] tPosData = tPos.split(" ");
+ xPos = tPosData[1];
+ yPos = tPosData[3];
+ zPos = tPosData[5];
+ aDim = tPosData[7];
+ //Oil
+ String tOil = tNBT.getString("prospection_oils");
+ String[] tOilData = tOil.split("\\|");
+ if (tOilData.length > 0) {
+ aOilTypes.add("Oil Types:");
+ for (String s : tOilData) {
+ if (s != null) {
+ aOilTypes.add(s);
+ }
+ }
+ }
+
+ //Near
+ String tOresNear = tNBT.getString("prospection_near");
+ String[] tOresNearData = tOresNear.split("\\|");
+ //Middle
+ String tOresMid = tNBT.getString("prospection_middle");
+ String[] tOresMidData = tOresMid.split("\\|");
+ //Far
+ String tOresFar = tNBT.getString("prospection_far");
+ String[] tOresFarData = tOresFar.split("\\|");
+
+ if ((tOresNearData.length + tOresMidData.length + tOresFarData.length) > 0) {
+ aOreTypes.add("Ore Types:");
+ if (tOresNearData.length > 0) {
+ for (String s : tOresNearData) {
+ if (s != null) {
+ aOreTypes.add(s);
+ }
+ }
+ }
+ if (tOresMidData.length > 0) {
+ for (String s : tOresMidData) {
+ if (s != null) {
+ aOreTypes.add(s);
+ }
+ }
+ }
+ if (tOresFarData.length > 0) {
+ for (String s : tOresFarData) {
+ if (s != null) {
+ aOreTypes.add(s);
+ }
+ }
+ }
+ }
+
}
+
+ aInfoString = "Tier: "+tTier+" | Dim: "+aDim;
+ aPositionString = "X:"+xPos+", Y:"+yPos+", Z:"+zPos;
+
+ //Draw the GUI
+ // List prospection
+ this.fontRendererObj.drawString(I18n.format(aInfoString, new Object[0]), 10, 18, Utils.rgbtoHexValue(125, 255, 125));
+ // Divider
+ this.fontRendererObj.drawString(I18n.format("-------------------", new Object[0]), 10, 23, Utils.rgbtoHexValue(125, 125, 255));
+ // Pos data
+ this.fontRendererObj.drawString(I18n.format(aPositionString, new Object[0]), 10, 29, Utils.rgbtoHexValue(125, 125, 255));
+ // Divider
+ this.fontRendererObj.drawString(I18n.format("-------------------", new Object[0]), 10, 35, Utils.rgbtoHexValue(125, 125, 255));
+
+ int aLastYUsed = 40;
+
+ AutoMap<String> aInfoList = new AutoMap<String>();
+
+ if (aOilTypes.size() > 0) {
+ for (String aOils : aOilTypes) {
+ if (aOils != null && aOils.length() > 0) {
+ aInfoList.put(aOils);
+ }
+ }
+ }
+
+ if (aOreTypes.size() > 0) {
+ for (String aOres : aOreTypes) {
+ if (aOres != null && aOres.length() > 0) {
+ aInfoList.put(aOres);
+ }
+ }
+ }
+
+ for (int i=0;i<aInfoList.size();i++) {
+ if ((aLastYUsed + 9) <= (68 + 56)) {
+ this.fontRendererObj.drawString(I18n.format(aInfoList.get(i), new Object[0]), 10, aLastYUsed, Utils.rgbtoHexValue(125, 255, 125));
+ aLastYUsed = aLastYUsed + 9;
+ }
+ }
}
- }
- else {
- //Valid Datastick?
- this.fontRendererObj.drawStringWithShadow(I18n.format("Insert device into port.", new Object[0]), 10, 8, Utils.rgbtoHexValue(255, 125, 125));
- }
+ else {
+
+ }
+
+ /*if (tDataArray.length > 6) {
+ // Adds weird info to item in slot but this data is not retained.
+ // tNBT.setString("author", ".");
+ NBTTagList tNBTList = new NBTTagList();
+ String[] mOreTypes = new String[50];
+ String tOres = " Prospected Ores: ";
+ for (int i = 6; tDataArray.length > i; i++) {
+ mOreTypes[i] = (tDataArray[i] + " ");
+ if ((68 + (i - 6) * 8) < (68 + 56)) {
+ this.fontRendererObj.drawString(I18n.format(mOreTypes[i], new Object[0]), 10,
+ 40 + ((i - 6) * 8), Utils.rgbtoHexValue(125, 255, 125));
+ }
+ }
+ // tNBTList.appendTag(new NBTTagString("Prospection Data From: X" +
+ // tDataArray[0] + " Z:" + tDataArray[2] + " Dim:" + tDataArray[3] + " Produces
+ // " + tDataArray[4] + "L " + tDataArray[5] + " " + tOres));
+ // tNBT.setTag("pages", tNBTList);
- //Inventory Label
- this.fontRendererObj.drawStringWithShadow(I18n.format("container.inventory", new Object[0]), 8, 131, Utils.rgbtoHexValue(255, 255, 255));
+ } else {
+ this.fontRendererObj.drawString(I18n.format("Bad prospection data.", new Object[0]), 10, 68,
+ Utils.rgbtoHexValue(255, 125, 125));
+ }*/
+ } else {
+ // Valid Datastick?
+ this.fontRendererObj.drawStringWithShadow(I18n.format("Insert device into port.", new Object[0]), 10, 8,
+ Utils.rgbtoHexValue(255, 125, 125));
+ }
- //this.fontRenderer.drawString(s, this.xSize / 2 - this.fontRenderer.getStringWidth(s) / 2, 0, 4210752);
- //this.fontRenderer.drawString(I18n.translate("container.inventory"), 26, this.ySize - 96 + 4, 4210752);
+ // Inventory Label
+ this.fontRendererObj.drawStringWithShadow(I18n.format("container.inventory", new Object[0]), 8, 131,
+ Utils.rgbtoHexValue(255, 255, 255));
}
/**
* Draw the background layer for the GuiContainer (everything behind the items)
*/
@Override
- protected void drawGuiContainerBackgroundLayer(final float par1, final int par2, final int par3)
- {
+ protected void drawGuiContainerBackgroundLayer(final float par1, final int par2, final int par3) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.getTextureManager().bindTexture(iconLocation);
final int k = (this.width - this.xSize) / 2;
final int l = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
final int i1;
- //drawPlayerModel(k + 51, l + 75, 30, k + 51 - this.xSize_lo, (l + 75) - 50 - this.ySize_lo, this.mc.thePlayer);
+ // drawPlayerModel(k + 51, l + 75, 30, k + 51 - this.xSize_lo, (l + 75) - 50 -
+ // this.ySize_lo, this.mc.thePlayer);
}
}
diff --git a/src/Java/gtPlusPlus/core/handler/GuiHandler.java b/src/Java/gtPlusPlus/core/handler/GuiHandler.java
index 1dc70a9360..44ff165a1b 100644
--- a/src/Java/gtPlusPlus/core/handler/GuiHandler.java
+++ b/src/Java/gtPlusPlus/core/handler/GuiHandler.java
@@ -14,6 +14,7 @@ import gtPlusPlus.core.container.*;
import gtPlusPlus.core.gui.beta.Gui_ID_Registry;
import gtPlusPlus.core.gui.beta.MU_GuiId;
import gtPlusPlus.core.gui.item.GuiBaseBackpack;
+import gtPlusPlus.core.gui.item.GuiBaseGrindle;
import gtPlusPlus.core.gui.item.GuiScreenGrindle;
import gtPlusPlus.core.gui.machine.*;
import gtPlusPlus.core.interfaces.IGuiManager;
@@ -138,7 +139,7 @@ public class GuiHandler implements IGuiHandler {
}
if (ID == GUI9){
- return new GuiScreenGrindle(new Container_Grindle(player, player.inventory, new BaseInventoryGrindle(player.getHeldItem())), player);
+ return new GuiBaseGrindle(new Container_Grindle(player, player.inventory, new BaseInventoryGrindle(player.getHeldItem())));
}
return null;
diff --git a/src/Java/gtPlusPlus/core/inventories/BaseInventoryGrindle.java b/src/Java/gtPlusPlus/core/inventories/BaseInventoryGrindle.java
index a7acb96ade..823398bd57 100644
--- a/src/Java/gtPlusPlus/core/inventories/BaseInventoryGrindle.java
+++ b/src/Java/gtPlusPlus/core/inventories/BaseInventoryGrindle.java
@@ -11,7 +11,7 @@ import net.minecraft.nbt.NBTTagList;
import gtPlusPlus.core.item.base.BaseItemBackpack;
import net.minecraftforge.common.util.Constants;
-public class BaseInventoryGrindle implements IInventory{
+public class BaseInventoryGrindle implements IInventory {
private final String name = "Inventory Item";
@@ -21,24 +21,26 @@ public class BaseInventoryGrindle implements IInventory{
/** Defining your inventory size this way is handy */
public static final int INV_SIZE = 6;
- /** Inventory's size must be same as number of slots you add to the Container class */
+ /**
+ * Inventory's size must be same as number of slots you add to the Container
+ * class
+ */
private final ItemStack[] inventory = new ItemStack[INV_SIZE];
// declaration of variable:
protected String uniqueID;
/**
- * @param itemstack - the ItemStack to which this inventory belongs
+ * @param itemstack
+ * - the ItemStack to which this inventory belongs
*/
- public BaseInventoryGrindle(final ItemStack stack)
- {
+ public BaseInventoryGrindle(final ItemStack stack) {
this.invItem = stack;
/** initialize variable within the constructor: */
this.uniqueID = "";
- if (!stack.hasTagCompound())
- {
+ if (!stack.hasTagCompound()) {
stack.setTagCompound(new NBTTagCompound());
// no tag compound means the itemstack does not yet have a UUID, so assign one:
this.uniqueID = UUID.randomUUID().toString();
@@ -55,32 +57,26 @@ public class BaseInventoryGrindle implements IInventory{
// Read the inventory contents from NBT
this.readFromNBT(stack.getTagCompound());
}
+
@Override
- public int getSizeInventory()
- {
+ public int getSizeInventory() {
return this.inventory.length;
}
@Override
- public ItemStack getStackInSlot(final int slot)
- {
+ public ItemStack getStackInSlot(final int slot) {
return this.inventory[slot];
}
@Override
- public ItemStack decrStackSize(final int slot, final int amount)
- {
+ public ItemStack decrStackSize(final int slot, final int amount) {
ItemStack stack = this.getStackInSlot(slot);
- if(stack != null)
- {
- if(stack.stackSize > amount)
- {
+ if (stack != null) {
+ if (stack.stackSize > amount) {
stack = stack.splitStack(amount);
// Don't forget this line or your inventory will not be saved!
this.markDirty();
- }
- else
- {
+ } else {
// this method also calls markDirty, so we don't need to call it again
this.setInventorySlotContents(slot, null);
}
@@ -89,20 +85,17 @@ public class BaseInventoryGrindle implements IInventory{
}
@Override
- public ItemStack getStackInSlotOnClosing(final int slot)
- {
+ public ItemStack getStackInSlotOnClosing(final int slot) {
final ItemStack stack = this.getStackInSlot(slot);
this.setInventorySlotContents(slot, null);
return stack;
}
@Override
- public void setInventorySlotContents(final int slot, final ItemStack stack)
- {
+ public void setInventorySlotContents(final int slot, final ItemStack stack) {
this.inventory[slot] = stack;
- if ((stack != null) && (stack.stackSize > this.getInventoryStackLimit()))
- {
+ if ((stack != null) && (stack.stackSize > this.getInventoryStackLimit())) {
stack.stackSize = this.getInventoryStackLimit();
}
@@ -112,35 +105,31 @@ public class BaseInventoryGrindle implements IInventory{
// 1.7.2+ renamed to getInventoryName
@Override
- public String getInventoryName()
- {
+ public String getInventoryName() {
return this.name;
}
// 1.7.2+ renamed to hasCustomInventoryName
@Override
- public boolean hasCustomInventoryName()
- {
+ public boolean hasCustomInventoryName() {
return this.name.length() > 0;
}
@Override
- public int getInventoryStackLimit()
- {
+ public int getInventoryStackLimit() {
return 1;
}
/**
- * This is the method that will handle saving the inventory contents, as it is called (or should be called!)
- * anytime the inventory changes. Perfect. Much better than using onUpdate in an Item, as this will also
- * let you change things in your inventory without ever opening a Gui, if you want.
+ * This is the method that will handle saving the inventory contents, as it is
+ * called (or should be called!) anytime the inventory changes. Perfect. Much
+ * better than using onUpdate in an Item, as this will also let you change
+ * things in your inventory without ever opening a Gui, if you want.
*/
// 1.7.2+ renamed to markDirty
@Override
- public void markDirty()
- {
- for (int i = 0; i < this.getSizeInventory(); ++i)
- {
+ public void markDirty() {
+ for (int i = 0; i < this.getSizeInventory(); ++i) {
if ((this.getStackInSlot(i) != null) && (this.getStackInSlot(i).stackSize == 0)) {
this.inventory[i] = null;
}
@@ -151,27 +140,26 @@ public class BaseInventoryGrindle implements IInventory{
}
@Override
- public boolean isUseableByPlayer(final EntityPlayer entityplayer)
- {
+ public boolean isUseableByPlayer(final EntityPlayer entityplayer) {
return true;
}
// 1.7.2+ renamed to openInventory(EntityPlayer player)
@Override
- public void openInventory() {}
+ public void openInventory() {
+ }
// 1.7.2+ renamed to closeInventory(EntityPlayer player)
@Override
- public void closeInventory() {}
+ public void closeInventory() {
+ }
/**
- * This method doesn't seem to do what it claims to do, as
- * items can still be left-clicked and placed in the inventory
- * even when this returns false
+ * This method doesn't seem to do what it claims to do, as items can still be
+ * left-clicked and placed in the inventory even when this returns false
*/
@Override
- public boolean isItemValidForSlot(final int slot, final ItemStack itemstack)
- {
+ public boolean isItemValidForSlot(final int slot, final ItemStack itemstack) {
// Don't want to be able to store the inventory item within itself
// Bad things will happen, like losing your inventory
// Actually, this needs a custom Slot to work
@@ -181,30 +169,28 @@ public class BaseInventoryGrindle implements IInventory{
/**
* A custom method to read our inventory from an ItemStack's NBT compound
*/
- public void readFromNBT(final NBTTagCompound compound)
- {
+ public void readFromNBT(final NBTTagCompound compound) {
// Gets the custom taglist we wrote to this compound, if any
- // 1.7.2+ change to compound.getTagList("ItemInventory", Constants.NBT.TAG_COMPOUND);
+ // 1.7.2+ change to compound.getTagList("ItemInventory",
+ // Constants.NBT.TAG_COMPOUND);
final NBTTagList items = compound.getTagList("ItemInventory", Constants.NBT.TAG_COMPOUND);
- if ("".equals(this.uniqueID))
- {
+ if ("".equals(this.uniqueID)) {
// try to read unique ID from NBT
this.uniqueID = compound.getString("uniqueID");
// if it's still "", assign a new one:
- if ("".equals(this.uniqueID))
- {
+ if ("".equals(this.uniqueID)) {
this.uniqueID = UUID.randomUUID().toString();
}
}
- for (int i = 0; i < items.tagCount(); ++i)
- {
+ for (int i = 0; i < items.tagCount(); ++i) {
// 1.7.2+ change to items.getCompoundTagAt(i)
final NBTTagCompound item = items.getCompoundTagAt(i);
final int slot = item.getInteger("Slot");
- // Just double-checking that the saved slot index is within our inventory array bounds
+ // Just double-checking that the saved slot index is within our inventory array
+ // bounds
if ((slot >= 0) && (slot < this.getSizeInventory())) {
this.inventory[slot] = ItemStack.loadItemStackFromNBT(item);
}
@@ -214,16 +200,13 @@ public class BaseInventoryGrindle implements IInventory{
/**
* A custom method to write our inventory to an ItemStack's NBT compound
*/
- public void writeToNBT(final NBTTagCompound tagcompound)
- {
+ public void writeToNBT(final NBTTagCompound tagcompound) {
// Create a new NBT Tag List to store itemstacks as NBT Tags
final NBTTagList items = new NBTTagList();
- for (int i = 0; i < this.getSizeInventory(); ++i)
- {
+ for (int i = 0; i < this.getSizeInventory(); ++i) {
// Only write stacks that contain items
- if (this.getStackInSlot(i) != null)
- {
+ if (this.getStackInSlot(i) != null) {
// Make a new NBT Tag Compound to write the itemstack and slot index to
final NBTTagCompound item = new NBTTagCompound();
item.setInteger("Slot", i);
diff --git a/src/Java/gtPlusPlus/core/item/general/BaseItemGrindle.java b/src/Java/gtPlusPlus/core/item/general/BaseItemGrindle.java
index 50611c4d01..0ff922d853 100644
--- a/src/Java/gtPlusPlus/core/item/general/BaseItemGrindle.java
+++ b/src/Java/gtPlusPlus/core/item/general/BaseItemGrindle.java
@@ -13,69 +13,63 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
-import gregtech.api.util.GT_OreDictUnificator;
-
import gtPlusPlus.GTplusplus;
import gtPlusPlus.core.creative.AddToCreativeTab;
import gtPlusPlus.core.handler.GuiHandler;
import gtPlusPlus.core.lib.CORE;
-import gtPlusPlus.core.util.minecraft.ItemUtils;
-public class BaseItemGrindle extends Item{
+public class BaseItemGrindle extends Item {
protected final String unlocalName;
-
- public BaseItemGrindle(){
+ public BaseItemGrindle() {
this.unlocalName = "itemGrindleTablet";
this.setUnlocalizedName("itemGrindleTablet");
this.setTextureName(CORE.MODID + ":" + "itemTablet");
GameRegistry.registerItem(this, "itemGrindleTablet");
- GT_OreDictUnificator.registerOre("tabletGit", ItemUtils.getSimpleStack(this));
this.setMaxStackSize(1);
this.setCreativeTab(AddToCreativeTab.tabOther);
}
@Override
public int getMaxItemUseDuration(final ItemStack stack) {
- return 1;
+ return 1;
}
@Override
- public ItemStack onItemRightClick(final ItemStack itemstack, final World world, final EntityPlayer player)
- {
- if (!world.isRemote){
+ public ItemStack onItemRightClick(final ItemStack itemstack, final World world, final EntityPlayer player) {
+ if (!world.isRemote) {
if (!player.isSneaking()) {
player.openGui(GTplusplus.instance, GuiHandler.GUI9, world, 0, 0, 0);
}
}
-
return itemstack;
}
@Override
- public String getItemStackDisplayName(final ItemStack p_77653_1_) {
- return ("Git");
+ public String getItemStackDisplayName(final ItemStack aStack) {
+ String aName = super.getItemStackDisplayName(aStack);
+ if (aName.toLowerCase().contains(".name") || aName.toLowerCase().contains("git")) {
+ aName = "Grindle";
+ }
+ return aName;
}
@Override
@SideOnly(Side.CLIENT)
- public void registerIcons(final IIconRegister iconRegister)
- {
+ public void registerIcons(final IIconRegister iconRegister) {
this.itemIcon = iconRegister.registerIcon(CORE.MODID + ":" + "itemTablet");
}
@Override
public String getPotionEffect(ItemStack p_150896_1_) {
- // TODO Auto-generated method stub
return super.getPotionEffect(p_150896_1_);
}
@Override
- public void addInformation(ItemStack p_77624_1_, EntityPlayer p_77624_2_,
- List p_77624_3_, boolean p_77624_4_) {
- // TODO Auto-generated method stub
- super.addInformation(p_77624_1_, p_77624_2_, p_77624_3_, p_77624_4_);
+ public void addInformation(ItemStack p_77624_1_, EntityPlayer p_77624_2_, List aList, boolean p_77624_4_) {
+ super.addInformation(p_77624_1_, p_77624_2_, aList, p_77624_4_);
+ aList.add("Used to read data from DataSticks & DataOrbs.");
}
@Override
diff --git a/src/Java/gtPlusPlus/core/recipe/common/CI.java b/src/Java/gtPlusPlus/core/recipe/common/CI.java
index d329a42dfc..9ccfcc1a15 100644
--- a/src/Java/gtPlusPlus/core/recipe/common/CI.java
+++ b/src/Java/gtPlusPlus/core/recipe/common/CI.java
@@ -18,7 +18,6 @@ import gtPlusPlus.core.recipe.LOADER_Machine_Components;
import gtPlusPlus.core.util.Utils;
import gtPlusPlus.core.util.minecraft.ItemUtils;
import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList;
-import gtPlusPlus.xmod.gregtech.common.items.MetaGeneratedGregtechItems;
import ic2.core.Ic2Items;
public class CI {
@@ -396,6 +395,15 @@ public class CI {
return ItemList.Tool_DataOrb.get(1);
}
}
+
+ public static ItemStack getDataStick(){
+ if (CORE.ConfigSwitches.enableOldGTcircuits && CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK && !CORE.GTNH){
+ return GregtechItemList.Old_Tool_DataStick.get(1);
+ }
+ else {
+ return ItemList.Tool_DataStick.get(1);
+ }
+ }
public static final ItemStack getTieredMachineHull(int tier){
if (tier == 0){
diff --git a/src/Java/gtPlusPlus/core/slots/SlotDataStick.java b/src/Java/gtPlusPlus/core/slots/SlotDataStick.java
index 66bc4d4b5d..ce97a2fdbf 100644
--- a/src/Java/gtPlusPlus/core/slots/SlotDataStick.java
+++ b/src/Java/gtPlusPlus/core/slots/SlotDataStick.java
@@ -4,11 +4,8 @@ import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
-import gregtech.api.enums.ItemList;
-import gregtech.common.items.GT_MetaGenerated_Item_01;
-
-import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList;
-import gtPlusPlus.xmod.gregtech.common.items.MetaGeneratedGregtechItems;
+import gregtech.api.util.GT_Utility;
+import gtPlusPlus.core.recipe.common.CI;
public class SlotDataStick extends Slot {
@@ -17,21 +14,24 @@ public class SlotDataStick extends Slot {
}
+ public static ItemStack[] mDataItems = new ItemStack[2];
+
@Override
- public boolean isItemValid(final ItemStack itemstack) {
+ public synchronized boolean isItemValid(final ItemStack itemstack) {
boolean isValid = false;
-
- if (itemstack != null) {
- if ((itemstack.getItem() instanceof GT_MetaGenerated_Item_01 && itemstack.getItemDamage() == 32708)
- || (itemstack == ItemList.Tool_DataStick.get(1))
- || (itemstack == GregtechItemList.Old_Tool_DataStick.get(1))
- || (itemstack.getItem() instanceof MetaGeneratedGregtechItems
- && itemstack.getItemDamage() == 32208)) {
- isValid = true;
+ if (itemstack != null) {
+ if (mDataItems[0] == null) {
+ mDataItems[0] = CI.getDataStick();
+ }
+ if (mDataItems[1] == null) {
+ mDataItems[1] = CI.getDataOrb();
}
+ if (mDataItems[0] != null && mDataItems[1] != null) {
+ if (GT_Utility.areStacksEqual(itemstack, mDataItems[0], true) || GT_Utility.areStacksEqual(itemstack, mDataItems[1], true) ) {
+ isValid = true;
+ }
+ }
}
- // Utils.LOG_INFO("Tried inserting "+itemstack.getDisplayName()+" |
- // "+itemstack.getItemDamage()+" | ");
return isValid;
}