aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gtPlusPlus/core/item
diff options
context:
space:
mode:
authormiozune <miozune@gmail.com>2023-10-17 13:37:11 +0900
committermiozune <miozune@gmail.com>2023-10-17 17:39:55 +0900
commit325a5f154e8d8d7dac6c03deb632a0041b3d69ca (patch)
tree323c840a7478f6550ce6fac4606589a24f440f89 /src/main/java/gtPlusPlus/core/item
parent6f27cb977e0ff601a540e9dbfd3d7565d0b05273 (diff)
downloadGT5-Unofficial-325a5f154e8d8d7dac6c03deb632a0041b3d69ca.tar.gz
GT5-Unofficial-325a5f154e8d8d7dac6c03deb632a0041b3d69ca.tar.bz2
GT5-Unofficial-325a5f154e8d8d7dac6c03deb632a0041b3d69ca.zip
Remove unused classes
Diffstat (limited to 'src/main/java/gtPlusPlus/core/item')
-rw-r--r--src/main/java/gtPlusPlus/core/item/base/BaseEuItem.java636
-rw-r--r--src/main/java/gtPlusPlus/core/item/base/dusts/BaseItemDustAbstract.java43
-rw-r--r--src/main/java/gtPlusPlus/core/item/base/dusts/decimal/BaseItemCentidust.java57
-rw-r--r--src/main/java/gtPlusPlus/core/item/base/dusts/decimal/BaseItemDecidust.java57
-rw-r--r--src/main/java/gtPlusPlus/core/item/base/foods/BaseItemFood.java45
-rw-r--r--src/main/java/gtPlusPlus/core/item/base/foods/BaseItemHotFood.java84
-rw-r--r--src/main/java/gtPlusPlus/core/item/base/itemblock/FluidItemBlock.java60
-rw-r--r--src/main/java/gtPlusPlus/core/item/base/itemblock/ItemBlockDoor.java101
-rw-r--r--src/main/java/gtPlusPlus/core/item/base/itemblock/ItemBlockGtFrameBox.java91
-rw-r--r--src/main/java/gtPlusPlus/core/item/base/itemblock/ItemBlockNBT.java96
-rw-r--r--src/main/java/gtPlusPlus/core/item/tool/misc/box/BaseBoxItem.java75
-rw-r--r--src/main/java/gtPlusPlus/core/item/tool/misc/box/ContainerBoxBase.java314
-rw-r--r--src/main/java/gtPlusPlus/core/item/tool/misc/box/CustomBoxInventory.java216
13 files changed, 0 insertions, 1875 deletions
diff --git a/src/main/java/gtPlusPlus/core/item/base/BaseEuItem.java b/src/main/java/gtPlusPlus/core/item/base/BaseEuItem.java
deleted file mode 100644
index 194e585c0d..0000000000
--- a/src/main/java/gtPlusPlus/core/item/base/BaseEuItem.java
+++ /dev/null
@@ -1,636 +0,0 @@
-package gtPlusPlus.core.item.base;
-
-import static gregtech.api.enums.GT_Values.D1;
-import static gregtech.api.enums.GT_Values.V;
-import static gregtech.api.enums.Mods.GTPlusPlus;
-
-import java.util.ArrayList;
-import java.util.BitSet;
-import java.util.HashMap;
-import java.util.List;
-
-import net.minecraft.client.renderer.texture.IIconRegister;
-import net.minecraft.creativetab.CreativeTabs;
-import net.minecraft.entity.EntityLivingBase;
-import net.minecraft.entity.player.EntityPlayer;
-import net.minecraft.inventory.Container;
-import net.minecraft.item.EnumRarity;
-import net.minecraft.item.Item;
-import net.minecraft.item.ItemStack;
-import net.minecraft.nbt.NBTTagCompound;
-import net.minecraft.util.EnumChatFormatting;
-import net.minecraft.util.IIcon;
-import net.minecraft.util.StatCollector;
-
-import cpw.mods.fml.common.registry.GameRegistry;
-import cpw.mods.fml.relauncher.Side;
-import cpw.mods.fml.relauncher.SideOnly;
-import gregtech.api.GregTech_API;
-import gregtech.api.enums.GT_Values;
-import gregtech.api.enums.SubTag;
-import gregtech.api.enums.TC_Aspects.TC_AspectStack;
-import gregtech.api.interfaces.IItemBehaviour;
-import gregtech.api.interfaces.IItemContainer;
-import gregtech.api.objects.ItemData;
-import gregtech.api.util.GT_LanguageManager;
-import gregtech.api.util.GT_ModHandler;
-import gregtech.api.util.GT_OreDictUnificator;
-import gregtech.api.util.GT_Utility;
-import gtPlusPlus.api.objects.data.Pair;
-import gtPlusPlus.core.creative.AddToCreativeTab;
-import ic2.api.item.ElectricItem;
-import ic2.api.item.IElectricItem;
-import ic2.api.item.IElectricItemManager;
-import ic2.api.item.ISpecialElectricItem;
-
-public class BaseEuItem extends Item implements ISpecialElectricItem, IElectricItemManager {
-
- /* ---------- CONSTRUCTOR AND MEMBER VARIABLES ---------- */
- private final HashMap<Short, ArrayList<IItemBehaviour<BaseEuItem>>> mItemBehaviors = new HashMap<>();
- public final short mOffset, mItemAmount;
- public final BitSet mEnabledItems;
- public final BitSet mVisibleItems;
- public final IIcon[][] mIconList;
- /** The unlocalized name of this item. */
- private String unlocalizedName;
-
- private final ArrayList<Pair<Integer, EnumRarity>> rarity = new ArrayList<>();
- private final ArrayList<Pair<Integer, EnumChatFormatting>> descColour = new ArrayList<>();
- private final ArrayList<Pair<Integer, String>> itemName = new ArrayList<>();
- private final ArrayList<Pair<Integer, String>> itemDescription = new ArrayList<>();
- private final ArrayList<Pair<Integer, Boolean>> hasEffect = new ArrayList<>();
-
- public final HashMap<Short, Long[]> mElectricStats = new HashMap<>();
- public final HashMap<Short, Short> mBurnValues = new HashMap<>();
-
- public BaseEuItem() {
- this("MU-metaitem.02", AddToCreativeTab.tabOther, (short) 1000, (short) 31766);
- }
-
- public BaseEuItem(final String unlocalizedName, final CreativeTabs creativeTab, final short aOffset,
- final short aItemAmount) {
- this.mEnabledItems = new BitSet(aItemAmount);
- this.mVisibleItems = new BitSet(aItemAmount);
- this.mOffset = (short) Math.min(32766, aOffset);
- this.mItemAmount = (short) Math.min(aItemAmount, 32766 - this.mOffset);
- this.mIconList = new IIcon[aItemAmount][1];
- this.setHasSubtypes(true);
- this.setMaxDamage(0);
- this.setUnlocalizedName(unlocalizedName);
- this.setCreativeTab(creativeTab);
- this.setMaxStackSize(1);
- GameRegistry.registerItem(this, unlocalizedName);
- }
-
- public void registerItem(final int id, final String localizedName, final long euStorage, final int tier,
- final String description) {
- this.registerItem(
- id,
- localizedName,
- euStorage,
- (short) tier,
- description,
- EnumRarity.common,
- EnumChatFormatting.GRAY,
- false);
- }
-
- public void registerItem(final int id, final String localizedName, final long euStorage, final int tier,
- final String description, final int burnTime) {
- this.registerItem(
- id,
- localizedName,
- euStorage,
- (short) tier,
- description,
- EnumRarity.common,
- EnumChatFormatting.GRAY,
- false);
- this.setBurnValue(id, burnTime);
- }
-
- public void registerItem(final int id, final String localizedName, final long euStorage, final short tier,
- final String description, final EnumRarity regRarity, final EnumChatFormatting colour,
- final boolean Effect) {
- this.addItem(id, localizedName, colour + description, new Object[] {});
- this.setElectricStats(this.mOffset + id, euStorage, GT_Values.V[tier], tier, -3L, true);
- this.rarity.add(new Pair<>(id, regRarity));
- this.hasEffect.add(new Pair<>(id, Effect));
- }
-
- @Override
- @SideOnly(Side.CLIENT)
- public EnumRarity getRarity(final ItemStack par1ItemStack) {
- if (this.rarity.get(par1ItemStack.getItemDamage() - this.mOffset) != null) {
- return this.rarity.get(par1ItemStack.getItemDamage() - this.mOffset).getValue();
- }
- return EnumRarity.common;
- }
-
- @Override
- public boolean hasEffect(final ItemStack par1ItemStack, final int pass) {
- if (this.hasEffect.get(par1ItemStack.getItemDamage() - this.mOffset) != null) {
- return this.hasEffect.get(par1ItemStack.getItemDamage() - this.mOffset).getValue();
- }
- return false;
- }
-
- @SuppressWarnings({ "unchecked", "rawtypes" })
- @Override
- public void addInformation(final ItemStack aStack, final EntityPlayer aPlayer, List aList, final boolean aF3_H) {
- // aList.add("Meta: "+(aStack.getItemDamage()-mOffset));
- int keyValue = aStack.getItemDamage() - this.mOffset;
- final String tKey = "gtplusplus." + this.getUnlocalizedName(aStack) + "." + keyValue + ".tooltip",
- tString = GT_LanguageManager.getTranslation(tKey);
- if (GT_Utility.isStringValid(tString) && !tKey.equals(tString)) {
- aList.add(tString);
- }
- aList.add(StatCollector.translateToLocal("item.itemBaseEuItem.tooltip.0"));
- final Long[] tStats = this.getElectricStats(aStack);
- if (tStats != null) {
- if (tStats[3] > 0) {
- aList.add(
- EnumChatFormatting.AQUA + StatCollector.translateToLocalFormatted(
- "item.itemBaseEuItem.tooltip.1",
- GT_Utility.formatNumbers(tStats[3]),
- (tStats[2] >= 0 ? tStats[2] : 0)) + EnumChatFormatting.GRAY);
- } else {
- final long tCharge = this.getRealCharge(aStack);
- if ((tStats[3] == -2) && (tCharge <= 0)) {
- aList.add(
- EnumChatFormatting.AQUA + StatCollector.translateToLocal("item.itemBaseEuItem.tooltip.2")
- + EnumChatFormatting.GRAY);
- } else {
- aList.add(
- EnumChatFormatting.AQUA + StatCollector.translateToLocalFormatted(
- "item.itemBaseEuItem.tooltip.3",
- GT_Utility.formatNumbers(tCharge),
- GT_Utility.formatNumbers(Math.abs(tStats[0])),
- V[(int) (tStats[2] >= 0 ? tStats[2] < V.length ? tStats[2] : V.length - 1 : 1)])
- + EnumChatFormatting.GRAY);
- }
- }
- }
- final ArrayList<IItemBehaviour<BaseEuItem>> tList = this.mItemBehaviors.get((short) this.getDamage(aStack));
- if (tList != null) {
- for (final IItemBehaviour<BaseEuItem> tBehavior : tList) {
- aList = tBehavior.getAdditionalToolTips(this, aList, aStack);
- }
- }
- }
-
- @Override
- public final Item getChargedItem(final ItemStack itemStack) {
- return this;
- }
-
- @Override
- public final Item getEmptyItem(final ItemStack itemStack) {
- return this;
- }
-
- @Override
- public final double getMaxCharge(final ItemStack aStack) {
- final Long[] tStats = this.getElectricStats(aStack);
- if (tStats == null) {
- return 0;
- }
- return Math.abs(tStats[0]);
- }
-
- @Override
- public final double getTransferLimit(final ItemStack aStack) {
- final Long[] tStats = this.getElectricStats(aStack);
- if (tStats == null) {
- return 0;
- }
- return Math.max(tStats[1], tStats[3]);
- }
-
- @Override
- public final int getTier(final ItemStack aStack) {
- final Long[] tStats = this.getElectricStats(aStack);
- return (int) (tStats == null ? Integer.MAX_VALUE : tStats[2]);
- }
-
- @Override
- public final double charge(final ItemStack aStack, final double aCharge, final int aTier,
- final boolean aIgnoreTransferLimit, final boolean aSimulate) {
- final Long[] tStats = this.getElectricStats(aStack);
- if ((tStats == null) || (tStats[2] > aTier)
- || !((tStats[3] == -1) || (tStats[3] == -3) || ((tStats[3] < 0) && (aCharge == Integer.MAX_VALUE)))
- || (aStack.stackSize != 1)) {
- return 0;
- }
- final long tChargeBefore = this.getRealCharge(aStack), tNewCharge = aCharge == Integer.MAX_VALUE
- ? Long.MAX_VALUE
- : Math.min(
- Math.abs(tStats[0]),
- tChargeBefore + (aIgnoreTransferLimit ? (long) aCharge : Math.min(tStats[1], (long) aCharge)));
- if (!aSimulate) {
- this.setCharge(aStack, tNewCharge);
- }
- return tNewCharge - tChargeBefore;
- }
-
- @Override
- public final double discharge(final ItemStack aStack, final double aCharge, final int aTier,
- final boolean aIgnoreTransferLimit, final boolean aBatteryAlike, final boolean aSimulate) {
- final Long[] tStats = this.getElectricStats(aStack);
- if ((tStats == null) || (tStats[2] > aTier)) {
- return 0;
- }
- if (aBatteryAlike && !this.canProvideEnergy(aStack)) {
- return 0;
- }
- if (tStats[3] > 0) {
- if ((aCharge < tStats[3]) || (aStack.stackSize < 1)) {
- return 0;
- }
- if (!aSimulate) {
- aStack.stackSize--;
- }
- return tStats[3];
- }
- final long tChargeBefore = this.getRealCharge(aStack), tNewCharge = Math
- .max(0, tChargeBefore - (aIgnoreTransferLimit ? (long) aCharge : Math.min(tStats[1], (long) aCharge)));
- if (!aSimulate) {
- this.setCharge(aStack, tNewCharge);
- }
- return tChargeBefore - tNewCharge;
- }
-
- @Override
- public final double getCharge(final ItemStack aStack) {
- return this.getRealCharge(aStack);
- }
-
- @Override
- public final boolean canUse(final ItemStack aStack, final double aAmount) {
- return this.getRealCharge(aStack) >= aAmount;
- }
-
- @Override
- public final boolean use(final ItemStack aStack, final double aAmount, final EntityLivingBase aPlayer) {
- this.chargeFromArmor(aStack, aPlayer);
- if ((aPlayer instanceof EntityPlayer) && ((EntityPlayer) aPlayer).capabilities.isCreativeMode) {
- return true;
- }
- final double tTransfer = this.discharge(aStack, aAmount, Integer.MAX_VALUE, true, false, true);
- if (tTransfer == aAmount) {
- this.discharge(aStack, aAmount, Integer.MAX_VALUE, true, false, false);
- this.chargeFromArmor(aStack, aPlayer);
- return true;
- }
- this.discharge(aStack, aAmount, Integer.MAX_VALUE, true, false, false);
- this.chargeFromArmor(aStack, aPlayer);
- return false;
- }
-
- @Override
- public final boolean canProvideEnergy(final ItemStack aStack) {
- final Long[] tStats = this.getElectricStats(aStack);
- if (tStats == null) {
- return false;
- }
- return (tStats[3] > 0) || ((aStack.stackSize == 1) && ((tStats[3] == -2) || (tStats[3] == -3)));
- }
-
- @Override
- public final void chargeFromArmor(final ItemStack aStack, final EntityLivingBase aPlayer) {
- if ((aPlayer == null) || aPlayer.worldObj.isRemote) {
- return;
- }
- for (int i = 1; i < 5; i++) {
- final ItemStack tArmor = aPlayer.getEquipmentInSlot(i);
- if (GT_ModHandler.isElectricItem(tArmor)) {
- final IElectricItem tArmorItem = (IElectricItem) tArmor.getItem();
- if (tArmorItem.canProvideEnergy(tArmor) && (tArmorItem.getTier(tArmor) >= this.getTier(aStack))) {
- final double tCharge = ElectricItem.manager.discharge(
- tArmor,
- this.charge(aStack, Integer.MAX_VALUE - 1, Integer.MAX_VALUE, true, true),
- Integer.MAX_VALUE,
- true,
- true,
- false);
- if (tCharge > 0) {
- this.charge(aStack, tCharge, Integer.MAX_VALUE, true, false);
- if (aPlayer instanceof EntityPlayer) {
- final Container tContainer = ((EntityPlayer) aPlayer).openContainer;
- if (tContainer != null) {
- tContainer.detectAndSendChanges();
- }
- }
- }
- }
- }
- }
- }
-
- public final long getRealCharge(final ItemStack aStack) {
- final Long[] tStats = this.getElectricStats(aStack);
- if (tStats == null) {
- return 0;
- }
- if (tStats[3] > 0) {
- return (int) (long) tStats[3];
- }
- final NBTTagCompound tNBT = aStack.getTagCompound();
- return tNBT == null ? 0 : tNBT.getLong("GT.ItemCharge");
- }
-
- public final boolean setCharge(final ItemStack aStack, long aCharge) {
- final Long[] tStats = this.getElectricStats(aStack);
- if ((tStats == null) || (tStats[3] > 0)) {
- return false;
- }
- NBTTagCompound tNBT = aStack.getTagCompound();
- if (tNBT == null) {
- tNBT = new NBTTagCompound();
- }
- tNBT.removeTag("GT.ItemCharge");
- aCharge = Math.min(tStats[0] < 0 ? Math.abs(tStats[0] / 2) : aCharge, Math.abs(tStats[0]));
- if (aCharge > 0) {
- aStack.setItemDamage(this.getChargedMetaData(aStack));
- tNBT.setLong("GT.ItemCharge", aCharge);
- } else {
- aStack.setItemDamage(this.getEmptyMetaData(aStack));
- }
- if (tNBT.hasNoTags()) {
- aStack.setTagCompound(null);
- } else {
- aStack.setTagCompound(tNBT);
- }
- this.isItemStackUsable(aStack);
- return true;
- }
-
- public short getChargedMetaData(final ItemStack aStack) {
- return (short) aStack.getItemDamage();
- }
-
- public short getEmptyMetaData(final ItemStack aStack) {
- return (short) aStack.getItemDamage();
- }
-
- public boolean isItemStackUsable(final ItemStack aStack) {
- final ArrayList<IItemBehaviour<BaseEuItem>> tList = this.mItemBehaviors.get((short) this.getDamage(aStack));
- if (tList != null) {
- for (final IItemBehaviour<BaseEuItem> tBehavior : tList) {
- if (!tBehavior.isItemStackUsable(this, aStack)) {
- return false;
- }
- }
- }
- return true;
- }
-
- @Override
- public final String getToolTip(final ItemStack aStack) {
- return null;
- } // This has its own ToolTip Handler, no need to let the IC2 Handler screw us up at this Point
-
- @Override
- public final IElectricItemManager getManager(final ItemStack aStack) {
- return this;
- } // We are our own Manager
-
- /**
- * Sets the Furnace Burn Value for the Item.
- *
- * @param aMetaValue the Meta Value of the Item you want to set it to. [0 - 32765]
- * @param aValue 200 = 1 Burn Process = 500 EU, max = 32767 (that is 81917.5 EU)
- * @return the Item itself for convenience in constructing.
- */
- public final BaseEuItem setBurnValue(final int aMetaValue, final int aValue) {
- if ((aMetaValue < 0) || (aValue < 0)) {
- return this;
- }
- if (aValue == 0) {
- this.mBurnValues.remove((short) aMetaValue);
- } else {
- this.mBurnValues.put((short) aMetaValue, aValue > Short.MAX_VALUE ? Short.MAX_VALUE : (short) aValue);
- }
- return this;
- }
-
- /**
- * @param aMetaValue the Meta Value of the Item you want to set it to. [0 - 32765]
- * @param aMaxCharge Maximum Charge. (if this is == 0 it will remove the Electric Behavior)
- * @param aTransferLimit Transfer Limit.
- * @param aTier The electric Tier.
- * @param aSpecialData If this Item has a Fixed Charge, like a SingleUse Battery (if > 0). Use -1 if you want to
- * make this Battery chargeable (the use and canUse Functions will still discharge if you just
- * use this) Use -2 if you want to make this Battery dischargeable. Use -3 if you want to make
- * this Battery charge/discharge-able.
- * @return the Item itself for convenience in constructing.
- */
- public final BaseEuItem setElectricStats(final int aMetaValue, final long aMaxCharge, final long aTransferLimit,
- final long aTier, final long aSpecialData, final boolean aUseAnimations) {
- if (aMetaValue < 0) {
- return this;
- }
- if (aMaxCharge == 0) {
- this.mElectricStats.remove((short) aMetaValue);
- } else {
- this.mElectricStats.put(
- (short) aMetaValue,
- new Long[] { aMaxCharge, Math.max(0, aTransferLimit), Math.max(-1, aTier), aSpecialData });
- }
- return this;
- }
-
- @SuppressWarnings({ "rawtypes", "unchecked" })
- @Override
- @SideOnly(Side.CLIENT)
- public void getSubItems(final Item var1, final CreativeTabs aCreativeTab, final List aList) {
- for (int i = 0, j = this.mEnabledItems.length(); i < j; i++) {
- if (this.mVisibleItems.get(i) || (D1 && this.mEnabledItems.get(i))) {
- final Long[] tStats = this.mElectricStats.get((short) (this.mOffset + i));
- if ((tStats != null) && (tStats[3] < 0)) {
- final ItemStack tStack = new ItemStack(this, 1, this.mOffset + i);
- this.setCharge(tStack, Math.abs(tStats[0]));
- this.isItemStackUsable(tStack);
- aList.add(tStack);
- }
- if ((tStats == null) || (tStats[3] != -2)) {
- final ItemStack tStack = new ItemStack(this, 1, this.mOffset + i);
- this.isItemStackUsable(tStack);
- aList.add(tStack);
- }
- }
- }
- }
-
- @Override
- @SideOnly(Side.CLIENT)
- public final void registerIcons(final IIconRegister aIconRegister) {
- for (short i = 0, j = (short) this.mEnabledItems.length(); i < j; i++) {
- if (this.mEnabledItems.get(i)) {
- for (byte k = 1; k < this.mIconList[i].length; k++) {
- this.mIconList[i][k] = aIconRegister
- .registerIcon(GTPlusPlus.ID + ":" + (this.getUnlocalizedName() + "/" + i + "/" + k));
- }
- this.mIconList[i][0] = aIconRegister
- .registerIcon(GTPlusPlus.ID + ":" + (this.getUnlocalizedName() + "/" + i));
- }
- }
- }
-
- @Override
- public final IIcon getIconFromDamage(final int aMetaData) {
- if (aMetaData < 0) {
- return null;
- }
- return (aMetaData - this.mOffset) < this.mIconList.length ? this.mIconList[aMetaData - this.mOffset][0] : null;
- }
-
- /**
- * Sets the unlocalized name of this item to the string passed as the parameter"
- */
- @Override
- public Item setUnlocalizedName(final String p_77655_1_) {
- this.unlocalizedName = p_77655_1_;
- super.setUnlocalizedName(p_77655_1_);
- return this;
- }
-
- /**
- * Returns the unlocalized name of this item.
- */
- @Override
- public String getUnlocalizedName() {
- return this.unlocalizedName;
- }
-
- public final Long[] getElectricStats(final ItemStack aStack) {
- return this.mElectricStats.get((short) aStack.getItemDamage());
- }
-
- @Override
- public int getItemEnchantability() {
- return 0;
- }
-
- @Override
- public boolean isBookEnchantable(final ItemStack aStack, final ItemStack aBook) {
- return false;
- }
-
- @Override
- public boolean getIsRepairable(final ItemStack aStack, final ItemStack aMaterial) {
- return false;
- }
-
- /**
- * Adds a special Item Behaviour to the Item.
- * <p/>
- * Note: the boolean Behaviours sometimes won't be executed if another boolean Behaviour returned true before.
- *
- * @param aMetaValue the Meta Value of the Item you want to add it to. [0 - 32765]
- * @param aBehavior the Click Behavior you want to add.
- * @return the Item itself for convenience in constructing.
- */
- public final BaseEuItem addItemBehavior(final int aMetaValue, final IItemBehaviour<BaseEuItem> aBehavior) {
- if ((aMetaValue < 0) || (aMetaValue >= 32766) || (aBehavior == null)) {
- return this;
- }
- ArrayList<IItemBehaviour<BaseEuItem>> tList = this.mItemBehaviors.get((short) aMetaValue);
- if (tList == null) {
- tList = new ArrayList<>(1);
- this.mItemBehaviors.put((short) aMetaValue, tList);
- }
- tList.add(aBehavior);
- return this;
- }
-
- /**
- * This adds a Custom Item to the ending Range.
- *
- * @param aID The Id of the assigned Item [0 - mItemAmount] (The MetaData gets auto-shifted by +mOffset)
- * @param aEnglish The Default Localized Name of the created Item
- * @param aToolTip The Default ToolTip of the created Item, you can also insert null for having no ToolTip
- * @param aFoodBehavior The Food Value of this Item. Can be null aswell. Just a convenience thing.
- * @param aRandomData The OreDict Names you want to give the Item. Also used for TC Aspects and some other things.
- * @return An ItemStack containing the newly created Item.
- */
- @SuppressWarnings("unchecked")
- public final ItemStack addItem(final int aID, final String aEnglish, String aToolTip, final Object... aRandomData) {
- if (aToolTip == null) {
- aToolTip = "";
- }
- if ((aID >= 0) && (aID < this.mItemAmount)) {
- final ItemStack rStack = new ItemStack(this, 1, this.mOffset + aID);
- this.mEnabledItems.set(aID);
- this.mVisibleItems.set(aID);
- GT_LanguageManager.addStringLocalization(
- "gtplusplus." + this.getUnlocalizedName(rStack) + "." + aID + ".name",
- aEnglish);
- GT_LanguageManager.addStringLocalization(
- "gtplusplus." + this.getUnlocalizedName(rStack) + "." + aID + ".tooltip",
- aToolTip);
- final List<TC_AspectStack> tAspects = new ArrayList<>();
- // Important Stuff to do first
- for (final Object tRandomData : aRandomData) {
- if (tRandomData instanceof SubTag) {
- if (tRandomData == SubTag.INVISIBLE) {
- this.mVisibleItems.set(aID, false);
- continue;
- }
- if (tRandomData == SubTag.NO_UNIFICATION) {
- GT_OreDictUnificator.addToBlacklist(rStack);
- continue;
- }
- }
- }
- // now check for the rest
- for (final Object tRandomData : aRandomData) {
- if (tRandomData != null) {
- boolean tUseOreDict = true;
- if (tRandomData instanceof IItemBehaviour) {
- this.addItemBehavior(this.mOffset + aID, (IItemBehaviour<BaseEuItem>) tRandomData);
- tUseOreDict = false;
- }
- if (tRandomData instanceof IItemContainer) {
- ((IItemContainer) tRandomData).set(rStack);
- tUseOreDict = false;
- }
- if (tRandomData instanceof SubTag) {
- continue;
- }
- if (tRandomData instanceof TC_AspectStack) {
- ((TC_AspectStack) tRandomData).addToAspectList(tAspects);
- continue;
- }
- if (tRandomData instanceof ItemData) {
- if (GT_Utility.isStringValid(tRandomData)) {
- GT_OreDictUnificator.registerOre(tRandomData, rStack);
- } else {
- GT_OreDictUnificator.addItemData(rStack, (ItemData) tRandomData);
- }
- continue;
- }
- if (tUseOreDict) {
- GT_OreDictUnificator.registerOre(tRandomData, rStack);
- continue;
- }
- }
- }
- if (GregTech_API.sThaumcraftCompat != null) {
- GregTech_API.sThaumcraftCompat.registerThaumcraftAspectsToItem(rStack, tAspects, false);
- }
- return rStack;
- }
- return null;
- }
-
- @Override
- public String getItemStackDisplayName(final ItemStack par1ItemStack) {
- int keyValue = (par1ItemStack.getItemDamage() - this.mOffset);
- if (keyValue < 0 || keyValue > 5) {
- keyValue = 0;
- }
- return GT_LanguageManager
- .getTranslation("gtplusplus." + this.getUnlocalizedName(par1ItemStack) + "." + keyValue + ".name");
- }
-}
diff --git a/src/main/java/gtPlusPlus/core/item/base/dusts/BaseItemDustAbstract.java b/src/main/java/gtPlusPlus/core/item/base/dusts/BaseItemDustAbstract.java
deleted file mode 100644
index c89bbb1d7d..0000000000
--- a/src/main/java/gtPlusPlus/core/item/base/dusts/BaseItemDustAbstract.java
+++ /dev/null
@@ -1,43 +0,0 @@
-package gtPlusPlus.core.item.base.dusts;
-
-import static gregtech.api.enums.Mods.GTPlusPlus;
-
-import java.util.List;
-
-import net.minecraft.entity.player.EntityPlayer;
-import net.minecraft.item.Item;
-import net.minecraft.item.ItemStack;
-
-import cpw.mods.fml.common.registry.GameRegistry;
-
-public abstract class BaseItemDustAbstract extends Item {
-
- protected int colour = 0;
- protected String materialName;
- protected String pileType;
-
- public BaseItemDustAbstract(final String unlocalizedName, final String materialName, final int colour,
- final String pileSize) {
- this.setUnlocalizedName(unlocalizedName);
- this.setMaxStackSize(64);
- if (pileSize.equalsIgnoreCase("dust")) {
- this.setTextureName(GTPlusPlus.ID + ":" + "dust");
- } else {
- this.setTextureName(GTPlusPlus.ID + ":" + "dust" + pileSize);
- }
- this.setMaxStackSize(64);
- this.colour = colour;
- this.materialName = materialName;
- this.setUnlocalizedName(unlocalizedName);
- GameRegistry.registerItem(this, unlocalizedName);
- }
-
- @SuppressWarnings("rawtypes")
- @Override
- public abstract void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool);
-
- public abstract String getMaterialName();
-
- @Override
- public abstract int getColorFromItemStack(ItemStack stack, int hex);
-}
diff --git a/src/main/java/gtPlusPlus/core/item/base/dusts/decimal/BaseItemCentidust.java b/src/main/java/gtPlusPlus/core/item/base/dusts/decimal/BaseItemCentidust.java
deleted file mode 100644
index 78af2155b1..0000000000
--- a/src/main/java/gtPlusPlus/core/item/base/dusts/decimal/BaseItemCentidust.java
+++ /dev/null
@@ -1,57 +0,0 @@
-package gtPlusPlus.core.item.base.dusts.decimal;
-
-import static gregtech.api.enums.Mods.GTPlusPlus;
-
-import java.util.List;
-
-import net.minecraft.entity.player.EntityPlayer;
-import net.minecraft.item.Item;
-import net.minecraft.item.ItemStack;
-import net.minecraft.util.EnumChatFormatting;
-
-import cpw.mods.fml.common.registry.GameRegistry;
-import gtPlusPlus.core.creative.AddToCreativeTab;
-import gtPlusPlus.core.material.Material;
-
-public class BaseItemCentidust extends Item {
-
- final Material dustMaterial;
- final String materialName;
- final String unlocalName;
-
- public BaseItemCentidust(final Material material) {
- this.dustMaterial = material;
- this.unlocalName = "itemCentidust" + material.getUnlocalizedName();
- this.materialName = material.getLocalizedName();
- this.setCreativeTab(AddToCreativeTab.tabMisc);
- this.setUnlocalizedName(this.unlocalName);
- this.setMaxStackSize(10);
- this.setTextureName(GTPlusPlus.ID + ":" + "itemCentidust"); // TODO
- GameRegistry.registerItem(this, this.unlocalName);
- // GT_OreDictUnificator.registerOre(unlocalName.replace("itemR", "r"), UtilsItems.getSimpleStack(this)); //TODO
- }
-
- @Override
- public String getItemStackDisplayName(final ItemStack p_77653_1_) {
-
- return (this.materialName + " Centidust");
- }
-
- @SuppressWarnings({ "rawtypes", "unchecked" })
- @Override
- public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) {
- if ((this.materialName != null) && (this.materialName != "") && !this.materialName.equals("")) {
- list.add(EnumChatFormatting.GRAY + "1% of a " + this.materialName + " dust pile.");
- }
- super.addInformation(stack, aPlayer, list, bool);
- }
-
- public final String getMaterialName() {
- return this.materialName;
- }
-
- @Override
- public int getColorFromItemStack(final ItemStack stack, final int HEX_OxFFFFFF) {
- return this.dustMaterial.getRgbAsHex();
- }
-}
diff --git a/src/main/java/gtPlusPlus/core/item/base/dusts/decimal/BaseItemDecidust.java b/src/main/java/gtPlusPlus/core/item/base/dusts/decimal/BaseItemDecidust.java
deleted file mode 100644
index de1b63794e..0000000000
--- a/src/main/java/gtPlusPlus/core/item/base/dusts/decimal/BaseItemDecidust.java
+++ /dev/null
@@ -1,57 +0,0 @@
-package gtPlusPlus.core.item.base.dusts.decimal;
-
-import static gregtech.api.enums.Mods.GTPlusPlus;
-
-import java.util.List;
-
-import net.minecraft.entity.player.EntityPlayer;
-import net.minecraft.item.Item;
-import net.minecraft.item.ItemStack;
-import net.minecraft.util.EnumChatFormatting;
-
-import cpw.mods.fml.common.registry.GameRegistry;
-import gtPlusPlus.core.creative.AddToCreativeTab;
-import gtPlusPlus.core.material.Material;
-
-public class BaseItemDecidust extends Item {
-
- final Material dustMaterial;
- final String materialName;
- final String unlocalName;
-
- public BaseItemDecidust(final Material material) {
- this.dustMaterial = material;
- this.unlocalName = "itemDecidust" + material.getUnlocalizedName();
- this.materialName = material.getLocalizedName();
- this.setCreativeTab(AddToCreativeTab.tabMisc);
- this.setUnlocalizedName(this.unlocalName);
- this.setMaxStackSize(10);
- this.setTextureName(GTPlusPlus.ID + ":" + "itemDecidust"); // TODO
- GameRegistry.registerItem(this, this.unlocalName);
- // GT_OreDictUnificator.registerOre(unlocalName.replace("itemR", "r"), UtilsItems.getSimpleStack(this)); //TODO
- }
-
- @Override
- public String getItemStackDisplayName(final ItemStack p_77653_1_) {
-
- return (this.materialName + " Decidust");
- }
-
- @SuppressWarnings({ "rawtypes", "unchecked" })
- @Override
- public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) {
- if ((this.materialName != null) && (this.materialName != "") && !this.materialName.equals("")) {
- list.add(EnumChatFormatting.GRAY + "10% of a " + this.materialName + " dust pile.");
- }
- super.addInformation(stack, aPlayer, list, bool);
- }
-
- public final String getMaterialName() {
- return this.materialName;
- }
-
- @Override
- public int getColorFromItemStack(final ItemStack stack, final int HEX_OxFFFFFF) {
- return this.dustMaterial.getRgbAsHex();
- }
-}
diff --git a/src/main/java/gtPlusPlus/core/item/base/foods/BaseItemFood.java b/src/main/java/gtPlusPlus/core/item/base/foods/BaseItemFood.java
deleted file mode 100644
index f101bb969b..0000000000
--- a/src/main/java/gtPlusPlus/core/item/base/foods/BaseItemFood.java
+++ /dev/null
@@ -1,45 +0,0 @@
-package gtPlusPlus.core.item.base.foods;
-
-import static gregtech.api.enums.Mods.GTPlusPlus;
-
-import net.minecraft.entity.player.EntityPlayer;
-import net.minecraft.item.ItemFood;
-import net.minecraft.item.ItemStack;
-import net.minecraft.potion.PotionEffect;
-import net.minecraft.world.World;
-
-import cpw.mods.fml.common.registry.GameRegistry;
-import gtPlusPlus.core.creative.AddToCreativeTab;
-
-public class BaseItemFood extends ItemFood {
-
- private final PotionEffect[] effects;
- protected String localName;
-
- public BaseItemFood(final String unlocalizedName, final String localizedName, final int healAmount,
- final float saturationModifier, final boolean wolvesFavorite, final PotionEffect... effects) {
- super(healAmount, saturationModifier, wolvesFavorite);
- this.setUnlocalizedName(unlocalizedName);
- this.setTextureName(GTPlusPlus.ID + ":" + unlocalizedName.replace("Hot", ""));
- this.setCreativeTab(AddToCreativeTab.tabMisc);
- this.effects = effects;
- this.localName = localizedName;
- GameRegistry.registerItem(this, unlocalizedName);
- }
-
- @Override
- protected void onFoodEaten(final ItemStack stack, final World world, final EntityPlayer player) {
- super.onFoodEaten(stack, world, player);
-
- for (int i = 0; i < this.effects.length; i++) {
- if (!world.isRemote && (this.effects[i] != null) && (this.effects[i].getPotionID() > 0)) {
- player.addPotionEffect(
- new PotionEffect(
- this.effects[i].getPotionID(),
- this.effects[i].getDuration(),
- this.effects[i].getAmplifier(),
- this.effects[i].getIsAmbient()));
- }
- }
- }
-}
diff --git a/src/main/java/gtPlusPlus/core/item/base/foods/BaseItemHotFood.java b/src/main/java/gtPlusPlus/core/item/base/foods/BaseItemHotFood.java
deleted file mode 100644
index b68d7a5d7f..0000000000
--- a/src/main/java/gtPlusPlus/core/item/base/foods/BaseItemHotFood.java
+++ /dev/null
@@ -1,84 +0,0 @@
-package gtPlusPlus.core.item.base.foods;
-
-import java.util.List;
-
-import net.minecraft.entity.Entity;
-import net.minecraft.entity.player.EntityPlayer;
-import net.minecraft.item.Item;
-import net.minecraft.item.ItemStack;
-import net.minecraft.util.DamageSource;
-import net.minecraft.util.EnumChatFormatting;
-import net.minecraft.util.StatCollector;
-import net.minecraft.world.World;
-
-import gtPlusPlus.api.objects.Logger;
-import gtPlusPlus.core.util.Utils;
-import gtPlusPlus.core.util.math.MathUtils;
-import gtPlusPlus.core.util.minecraft.ItemUtils;
-
-public class BaseItemHotFood extends BaseItemFood {
-
- protected String materialName;
- protected String unlocalName;
- protected int cooldownTime;
- protected Item output;
-
- public BaseItemHotFood(final String unlocalizedName, final int healAmount, final float healSaturation,
- final String foodName, final int timeToCoolInSeconds, final Item cooledFood) {
- super(unlocalizedName, "Hot " + foodName, healAmount, healSaturation, false);
- this.unlocalName = unlocalizedName;
- this.cooldownTime = timeToCoolInSeconds * 20;
- this.materialName = foodName;
- this.output = cooledFood;
- this.setMaxStackSize(1);
- }
-
- @Override
- public ItemStack onEaten(final ItemStack iStack, final World world, final EntityPlayer player) {
- return super.onEaten(iStack, world, player);
- }
-
- @Override
- public void onUpdate(final ItemStack iStack, final World world, final Entity entityHolding, final int p_77663_4_,
- final boolean p_77663_5_) {
- // Utils.LOG_INFO("Item Damage: "+iStack.getItemDamage()+" Max Damage: "+iStack.getMaxDamage());
- if (!world.isRemote) {
- if (iStack.getItemDamage() == this.cooldownTime) {
- if (entityHolding instanceof EntityPlayer) {
- Logger.INFO("Foods Done.");
- ((EntityPlayer) entityHolding).inventory
- .addItemStackToInventory(ItemUtils.getSimpleStack(this.output));
- ((EntityPlayer) entityHolding).inventory.consumeInventoryItem(this);
- }
- } else if (iStack.getItemDamage() < this.cooldownTime) {
- iStack.setItemDamage(iStack.getItemDamage() + 1);
- }
- if (MathUtils.divideXintoY(iStack.getItemDamage(), 150)) {
- entityHolding.attackEntityFrom(DamageSource.onFire, 1);
- }
- }
- super.onUpdate(iStack, world, entityHolding, p_77663_4_, p_77663_5_);
- }
-
- @SuppressWarnings({ "rawtypes", "unchecked" })
- @Override
- public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) {
- if ((this.materialName != null) && (this.materialName != "") && !this.materialName.equals("")) {
- list.add(StatCollector.translateToLocal("item.itemBaseItemHotFood.tooltip.0"));
- list.add(
- EnumChatFormatting.GRAY + StatCollector.translateToLocalFormatted(
- "item.itemBaseItemHotFood.tooltip.1",
- (this.cooldownTime - stack.getItemDamage()) / 20));
- }
- super.addInformation(stack, aPlayer, list, bool);
- }
-
- public final String getMaterialName() {
- return this.materialName;
- }
-
- @Override
- public int getColorFromItemStack(final ItemStack stack, final int HEX_OxFFFFFF) {
- return Utils.rgbtoHexValue(230, 96, 96);
- }
-}
diff --git a/src/main/java/gtPlusPlus/core/item/base/itemblock/FluidItemBlock.java b/src/main/java/gtPlusPlus/core/item/base/itemblock/FluidItemBlock.java
deleted file mode 100644
index 8c2278d50b..0000000000
--- a/src/main/java/gtPlusPlus/core/item/base/itemblock/FluidItemBlock.java
+++ /dev/null
@@ -1,60 +0,0 @@
-package gtPlusPlus.core.item.base.itemblock;
-
-import java.util.List;
-
-import net.minecraft.block.Block;
-import net.minecraft.entity.player.EntityPlayer;
-import net.minecraft.item.ItemBlock;
-import net.minecraft.item.ItemStack;
-
-import gtPlusPlus.core.fluids.BlockFluidBase;
-import gtPlusPlus.core.util.math.MathUtils;
-
-public class FluidItemBlock extends ItemBlock {
-
- protected final int blockColour;
- final BlockFluidBase baseBlock;
- String name;
-
- public FluidItemBlock(final Block block) {
- super(block);
- this.baseBlock = (BlockFluidBase) block;
- this.blockColour = this.baseBlock.getRenderColor(1);
- this.name = this.baseBlock.getLocalizedName().replace("tile", "").replace("fluid", "").replace("name", "")
- .replace("block", "").replace(".", "");
- // GT_OreDictUnificator.registerOre("frameGt"+block.getUnlocalizedName().replace("tile.",
- // "").replace("tile.BlockGtFrame", "").replace("-", "").replace("_", "").replace(" ", "").replace("FrameBox",
- // ""), UtilsItems.getSimpleStack(this));
- }
-
- public int getRenderColor(final int aMeta) {
- return this.blockColour;
- }
-
- @Override
- public String getItemStackDisplayName(final ItemStack iStack) {
- /*
- * if (this.thisFluid != null){ this.name = "Molten "+this.thisFluid.getLocalizedName(); return this.name; }
- */
- this.name = "Molten " + this.baseBlock.getLocalizedName().replace("tile", "").replace("fluid", "")
- .replace("name", "").replace("block", "").replace(".", "");
- return this.name;
- }
-
- @Override
- public int getColorFromItemStack(final ItemStack stack, final int HEX_OxFFFFFF) {
- if (this.blockColour == 0) {
- return MathUtils.generateSingularRandomHexValue();
- }
- return this.blockColour;
- }
-
- @Override
- public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) {
- /*
- * list.add("Temperature: "+MathUtils.celsiusToKelvin(this.thisFluid.getMeltingPointC())+"K"); if
- * (this.sRadiation > 0){ list.add(CORE.GT_Tooltip_Radioactive.get()); }
- */
- super.addInformation(stack, aPlayer, list, bool);
- }
-}
diff --git a/src/main/java/gtPlusPlus/core/item/base/itemblock/ItemBlockDoor.java b/src/main/java/gtPlusPlus/core/item/base/itemblock/ItemBlockDoor.java
deleted file mode 100644
index 54c8b89704..0000000000
--- a/src/main/java/gtPlusPlus/core/item/base/itemblock/ItemBlockDoor.java
+++ /dev/null
@@ -1,101 +0,0 @@
-package gtPlusPlus.core.item.base.itemblock;
-
-import java.util.List;
-
-import net.minecraft.block.Block;
-import net.minecraft.entity.player.EntityPlayer;
-import net.minecraft.item.ItemBlock;
-import net.minecraft.item.ItemStack;
-import net.minecraft.util.IIcon;
-import net.minecraft.util.MathHelper;
-import net.minecraft.world.World;
-
-import cpw.mods.fml.relauncher.Side;
-import cpw.mods.fml.relauncher.SideOnly;
-
-public class ItemBlockDoor extends ItemBlock {
-
- @SideOnly(Side.CLIENT)
- private IIcon field_150938_b;
-
- public ItemBlockDoor(Block p_i45328_1_) {
- super(p_i45328_1_);
- }
-
- /**
- * Callback for item usage. If the item does something special on right clicking, he will have one of those. Return
- * True if something happen and false if it don't. This is for ITEMS, not BLOCKS
- */
- @Override
- public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4,
- int par5, int par6, int par7, float par8, float par9, float par10) {
- if (par7 != 1) {
- return false;
- } else {
- ++par5;
- Block block;
-
- block = field_150939_a;
-
- if (par2EntityPlayer.canPlayerEdit(par4, par5, par6, par7, par1ItemStack)
- && par2EntityPlayer.canPlayerEdit(par4, par5 + 1, par6, par7, par1ItemStack)) {
- if (!block.canPlaceBlockAt(par3World, par4, par5, par6)) {
- return false;
- } else {
- int i1 = MathHelper.floor_double(
- (double) ((par2EntityPlayer.rotationYaw + 180.0F) * 4.0F / 360.0F) - 0.5D) & 3;
- byte b0 = 0;
- byte b1 = 0;
-
- if (i1 == 0) {
- b1 = 1;
- }
-
- if (i1 == 1) {
- b0 = -1;
- }
-
- if (i1 == 2) {
- b1 = -1;
- }
-
- if (i1 == 3) {
- b0 = 1;
- }
-
- int i2 = (par3World.getBlock(par4 - b0, par5, par6 - b1).isNormalCube() ? 1 : 0)
- + (par3World.getBlock(par4 - b0, par5 + 1, par6 - b1).isNormalCube() ? 1 : 0);
- int j1 = (par3World.getBlock(par4 + b0, par5, par6 + b1).isNormalCube() ? 1 : 0)
- + (par3World.getBlock(par4 + b0, par5 + 1, par6 + b1).isNormalCube() ? 1 : 0);
- boolean flag = par3World.getBlock(par4 - b0, par5, par6 - b1) == block
- || par3World.getBlock(par4 - b0, par5 + 1, par6 - b1) == block;
- boolean flag1 = par3World.getBlock(par4 + b0, par5, par6 + b1) == block
- || par3World.getBlock(par4 + b0, par5 + 1, par6 + b1) == block;
- boolean flag2 = false;
-
- if (flag && !flag1) {
- flag2 = true;
- } else if (j1 > i2) {
- flag2 = true;
- }
-
- par3World.setBlock(par4, par5, par6, block, i1, 2);
- par3World.setBlock(par4, par5 + 1, par6, block, 8 | (flag2 ? 1 : 0), 2);
- par3World.notifyBlocksOfNeighborChange(par4, par5, par6, block);
- par3World.notifyBlocksOfNeighborChange(par4, par5 + 1, par6, block);
-
- --par1ItemStack.stackSize;
- return true;
- }
- } else {
- return false;
- }
- }
- }
-
- @Override
- public void addInformation(ItemStack p_77624_1_, EntityPlayer p_77624_2_, List p_77624_3_, boolean p_77624_4_) {
- p_77624_3_.add("This is a block, you can place it by right clicking");
- super.addInformation(p_77624_1_, p_77624_2_, p_77624_3_, p_77624_4_);
- }
-}
diff --git a/src/main/java/gtPlusPlus/core/item/base/itemblock/ItemBlockGtFrameBox.java b/src/main/java/gtPlusPlus/core/item/base/itemblock/ItemBlockGtFrameBox.java
deleted file mode 100644
index 914e39e2a5..0000000000
--- a/src/main/java/gtPlusPlus/core/item/base/itemblock/ItemBlockGtFrameBox.java
+++ /dev/null
@@ -1,91 +0,0 @@
-package gtPlusPlus.core.item.base.itemblock;
-
-import java.util.List;
-
-import net.minecraft.block.Block;
-import net.minecraft.entity.Entity;
-import net.minecraft.entity.player.EntityPlayer;
-import net.minecraft.item.ItemBlock;
-import net.minecraft.item.ItemStack;
-import net.minecraft.util.EnumChatFormatting;
-import net.minecraft.world.World;
-
-import gtPlusPlus.core.block.base.BlockBaseModular;
-import gtPlusPlus.core.lib.CORE;
-import gtPlusPlus.core.material.Material;
-import gtPlusPlus.core.material.MaterialStack;
-import gtPlusPlus.core.util.minecraft.EntityUtils;
-import gtPlusPlus.core.util.sys.KeyboardUtils;
-
-public class ItemBlockGtFrameBox extends ItemBlock {
-
- protected int blockColour;
- private Material mMaterial;
- private int sRadiation;
-
- public ItemBlockGtFrameBox(final Block block) {
- super(block);
- final BlockBaseModular baseBlock = (BlockBaseModular) block;
- this.blockColour = baseBlock.getRenderColor(1);
-
- if (block instanceof BlockBaseModular) {
- BlockBaseModular g = (BlockBaseModular) block;
- this.mMaterial = g.getMaterialEx();
- sRadiation = mMaterial.vRadiationLevel;
- } else {
- this.mMaterial = null;
- sRadiation = 0;
- }
-
- // GT_OreDictUnificator.registerOre("frameGt"+block.getUnlocalizedName().replace("tile.",
- // "").replace("tile.BlockGtFrame", "").replace("-", "").replace("_", "").replace(" ", "").replace("FrameBox",
- // ""), ItemUtils.getSimpleStack(this));
- }
-
- public int getRenderColor(final int aMeta) {
- return this.blockColour;
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) {
- if (this.mMaterial != null) {
- list.add(this.mMaterial.vChemicalFormula);
- if (this.mMaterial.vRadiationLevel > 0) {
- list.add(CORE.GT_Tooltip_Radioactive.get());
- }
- } else {
- list.add("Material is Null.");
- }
- if (KeyboardUtils.isCtrlKeyDown()) {
- Block b = Block.getBlockFromItem(stack.getItem());
- if (b != null) {
- String aTool = b.getHarvestTool(stack.getItemDamage());
- int aMiningLevel1 = b.getHarvestLevel(stack.getItemDamage());
- list.add("Mining Level: " + Math.min(Math.max(aMiningLevel1, 0), 5));
- if (this.mMaterial != null) {
- list.add("Contains: ");
- if (mMaterial.getComposites().isEmpty()) {
- list.add("- " + mMaterial.getLocalizedName());
- } else {
- for (MaterialStack m : mMaterial.getComposites()) {
- list.add("- " + m.getStackMaterial().getLocalizedName() + " x" + m.getPartsPerOneHundred());
- }
- }
- }
- }
- } else {
- list.add(EnumChatFormatting.DARK_GRAY + "Hold Ctrl to show additional info.");
- }
- super.addInformation(stack, aPlayer, list, bool);
- }
-
- @Override
- public void onUpdate(final ItemStack iStack, final World world, final Entity entityHolding, final int p_77663_4_,
- final boolean p_77663_5_) {
-
- if (this.sRadiation > 0) {
- EntityUtils.applyRadiationDamageToEntity(iStack.stackSize, this.sRadiation, world, entityHolding);
- }
- }
-}
diff --git a/src/main/java/gtPlusPlus/core/item/base/itemblock/ItemBlockNBT.java b/src/main/java/gtPlusPlus/core/item/base/itemblock/ItemBlockNBT.java
deleted file mode 100644
index abbdd61ff1..0000000000
--- a/src/main/java/gtPlusPlus/core/item/base/itemblock/ItemBlockNBT.java
+++ /dev/null
@@ -1,96 +0,0 @@
-package gtPlusPlus.core.item.base.itemblock;
-
-import java.util.List;
-
-import net.minecraft.block.Block;
-import net.minecraft.entity.Entity;
-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.world.World;
-
-import gregtech.api.util.GT_Utility;
-import gtPlusPlus.api.interfaces.ITileTooltip;
-import gtPlusPlus.api.objects.Logger;
-import gtPlusPlus.core.tileentities.base.TileEntityBase;
-import gtPlusPlus.core.util.minecraft.PlayerUtils;
-
-public class ItemBlockNBT extends ItemBlock {
-
- protected final int mID;
-
- public ItemBlockNBT(final Block block) {
- super(block);
- this.mID = ((ITileTooltip) block).getTooltipID();
- }
-
- @Override
- public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) {
-
- // if ()
-
- if (this.mID == 0) { // blockDarkWorldPortalFrame
- list.add("Assembled in the same shape as the Nether Portal.");
- }
- }
-
- @Override
- public void onCreated(ItemStack item, World world, EntityPlayer player) {
- addNBT(player, item);
- super.onCreated(item, world, player);
- }
-
- @Override
- public void onUpdate(ItemStack item, World world, Entity entity, int p_77663_4_, boolean p_77663_5_) {
- if (entity instanceof EntityPlayerMP) {
- EntityPlayerMP mPlayer = (EntityPlayerMP) entity;
-
- NBTTagCompound rNBT = item.getTagCompound();
- rNBT = ((rNBT == null) ? new NBTTagCompound() : rNBT);
- if (!rNBT.hasKey("mOwner")) {
- addNBT(mPlayer, item);
- }
- }
- super.onUpdate(item, world, entity, p_77663_4_, p_77663_5_);
- }
-
- private void addNBT(EntityPlayer player, ItemStack item) {
- NBTTagCompound rNBT = item.getTagCompound();
- rNBT = ((rNBT == null) ? new NBTTagCompound() : rNBT);
- if (player != null) {
- boolean mOP = PlayerUtils.isPlayerOP(player);
- rNBT.setString("mOwner", player.getDisplayName());
- rNBT.setString("mUUID", "" + player.getUniqueID());
- rNBT.setBoolean("mOP", mOP);
- } else if (player == null) {
- rNBT.setString("mOwner", "fakeplayer");
- rNBT.setString("mUUID", "00000000");
- rNBT.setBoolean("mOP", false);
- }
- GT_Utility.ItemNBT.setNBT(item, rNBT);
- }
-
- @Override
- public boolean placeBlockAt(ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ, int side,
- float hitX, float hitY, float hitZ, int aMeta) {
- if (!(aWorld.setBlock(aX, aY, aZ, this.field_150939_a, 0, 3))) {
- return false;
- }
- if (aWorld.getBlock(aX, aY, aZ) == this.field_150939_a) {
- this.field_150939_a.onBlockPlacedBy(aWorld, aX, aY, aZ, aPlayer, aStack);
- this.field_150939_a.onPostBlockPlaced(aWorld, aX, aY, aZ, aMeta);
- }
- TileEntityBase tTileEntity = (TileEntityBase) aWorld.getTileEntity(aX, aY, aZ);
- if (tTileEntity != null && aPlayer != null) {
- if (tTileEntity.isServerSide()) {
- Logger.INFO("Setting Tile Entity information");
- NBTTagCompound aNBT = GT_Utility.ItemNBT.getNBT(aStack);
- tTileEntity
- .setOwnerInformation(aNBT.getString("mOwner"), aNBT.getString("mUUID"), aNBT.getBoolean("mOP"));
- }
- }
- return true;
- }
-}
diff --git a/src/main/java/gtPlusPlus/core/item/tool/misc/box/BaseBoxItem.java b/src/main/java/gtPlusPlus/core/item/tool/misc/box/BaseBoxItem.java
deleted file mode 100644
index 2679441d76..0000000000
--- a/src/main/java/gtPlusPlus/core/item/tool/misc/box/BaseBoxItem.java
+++ /dev/null
@@ -1,75 +0,0 @@
-package gtPlusPlus.core.item.tool.misc.box;
-
-import static gregtech.api.enums.Mods.GTPlusPlus;
-
-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;
-
-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.util.Utils;
-
-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(GTPlusPlus.ID + ":" + this.getUnlocalizedName().substring(5));
- }
-}
diff --git a/src/main/java/gtPlusPlus/core/item/tool/misc/box/ContainerBoxBase.java b/src/main/java/gtPlusPlus/core/item/tool/misc/box/ContainerBoxBase.java
deleted file mode 100644
index 3f24ba5e29..0000000000
--- a/src/main/java/gtPlusPlus/core/item/tool/misc/box/ContainerBoxBase.java
+++ /dev/null
@@ -1,314 +0,0 @@
-package gtPlusPlus.core.item.tool.misc.box;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-
-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.
- */
- @Override
- 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;
- }
-}
diff --git a/src/main/java/gtPlusPlus/core/item/tool/misc/box/CustomBoxInventory.java b/src/main/java/gtPlusPlus/core/item/tool/misc/box/CustomBoxInventory.java
deleted file mode 100644
index 858689f33d..0000000000
--- a/src/main/java/gtPlusPlus/core/item/tool/misc/box/CustomBoxInventory.java
+++ /dev/null
@@ -1,216 +0,0 @@
-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);
- }
-}