aboutsummaryrefslogtreecommitdiff
path: root/src/Java/gtPlusPlus/core/item
diff options
context:
space:
mode:
authorAlkalus <3060479+draknyte1@users.noreply.github.com>2018-12-24 03:59:59 +0000
committerAlkalus <3060479+draknyte1@users.noreply.github.com>2018-12-24 03:59:59 +0000
commit12dab5d109ac81034fd0a8fe18317024a996af61 (patch)
treec08e9a305f081fef24df556126be744d19f4c0f8 /src/Java/gtPlusPlus/core/item
parentc1606dd2997151dbf09797092a04294230d42059 (diff)
downloadGT5-Unofficial-12dab5d109ac81034fd0a8fe18317024a996af61.tar.gz
GT5-Unofficial-12dab5d109ac81034fd0a8fe18317024a996af61.tar.bz2
GT5-Unofficial-12dab5d109ac81034fd0a8fe18317024a996af61.zip
+ Added a config option to adjust the Turbine Rotor removal cut-off point.
+ Added some new Bags/Packs for various things. An Automatic Lunchbox, a Tool Box and a Magicians Satchel. + Added full compound of Eglin Steel to ABS. Closes #392. - Removed all Multi-Tools. $ Rewrote and Fixed the recipe system. All recipes are queued regardless of when called, then created during the end of the POST_INIT load phase. Fixes too many bugs to list. (Few more to do before tomorrow) $ Fixed COFH Hard requirement. Closes #398. % Adjusted the internal map type of the AutoMap. Should improve performance, if only in single digit cpu cycles. > To-Do) Fix Recipes pertaining to compound materials made from using fluids. State may be detected wrong after recipe system changes.
Diffstat (limited to 'src/Java/gtPlusPlus/core/item')
-rw-r--r--src/Java/gtPlusPlus/core/item/ModItems.java37
-rw-r--r--src/Java/gtPlusPlus/core/item/base/BaseItemComponent.java1
-rw-r--r--src/Java/gtPlusPlus/core/item/base/dusts/BaseItemDustUnique.java31
-rw-r--r--src/Java/gtPlusPlus/core/item/base/ore/BaseOreComponent.java52
-rw-r--r--src/Java/gtPlusPlus/core/item/base/rods/BaseItemRod.java2
-rw-r--r--src/Java/gtPlusPlus/core/item/base/rods/BaseItemRodLong.java15
-rw-r--r--src/Java/gtPlusPlus/core/item/tool/misc/box/AutoLunchBox.java11
-rw-r--r--src/Java/gtPlusPlus/core/item/tool/misc/box/BaseBoxItem.java59
-rw-r--r--src/Java/gtPlusPlus/core/item/tool/misc/box/ContainerBoxBase.java328
-rw-r--r--src/Java/gtPlusPlus/core/item/tool/misc/box/CustomBoxInventory.java243
-rw-r--r--src/Java/gtPlusPlus/core/item/tool/misc/box/MagicToolBag.java11
-rw-r--r--src/Java/gtPlusPlus/core/item/tool/misc/box/UniversalToolBox.java13
12 files changed, 781 insertions, 22 deletions
diff --git a/src/Java/gtPlusPlus/core/item/ModItems.java b/src/Java/gtPlusPlus/core/item/ModItems.java
index c86c10bb53..cc0b4325f3 100644
--- a/src/Java/gtPlusPlus/core/item/ModItems.java
+++ b/src/Java/gtPlusPlus/core/item/ModItems.java
@@ -49,6 +49,9 @@ import gtPlusPlus.core.item.init.ItemsFoods;
import gtPlusPlus.core.item.init.ItemsMultiTools;
import gtPlusPlus.core.item.materials.DustDecayable;
import gtPlusPlus.core.item.tool.misc.SandstoneHammer;
+import gtPlusPlus.core.item.tool.misc.box.AutoLunchBox;
+import gtPlusPlus.core.item.tool.misc.box.MagicToolBag;
+import gtPlusPlus.core.item.tool.misc.box.UniversalToolBox;
import gtPlusPlus.core.item.tool.misc.GregtechPump;
import gtPlusPlus.core.item.tool.staballoy.*;
import gtPlusPlus.core.item.wearable.WearableLoader;
@@ -282,6 +285,10 @@ public final class ModItems {
public static Fluid fluidZrF4;
+ public static Item boxTools;
+ public static Item boxFood;
+ public static Item boxMagic;
+
static {
Logger.INFO("Items!");
//Default item used when recipes fail, handy for debugging. Let's make sure they exist when this class is called upon.
@@ -348,6 +355,12 @@ public final class ModItems {
backpack_Gray = new BaseItemBackpack("backpackGray", Utils.rgbtoHexValue(128, 128, 128));
backpack_Black = new BaseItemBackpack("backpackBlack", Utils.rgbtoHexValue(20, 20, 20));
backpack_White = new BaseItemBackpack("backpackWhite", Utils.rgbtoHexValue(240, 240, 240));
+
+
+ //Load Custom Box/bags
+ boxTools = new UniversalToolBox("Tool Box");
+ boxFood = new AutoLunchBox("Eatotron-9000");
+ boxMagic = new MagicToolBag("Mystic Bag");
itemBlueprintBase = new ItemBlueprint("itemBlueprint");
@@ -365,19 +378,19 @@ public final class ModItems {
* Try generate dusts for missing rare earth materials if they don't exist
*/
- if (ItemUtils.getItemStackOfAmountFromOreDictNoBroken("dustGadolinium", 1) == null){
+ if (ItemUtils.checkForInvalidItems(ItemUtils.getItemStackOfAmountFromOreDictNoBroken("dustGadolinium", 1))){
ItemUtils.generateSpecialUseDusts("Gadolinium", "Gadolinium", Materials.Gadolinium.mElement.name(), Utils.rgbtoHexValue(226, 172, 9));
}
- if (ItemUtils.getItemStackOfAmountFromOreDictNoBroken("dustYtterbium", 1) == null){
+ if (ItemUtils.checkForInvalidItems(ItemUtils.getItemStackOfAmountFromOreDictNoBroken("dustYtterbium", 1))){
ItemUtils.generateSpecialUseDusts("Ytterbium", "Ytterbium", Materials.Ytterbium.mElement.name(), Utils.rgbtoHexValue(Materials.Yttrium.mRGBa[0]-60, Materials.Yttrium.mRGBa[1]-60, Materials.Yttrium.mRGBa[2]-60));
}
- if (ItemUtils.getItemStackOfAmountFromOreDictNoBroken("dustSamarium", 1) == null){
+ if (ItemUtils.checkForInvalidItems(ItemUtils.getItemStackOfAmountFromOreDictNoBroken("dustSamarium", 1))){
ItemUtils.generateSpecialUseDusts("Samarium", "Samarium", Materials.Samarium.mElement.name(), Utils.rgbtoHexValue(161, 168, 114));
}
- if (ItemUtils.getItemStackOfAmountFromOreDictNoBroken("dustLanthanum", 1) == null){
+ if (ItemUtils.checkForInvalidItems(ItemUtils.getItemStackOfAmountFromOreDictNoBroken("dustLanthanum", 1))){
ItemUtils.generateSpecialUseDusts("Lanthanum", "Lanthanum", Materials.Lanthanum.mElement.name(), Utils.rgbtoHexValue(106, 127, 163));
}
- if (ItemUtils.getItemStackOfAmountFromOreDictNoBroken("dustGermanium", 1) == null){
+ if (ItemUtils.checkForInvalidItems(ItemUtils.getItemStackOfAmountFromOreDictNoBroken("dustGermanium", 1))){
ItemUtils.generateSpecialUseDusts("Germanium", "Germanium", "Ge", ELEMENT.getInstance().GERMANIUM.getRgbAsHex());
}
@@ -621,8 +634,10 @@ public final class ModItems {
dustZrCl4 = ItemUtils.generateSpecialUseDusts("ZrCl4", "ZrCl4", "ZrCl4", Utils.rgbtoHexValue(180, 180, 180))[0]; //http://www.iaea.org/inis/collection/NCLCollectionStore/_Public/39/036/39036750.pdf
dustCookedZrCl4 = ItemUtils.generateSpecialUseDusts("CookedZrCl4", "Cooked ZrCl4", "ZrCl4", Utils.rgbtoHexValue(180, 180, 180))[0]; //http://www.iaea.org/inis/collection/NCLCollectionStore/_Public/39/036/39036750.pdf
//Zirconium Tetrafluoride
- GT_OreDictUnificator.registerOre("cellZrF4", ItemUtils.getItemStackOfAmountFromOreDict("cellZirconiumTetrafluoride", 1));
- GT_OreDictUnificator.registerOre("dustZrF4", ItemUtils.getItemStackOfAmountFromOreDict("dustZirconiumTetrafluoride", 1));
+ /*GT_OreDictUnificator.registerOre("cellZrF4", ItemUtils.getItemStackOfAmountFromOreDict("cellZirconiumTetrafluoride", 1));
+ GT_OreDictUnificator.registerOre("dustZrF4", ItemUtils.getItemStackOfAmountFromOreDict("dustZirconiumTetrafluoride", 1));*/
+ //GT_OreDictUnificator.registerOre("cellZrF4", ItemUtils.getItemStackOfAmountFromOreDict("cellZirconiumTetrafluoride", 1));
+ //GT_OreDictUnificator.registerOre("dustZrF4", ItemUtils.getItemStackOfAmountFromOreDict("dustZirconiumTetrafluoride", 1));
fluidZrF4 = FluidUtils.generateFluidNoPrefix("ZirconiumTetrafluoride", "Zirconium Tetrafluoride", 500, new short[]{170, 170, 140, 100}); //https://en.wikipedia.org/wiki/Zirconium_tetrafluoride
//Coolant Salt
@@ -684,7 +699,7 @@ public final class ModItems {
toolGregtechPump.registerPumpType(3, "Ultimate Hand Pump", 512000, 3);
//Create Multi-tools
- ItemsMultiTools.load();
+ //ItemsMultiTools.load();
//Xp Fluids - Dev
if (!FluidRegistry.isFluidRegistered("mobessence")){
@@ -731,7 +746,6 @@ public final class ModItems {
// A plate of Meat.
if (ItemUtils.getItemStackOfAmountFromOreDictNoBroken("plateMeatRaw", 1) == null){
itemPlateRawMeat = new BaseItemPlate(meatRaw);
- RecipeUtils.generateMortarRecipe(ItemUtils.getSimpleStack(itemPlateRawMeat), ItemUtils.getItemStackOfAmountFromOreDict("dustMeatRaw", 1));
ItemUtils.registerFuel(ItemUtils.getSimpleStack(itemPlateRawMeat), 100);
}
// A Block of Meat.
@@ -896,7 +910,10 @@ public final class ModItems {
//IC2 Exp
if (LoadedMods.IndustrialCraft2|| LOAD_ALL_CONTENT){
Logger.INFO("IndustrialCraft2 Found - Loading Resources.");
- RfEuBattery = new RF2EU_Battery();
+
+ if (LoadedMods.CoFHCore) {
+ RfEuBattery = new RF2EU_Battery();
+ }
//Baubles Mod Test
try {
diff --git a/src/Java/gtPlusPlus/core/item/base/BaseItemComponent.java b/src/Java/gtPlusPlus/core/item/base/BaseItemComponent.java
index b07815fa60..ec0b490f63 100644
--- a/src/Java/gtPlusPlus/core/item/base/BaseItemComponent.java
+++ b/src/Java/gtPlusPlus/core/item/base/BaseItemComponent.java
@@ -105,6 +105,7 @@ public class BaseItemComponent extends Item{
ItemStack x = aMap.get(aKey);
if (x == null) {
aMap.put(aKey, ItemUtils.getSimpleStack(this));
+ Logger.MATERIALS("Registering a material component. Item: ["+componentMaterial.getUnlocalizedName()+"] Map: ["+aKey+"]");
Material.mComponentMap.put(componentMaterial.getUnlocalizedName(), aMap);
return true;
}
diff --git a/src/Java/gtPlusPlus/core/item/base/dusts/BaseItemDustUnique.java b/src/Java/gtPlusPlus/core/item/base/dusts/BaseItemDustUnique.java
index df46dd2052..273995e181 100644
--- a/src/Java/gtPlusPlus/core/item/base/dusts/BaseItemDustUnique.java
+++ b/src/Java/gtPlusPlus/core/item/base/dusts/BaseItemDustUnique.java
@@ -2,18 +2,21 @@ package gtPlusPlus.core.item.base.dusts;
import static gtPlusPlus.core.creative.AddToCreativeTab.tabMisc;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import cpw.mods.fml.common.registry.GameRegistry;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
-
+import gregtech.api.enums.OrePrefixes;
import gregtech.api.util.GT_OreDictUnificator;
import gtPlusPlus.api.objects.Logger;
import gtPlusPlus.core.lib.CORE;
+import gtPlusPlus.core.material.Material;
import gtPlusPlus.core.util.data.StringUtils;
import gtPlusPlus.core.util.math.MathUtils;
import gtPlusPlus.core.util.minecraft.ItemUtils;
@@ -80,6 +83,32 @@ public class BaseItemDustUnique extends Item{
if ((temp != null) && !temp.equals("")){
GT_OreDictUnificator.registerOre(temp, ItemUtils.getSimpleStack(this));
}
+ registerComponent();
+ }
+
+ public boolean registerComponent() {
+ if (this.materialName == null) {
+ return false;
+ }
+ String aName = materialName;
+ //Register Component
+ Map<String, ItemStack> aMap = Material.mComponentMap.get(aName);
+ if (aMap == null) {
+ aMap = new HashMap<String, ItemStack>();
+ }
+ String aKey = OrePrefixes.dust.name();
+ ItemStack x = aMap.get(aKey);
+ if (x == null) {
+ aMap.put(aKey, ItemUtils.getSimpleStack(this));
+ Logger.MATERIALS("Registering a material component. Item: ["+aName+"] Map: ["+aKey+"]");
+ Material.mComponentMap.put(aName, aMap);
+ return true;
+ }
+ else {
+ //Bad
+ Logger.MATERIALS("Tried to double register a material component. ");
+ return false;
+ }
}
@Override
diff --git a/src/Java/gtPlusPlus/core/item/base/ore/BaseOreComponent.java b/src/Java/gtPlusPlus/core/item/base/ore/BaseOreComponent.java
index 08517776ec..2b3f477c56 100644
--- a/src/Java/gtPlusPlus/core/item/base/ore/BaseOreComponent.java
+++ b/src/Java/gtPlusPlus/core/item/base/ore/BaseOreComponent.java
@@ -1,6 +1,8 @@
package gtPlusPlus.core.item.base.ore;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
@@ -13,9 +15,9 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
-
+import gregtech.api.enums.OrePrefixes;
import gregtech.api.util.GT_OreDictUnificator;
-
+import gtPlusPlus.api.objects.Logger;
import gtPlusPlus.core.creative.AddToCreativeTab;
import gtPlusPlus.core.lib.CORE;
import gtPlusPlus.core.lib.LoadedMods;
@@ -52,6 +54,7 @@ public class BaseOreComponent extends Item{
//this.setTextureName(this.getCorrectTextures());
this.componentColour = material.getRgbAsHex();
GameRegistry.registerItem(this, this.unlocalName);
+ registerComponent();
GT_OreDictUnificator.registerOre(componentType.getComponent()+material.getUnlocalizedName(), ItemUtils.getSimpleStack(this));
if (LoadedMods.Thaumcraft) {
ThaumcraftUtils.addAspectToItem(ItemUtils.getSimpleStack(this), GTPP_Aspects.METALLUM, 2);
@@ -61,6 +64,51 @@ public class BaseOreComponent extends Item{
}
}
+
+ public boolean registerComponent() {
+ Logger.MATERIALS("Attempting to register "+this.getUnlocalizedName()+".");
+ if (this.componentMaterial == null) {
+ Logger.MATERIALS("Tried to register "+this.getUnlocalizedName()+" but the material was null.");
+ return false;
+ }
+ //Register Component
+ Map<String, ItemStack> aMap = Material.mComponentMap.get(componentMaterial.getUnlocalizedName());
+ if (aMap == null) {
+ aMap = new HashMap<String, ItemStack>();
+ }
+ String aKey = "Invalid";
+ if (componentType == ComponentTypes.CRUSHED) {
+ aKey = OrePrefixes.crushed.name();
+ }
+ else if (componentType == ComponentTypes.CRUSHEDCENTRIFUGED) {
+ aKey = OrePrefixes.crushedCentrifuged.name();
+ }
+ else if (componentType == ComponentTypes.CRUSHEDPURIFIED) {
+ aKey = OrePrefixes.crushedPurified.name();
+ }
+ else if (componentType == ComponentTypes.DUST) {
+ aKey = OrePrefixes.dust.name();
+ }
+ else if (componentType == ComponentTypes.DUSTIMPURE) {
+ aKey = OrePrefixes.dustImpure.name();
+ }
+ else if (componentType == ComponentTypes.DUSTPURE) {
+ aKey = OrePrefixes.dustPure.name();
+ }
+
+ ItemStack x = aMap.get(aKey);
+ if (x == null) {
+ aMap.put(aKey, ItemUtils.getSimpleStack(this));
+ Logger.MATERIALS("Registering a material component. Item: ["+componentMaterial.getUnlocalizedName()+"] Map: ["+aKey+"]");
+ Material.mComponentMap.put(componentMaterial.getUnlocalizedName(), aMap);
+ return true;
+ }
+ else {
+ //Bad
+ Logger.MATERIALS("Tried to double register a material component. ");
+ return false;
+ }
+ }
public String getCorrectTextures(){
if (!CORE.ConfigSwitches.useGregtechTextures){
diff --git a/src/Java/gtPlusPlus/core/item/base/rods/BaseItemRod.java b/src/Java/gtPlusPlus/core/item/base/rods/BaseItemRod.java
index f0a0f9f4ea..b6a5dff2ac 100644
--- a/src/Java/gtPlusPlus/core/item/base/rods/BaseItemRod.java
+++ b/src/Java/gtPlusPlus/core/item/base/rods/BaseItemRod.java
@@ -7,6 +7,7 @@ import gregtech.api.enums.GT_Values;
import gtPlusPlus.api.objects.Logger;
import gtPlusPlus.core.item.base.BaseItemComponent;
import gtPlusPlus.core.material.Material;
+import gtPlusPlus.core.util.minecraft.ItemUtils;
public class BaseItemRod extends BaseItemComponent{
@@ -22,6 +23,7 @@ public class BaseItemRod extends BaseItemComponent{
final ItemStack stackStick = this.componentMaterial.getRod(1);
final ItemStack stackBolt = this.componentMaterial.getBolt(4);
+ if (ItemUtils.checkForInvalidItems(new ItemStack[] {stackStick, stackBolt}))
GT_Values.RA.addCutterRecipe(
stackStick,
stackBolt,
diff --git a/src/Java/gtPlusPlus/core/item/base/rods/BaseItemRodLong.java b/src/Java/gtPlusPlus/core/item/base/rods/BaseItemRodLong.java
index 0870683c46..9b232f95c5 100644
--- a/src/Java/gtPlusPlus/core/item/base/rods/BaseItemRodLong.java
+++ b/src/Java/gtPlusPlus/core/item/base/rods/BaseItemRodLong.java
@@ -24,23 +24,20 @@ public class BaseItemRodLong extends BaseItemComponent{
private void addExtruderRecipe(){
Logger.WARNING("Adding recipe for Long "+this.materialName+" Rods");
- final String tempStick = this.unlocalName.replace("itemRodLong", "stick");
- final String tempStickLong = this.unlocalName.replace("itemRodLong", "stickLong");
- final ItemStack stackStick = ItemUtils.getItemStackOfAmountFromOreDict(tempStick, 1);
- final ItemStack stackLong = ItemUtils.getItemStackOfAmountFromOreDict(tempStickLong, 1);
-
- final ItemStack temp = stackStick;
- temp.stackSize = 2;
+ final ItemStack stackStick = this.componentMaterial.getRod(2);
+ final ItemStack stackLong = this.componentMaterial.getLongRod(1);
+ if (ItemUtils.checkForInvalidItems(new ItemStack[] {stackStick, stackLong}))
GT_Values.RA.addForgeHammerRecipe(
- temp,
+ stackStick,
stackLong,
(int) Math.max(this.componentMaterial.getMass(), 1L),
16);
+ if (ItemUtils.checkForInvalidItems(new ItemStack[] {stackStick, stackLong}))
GT_Values.RA.addCutterRecipe(
stackLong,
- temp,
+ stackStick,
null,
(int) Math.max(this.componentMaterial.getMass(), 1L),
4);
diff --git a/src/Java/gtPlusPlus/core/item/tool/misc/box/AutoLunchBox.java b/src/Java/gtPlusPlus/core/item/tool/misc/box/AutoLunchBox.java
new file mode 100644
index 0000000000..baed16db03
--- /dev/null
+++ b/src/Java/gtPlusPlus/core/item/tool/misc/box/AutoLunchBox.java
@@ -0,0 +1,11 @@
+package gtPlusPlus.core.item.tool.misc.box;
+
+public class AutoLunchBox extends BaseBoxItem {
+
+ public final static int SLOTS = 9;
+
+ public AutoLunchBox(String displayName) {
+ super(displayName, new String[] {"Stores 9 pieces of food", "Food will automatically be eaten from slot 1, through to "+gtPlusPlus.core.item.tool.misc.box.AutoLunchBox.SLOTS}, gtPlusPlus.core.item.tool.misc.box.AutoLunchBox.SLOTS);
+ }
+
+}
diff --git a/src/Java/gtPlusPlus/core/item/tool/misc/box/BaseBoxItem.java b/src/Java/gtPlusPlus/core/item/tool/misc/box/BaseBoxItem.java
new file mode 100644
index 0000000000..10a3ae5804
--- /dev/null
+++ b/src/Java/gtPlusPlus/core/item/tool/misc/box/BaseBoxItem.java
@@ -0,0 +1,59 @@
+package gtPlusPlus.core.item.tool.misc.box;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import gtPlusPlus.GTplusplus;
+import gtPlusPlus.core.creative.AddToCreativeTab;
+import gtPlusPlus.core.item.base.CoreItem;
+import gtPlusPlus.core.lib.CORE;
+import gtPlusPlus.core.util.Utils;
+import net.minecraft.client.renderer.texture.IIconRegister;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.EnumRarity;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.EnumChatFormatting;
+import net.minecraft.world.World;
+
+public class BaseBoxItem extends CoreItem {
+
+ private final int GUI;
+
+ public BaseBoxItem(String displayName, String[] description, int GUI_ID) {
+ super("item." + Utils.sanitizeString(displayName), displayName, AddToCreativeTab.tabTools, 1, 0,
+ modifyDescriptionStringArray(description), EnumRarity.uncommon, EnumChatFormatting.GRAY, false, null);
+ GUI = GUI_ID;
+ }
+
+ private static String[] modifyDescriptionStringArray(String[] array) {
+ String[] a = new String[array.length + 1];
+ for (int b = 0; b < array.length; b++) {
+ a[b] = array[b];
+ }
+ a[a.length - 1] = "Right Click to open";
+ return a;
+ }
+
+ // Without this method, your inventory will NOT work!!!
+ @Override
+ public int getMaxItemUseDuration(ItemStack stack) {
+ return 1; // return any value greater than zero
+ }
+
+ @Override
+ public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer player) {
+ if (!world.isRemote) {
+ // If player not sneaking, open the inventory gui
+ if (!player.isSneaking()) {
+ player.openGui(GTplusplus.instance, GUI, world, (int) player.posX, (int) player.posY,
+ (int) player.posZ);
+ }
+ }
+ return itemstack;
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void registerIcons(IIconRegister iconRegister) {
+ this.itemIcon = iconRegister.registerIcon(CORE.MODID + ":" + this.getUnlocalizedName().substring(5));
+ }
+}
diff --git a/src/Java/gtPlusPlus/core/item/tool/misc/box/ContainerBoxBase.java b/src/Java/gtPlusPlus/core/item/tool/misc/box/ContainerBoxBase.java
new file mode 100644
index 0000000000..035859c388
--- /dev/null
+++ b/src/Java/gtPlusPlus/core/item/tool/misc/box/ContainerBoxBase.java
@@ -0,0 +1,328 @@
+package gtPlusPlus.core.item.tool.misc.box;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+
+import gregtech.api.enums.Materials;
+import gregtech.api.metatileentity.implementations.GT_MetaPipeEntity_Fluid;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.entity.player.InventoryPlayer;
+import net.minecraft.inventory.Container;
+import net.minecraft.inventory.IInventory;
+import net.minecraft.inventory.Slot;
+import net.minecraft.item.ItemStack;
+
+public class ContainerBoxBase extends Container {
+
+ /*
+ * Finally, in your Container class, you will need to check if the currently
+ * opened inventory's uniqueID is equal to the itemstack's uniqueID in the
+ * method 'transferStackInSlot' as well as check if the itemstack is the
+ * currently equipped item in the method 'slotClick'. In both cases, you'll need
+ * to prevent the itemstack from being moved or it will cause bad things to
+ * happen.
+ */
+
+ /**
+ * Step 3: Create a custom Container for your Inventory
+ */
+
+ /*
+ * There's a LOT of code in this one, but read through all of the comments
+ * carefully and it should become clear what everything does. As a bonus, one of
+ * my previous tutorials is included within!
+ * "How to Properly Override Shift-Clicking" is here and better than ever! At
+ * least in my opinion. If you're like me, and you find no end of frustration
+ * trying to figure out which f-ing index you should use for which slots in your
+ * container when overriding transferStackInSlot, or if your following the
+ * original tutorial, then read on.
+ */
+
+ /**
+ * The Item Inventory for this Container, only needed if you want to reference
+ * isUseableByPlayer
+ */
+ private final CustomBoxInventory inventory;
+ /**
+ * 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
+ * CustomBoxInventory'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 CustomBoxInventory.INV_SIZE and if we ever change it, the
+ * Container updates automatically.
+ */
+ private final int INV_START, INV_END, HOTBAR_START, HOTBAR_END;
+
+ // If you're planning to add armor slots, put those first like this:
+ // ARMOR_START = CustomBoxInventory.INV_SIZE, ARMOR_END = ARMOR_START+3,
+ // INV_START = ARMOR_END+1, and then carry on like above.
+
+ private Slot generateSlot(final Constructor<?> aClazz, final IInventory base, final int id, final int x,
+ final int y) {
+ Slot aSlot;
+ try {
+ aSlot = (Slot) aClazz.newInstance(base, id, x, y);
+ if (aSlot != null) {
+ return aSlot;
+ }
+ } catch (InstantiationException | IllegalAccessException | IllegalArgumentException
+ | InvocationTargetException e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ public ContainerBoxBase(EntityPlayer par1Player, InventoryPlayer inventoryPlayer,
+ CustomBoxInventory CustomBoxInventory, Class<?> aClazz, int aSlotCount) {
+
+ INV_START = aSlotCount;
+ INV_END = INV_START + 26;
+ HOTBAR_START = INV_END + 1;
+ HOTBAR_END = HOTBAR_START + 8;
+
+ this.inventory = CustomBoxInventory;
+ try {
+
+ Constructor<?> constructor;
+ constructor = aClazz.getConstructor(IInventory.class, int.class, int.class, int.class);
+
+ int i;
+
+ // ITEM INVENTORY - you'll need to adjust the slot locations to match your
+ // texture file
+ // I have them set vertically in columns of 4 to the right of the player model
+ for (i = 0; i < CustomBoxInventory.INV_SIZE; ++i) {
+ // You can make a custom Slot if you need different behavior,
+ // such as only certain item types can be put into this slot
+ // We made a custom slot to prevent our inventory-storing item
+ // from being stored within itself, but if you want to allow that and
+ // you followed my advice at the end of the above step, then you
+ // could get away with using the vanilla Slot class
+ this.addSlotToContainer(generateSlot(constructor, this.getInventoryObject(), i,
+ 80 + (18 * (int) (i / 4)), 8 + (18 * (i % 4))));
+ }
+
+ // If you want, you can add ARMOR SLOTS here as well, but you need to
+ // make a public version of SlotArmor. I won't be doing that in this tutorial.
+ /*
+ * for (i = 0; i < 4; ++i) { // These are the standard positions for survival
+ * inventory layout this.addSlotToContainer(new SlotArmor(this.player,
+ * inventoryPlayer, inventoryPlayer.getSizeInventory() - 1 - i, 8, 8 + i * 18,
+ * i)); }
+ */
+
+ // PLAYER INVENTORY - uses default locations for standard inventory texture file
+ for (i = 0; i < 3; ++i) {
+ for (int j = 0; j < 9; ++j) {
+ this.addSlotToContainer(new Slot(inventoryPlayer, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
+ }
+ }
+
+ // 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));
+ }
+
+ } catch (NoSuchMethodException | SecurityException e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ public boolean canInteractWith(EntityPlayer entityplayer) {
+ // be sure to return the inventory's isUseableByPlayer method
+ // if you defined special behavior there:
+ return getInventoryObject().isUseableByPlayer(entityplayer);
+ }
+
+ /**
+ * Called when a player shift-clicks on a slot. You must override this or you
+ * will crash when someone does that.
+ */
+ public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int index) {
+ ItemStack itemstack = null;
+ Slot slot = (Slot) this.inventorySlots.get(index);
+
+ if (slot != null && slot.getHasStack()) {
+ ItemStack itemstack1 = slot.getStack();
+ itemstack = itemstack1.copy();
+
+ // If item is in our custom Inventory or armor slot
+ if (index < INV_START) {
+ // try to place in player inventory / action bar
+ 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
+ * 'CustomBoxInventory.INV_SIZE' instead of INV_START just in case // you also
+ * add armor or other custom slots if (!this.mergeItemStack(itemstack1, 0,
+ * CustomBoxInventory.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) {
+ // place in custom inventory
+ 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) {
+ // place in action bar
+ 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)) {
+ return null;
+ }
+ }
+ }
+
+ if (itemstack1.stackSize == 0) {
+ slot.putStack((ItemStack) null);
+ } else {
+ slot.onSlotChanged();
+ }
+
+ if (itemstack1.stackSize == itemstack.stackSize) {
+ return null;
+ }
+
+ slot.onPickupFromSlot(par1EntityPlayer, itemstack1);
+ }
+
+ return itemstack;
+ }
+
+ /**
+ * 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(int slot, int button, int flag, EntityPlayer player) {
+ // this will prevent the player from interacting with the item that opened the
+ // inventory:
+ if (slot >= 0 && getSlot(slot) != null && getSlot(slot).getStack() == player.getHeldItem()) {
+ return null;
+ }
+ return super.slotClick(slot, button, flag, player);
+ }
+
+ /*
+ * Special note: If your custom inventory's stack limit is 1 and you allow
+ * shift-clicking itemstacks into it, you will need to override mergeStackInSlot
+ * to avoid losing all the items but one in a stack when you shift-click.
+ */
+ /**
+ * Vanilla mergeItemStack method doesn't correctly handle inventories whose max
+ * stack size is 1 when you shift-click into the inventory. This is a modified
+ * method I wrote to handle such cases. Note you only need it if your slot /
+ * inventory's max stack size is 1
+ */
+ @Override
+ protected boolean mergeItemStack(ItemStack stack, int start, int end, boolean backwards) {
+ boolean flag1 = false;
+ int k = (backwards ? end - 1 : start);
+ Slot slot;
+ ItemStack itemstack1;
+
+ if (stack.isStackable()) {
+ while (stack.stackSize > 0 && (!backwards && k < end || backwards && k >= start)) {
+ slot = (Slot) inventorySlots.get(k);
+ itemstack1 = slot.getStack();
+
+ if (!slot.isItemValid(stack)) {
+ k += (backwards ? -1 : 1);
+ continue;
+ }
+
+ if (itemstack1 != null && itemstack1.getItem() == stack.getItem()
+ && (!stack.getHasSubtypes() || stack.getItemDamage() == itemstack1.getItemDamage())
+ && ItemStack.areItemStackTagsEqual(stack, itemstack1)) {
+ int l = itemstack1.stackSize + stack.stackSize;
+
+ if (l <= stack.getMaxStackSize() && l <= slot.getSlotStackLimit()) {
+ stack.stackSize = 0;
+ itemstack1.stackSize = l;
+ getInventoryObject().markDirty();
+ flag1 = true;
+ } else if (itemstack1.stackSize < stack.getMaxStackSize() && l < slot.getSlotStackLimit()) {
+ stack.stackSize -= stack.getMaxStackSize() - itemstack1.stackSize;
+ itemstack1.stackSize = stack.getMaxStackSize();
+ getInventoryObject().markDirty();
+ flag1 = true;
+ }
+ }
+
+ k += (backwards ? -1 : 1);
+ }
+ }
+ if (stack.stackSize > 0) {
+ k = (backwards ? end - 1 : start);
+ while (!backwards && k < end || backwards && k >= start) {
+ slot = (Slot) inventorySlots.get(k);
+ itemstack1 = slot.getStack();
+
+ if (!slot.isItemValid(stack)) {
+ k += (backwards ? -1 : 1);
+ continue;
+ }
+
+ if (itemstack1 == null) {
+ int l = stack.stackSize;
+ if (l <= slot.getSlotStackLimit()) {
+ slot.putStack(stack.copy());
+ stack.stackSize = 0;
+ getInventoryObject().markDirty();
+ flag1 = true;
+ break;
+ } else {
+ putStackInSlot(k,
+ new ItemStack(stack.getItem(), slot.getSlotStackLimit(), stack.getItemDamage()));
+ stack.stackSize -= slot.getSlotStackLimit();
+ getInventoryObject().markDirty();
+ flag1 = true;
+ }
+ }
+
+ k += (backwards ? -1 : 1);
+ }
+ }
+
+ return flag1;
+ }
+
+ public CustomBoxInventory getInventoryObject() {
+ return inventory;
+ }
+} \ No newline at end of file
diff --git a/src/Java/gtPlusPlus/core/item/tool/misc/box/CustomBoxInventory.java b/src/Java/gtPlusPlus/core/item/tool/misc/box/CustomBoxInventory.java
new file mode 100644
index 0000000000..0737e463d8
--- /dev/null
+++ b/src/Java/gtPlusPlus/core/item/tool/misc/box/CustomBoxInventory.java
@@ -0,0 +1,243 @@
+package gtPlusPlus.core.item.tool.misc.box;
+
+import java.util.UUID;
+
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.IInventory;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.nbt.NBTTagList;
+import net.minecraftforge.common.util.Constants;
+
+public abstract class CustomBoxInventory implements IInventory {
+
+ private final String name;
+ protected String uniqueID;
+
+ /** Provides NBT Tag Compound to reference */
+ private final ItemStack invItem;
+
+ /** Defining your inventory size this way is handy */
+ public final int INV_SIZE;
+
+ /** Inventory's size must be same as number of slots you add to the Container class */
+ private ItemStack[] inventory;
+
+ /**
+ * @param itemstack - the ItemStack to which this inventory belongs
+ */
+ public CustomBoxInventory(ItemStack stack, String name2){
+ this(stack, name2, 8);
+ }
+
+ /**
+ * @param itemstack - the ItemStack to which this inventory belongs
+ */
+ public CustomBoxInventory(ItemStack stack, String name2, int slots)
+ {
+ invItem = stack;
+ name = name2;
+ INV_SIZE = slots;
+ inventory = new ItemStack[INV_SIZE];
+
+ /** initialize variable within the constructor: */
+ uniqueID = "";
+
+ if (!stack.hasTagCompound())
+ {
+ stack.setTagCompound(new NBTTagCompound());
+ // no tag compound means the itemstack does not yet have a UUID, so assign one:
+ uniqueID = UUID.randomUUID().toString();
+ }
+
+ /** When reading from NBT: */
+ if ("".equals(uniqueID))
+ {
+ // try to read unique ID from NBT
+ uniqueID = stack.getTagCompound().getString("uniqueID");
+ // if it's still "", assign a new one:
+ if ("".equals(uniqueID))
+ {
+ uniqueID = UUID.randomUUID().toString();
+ }
+ }
+
+ /** Writing to NBT: */
+ // just add this line:
+ stack.getTagCompound().setString("uniqueID", this.uniqueID);
+
+ // note that it's okay to use stack instead of invItem right there
+ // both reference the same memory location, so whatever you change using
+ // either reference will change in the other
+
+ // Read the inventory contents from NBT
+ readFromNBT(stack.getTagCompound());
+ }
+
+ @Override
+ public int getSizeInventory()
+ {
+ return inventory.length;
+ }
+
+ @Override
+ public ItemStack getStackInSlot(int slot)
+ {
+ return inventory[slot];
+ }
+
+ @Override
+ public ItemStack decrStackSize(int slot, int amount)
+ {
+ ItemStack stack = getStackInSlot(slot);
+ if(stack != null)
+ {
+ if(stack.stackSize > amount)
+ {
+ stack = stack.splitStack(amount);
+ // Don't forget this line or your inventory will not be saved!
+ markDirty();
+ }
+ else
+ {
+ // this method also calls onInventoryChanged, so we don't need to call it again
+ setInventorySlotContents(slot, null);
+ }
+ }
+ return stack;
+ }
+
+ @Override
+ public ItemStack getStackInSlotOnClosing(int slot)
+ {
+ ItemStack stack = getStackInSlot(slot);
+ setInventorySlotContents(slot, null);
+ return stack;
+ }
+
+ @Override
+ public void setInventorySlotContents(int slot, ItemStack stack)
+ {
+ inventory[slot] = stack;
+
+ if (stack != null && stack.stackSize > getInventoryStackLimit())
+ {
+ stack.stackSize = getInventoryStackLimit();
+ }
+
+ // Don't forget this line or your inventory will not be saved!
+ markDirty();
+ }
+
+ // 1.7.2+ renamed to getInventoryName
+ @Override
+ public String getInventoryName()
+ {
+ return name;
+ }
+
+ // 1.7.2+ renamed to hasCustomInventoryName
+ @Override
+ public boolean hasCustomInventoryName()
+ {
+ return name.length() > 0;
+ }
+
+ @Override
+ public int getInventoryStackLimit()
+ {
+ return 64;
+ }
+
+ /**
+ * 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 < getSizeInventory(); ++i)
+ {
+ if (getStackInSlot(i) != null && getStackInSlot(i).stackSize == 0) {
+ inventory[i] = null;
+ }
+ }
+
+ // This line here does the work:
+ writeToNBT(invItem.getTagCompound());
+ }
+
+ @Override
+ public boolean isUseableByPlayer(EntityPlayer entityplayer)
+ {
+ return true;
+ }
+
+ // 1.7.2+ renamed to openInventory(EntityPlayer player)
+ @Override
+ public void openInventory() {}
+
+ // 1.7.2+ renamed to closeInventory(EntityPlayer player)
+ @Override
+ 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
+ */
+ @Override
+ public abstract boolean isItemValidForSlot(int slot, ItemStack itemstack);
+
+ /**
+ * A custom method to read our inventory from an ItemStack's NBT compound
+ */
+ public void readFromNBT(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);
+ NBTTagList items = compound.getTagList("ItemInventory", Constants.NBT.TAG_COMPOUND);
+
+ for (int i = 0; i < items.tagCount(); ++i)
+ {
+ // 1.7.2+ change to items.getCompoundTagAt(i)
+ NBTTagCompound item = (NBTTagCompound) items.getCompoundTagAt(i);
+ int slot = item.getInteger("Slot");
+
+ // Just double-checking that the saved slot index is within our inventory array bounds
+ if (slot >= 0 && slot < getSizeInventory()) {
+ inventory[slot] = ItemStack.loadItemStackFromNBT(item);
+ }
+ }
+ }
+
+ /**
+ * A custom method to write our inventory to an ItemStack's NBT compound
+ */
+ public void writeToNBT(NBTTagCompound tagcompound)
+ {
+ // Create a new NBT Tag List to store itemstacks as NBT Tags
+ NBTTagList items = new NBTTagList();
+
+ for (int i = 0; i < getSizeInventory(); ++i)
+ {
+ // Only write stacks that contain items
+ if (getStackInSlot(i) != null)
+ {
+ // Make a new NBT Tag Compound to write the itemstack and slot index to
+ NBTTagCompound item = new NBTTagCompound();
+ item.setInteger("Slot", i);
+ // Writes the itemstack in slot(i) to the Tag Compound we just made
+ getStackInSlot(i).writeToNBT(item);
+
+ // add the tag compound to our tag list
+ items.appendTag(item);
+ }
+ }
+ // Add the TagList to the ItemStack's Tag Compound with the name "ItemInventory"
+ tagcompound.setTag("ItemInventory", items);
+ }
+
+}
diff --git a/src/Java/gtPlusPlus/core/item/tool/misc/box/MagicToolBag.java b/src/Java/gtPlusPlus/core/item/tool/misc/box/MagicToolBag.java
new file mode 100644
index 0000000000..65b884bd51
--- /dev/null
+++ b/src/Java/gtPlusPlus/core/item/tool/misc/box/MagicToolBag.java
@@ -0,0 +1,11 @@
+package gtPlusPlus.core.item.tool.misc.box;
+
+public class MagicToolBag extends BaseBoxItem {
+
+ public final static int SLOTS = 24;
+
+ public MagicToolBag(String displayName) {
+ super(displayName, new String[] {"Can store magic tools from TC, BM, etc", "Please ask for additional mod support on Github"}, gtPlusPlus.core.item.tool.misc.box.MagicToolBag.SLOTS);
+ }
+
+}
diff --git a/src/Java/gtPlusPlus/core/item/tool/misc/box/UniversalToolBox.java b/src/Java/gtPlusPlus/core/item/tool/misc/box/UniversalToolBox.java
new file mode 100644
index 0000000000..92b1382e01
--- /dev/null
+++ b/src/Java/gtPlusPlus/core/item/tool/misc/box/UniversalToolBox.java
@@ -0,0 +1,13 @@
+package gtPlusPlus.core.item.tool.misc.box;
+
+import gtPlusPlus.core.handler.GuiHandler;
+
+public class UniversalToolBox extends BaseBoxItem {
+
+ public final static int SLOTS = 16;
+
+ public UniversalToolBox(String displayName) {
+ super(displayName, new String[] {"Can store tools from Gregtech, IC2, BC, Forestry", "Please ask for additional mod support on Github"}, GuiHandler.GUI10);
+ }
+
+}