Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor Fixes. #1592

Open
wants to merge 3 commits into
base: unstable
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
minecraft.version=1.7.10
forge.version=10.13.4.1614-1.7.10
ic2.version=2.2.790-experimental
ic2.version=2.2.817-experimental
gt.version=5.09.31
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
import gregtech.api.util.GT_ModHandler;
import gregtech.api.util.GT_OreDictUnificator;
import gregtech.api.util.GT_Utility;
import ic2.core.IHasGui;
import ic2.core.Ic2Items;
import ic2.core.item.ItemToolbox;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
Expand All @@ -25,6 +28,7 @@
import net.minecraft.nbt.NBTTagCompound;

import java.util.Arrays;
import java.util.HashSet;
import java.util.List;

public class GT_MetaTileEntity_Hatch_Maintenance extends GT_MetaTileEntity_Hatch {
Expand Down Expand Up @@ -186,18 +190,38 @@ public boolean autoMaintainance() {
}

public void onToolClick(ItemStack aStack, EntityLivingBase aPlayer) {
if (aStack == null || aPlayer == null) return;
if (GT_Utility.isStackInList(aStack, GregTech_API.sWrenchList) && GT_ModHandler.damageOrDechargeItem(aStack, 1, 1000, aPlayer))
if (aStack == null || aPlayer == null) return;

// Allow IC2 Toolbox with tools to function for maint issues.
if (aStack.getItem() instanceof ItemToolbox && aPlayer instanceof EntityPlayer) {
EntityPlayer aPlayerEntity = (EntityPlayer) aPlayer;
ItemToolbox aToolbox = (ItemToolbox) aStack.getItem();
IHasGui aToolboxGUI = aToolbox.getInventory(aPlayerEntity, aStack);
HashSet<ItemStack> aToolboxContents = new HashSet<ItemStack>();
for (int i=0; i<aToolboxGUI.getSizeInventory(); i++) {
ItemStack aTemp = aToolboxGUI.getStackInSlot(i);
if (aTemp != null) {
aToolboxContents.add(aTemp);
}
}
if (!aToolboxContents.isEmpty()) {
for (ItemStack aTool : aToolboxContents) {
onToolClick(aTool, aPlayer);
}
}
}

if (GT_Utility.isStackInList(aStack, GregTech_API.sWrenchList) && !mWrench && GT_ModHandler.damageOrDechargeItem(aStack, 1, 1000, aPlayer))
mWrench = true;
if (GT_Utility.isStackInList(aStack, GregTech_API.sScrewdriverList) && GT_ModHandler.damageOrDechargeItem(aStack, 1, 1000, aPlayer))
if (GT_Utility.isStackInList(aStack, GregTech_API.sScrewdriverList) && !mScrewdriver && GT_ModHandler.damageOrDechargeItem(aStack, 1, 1000, aPlayer))
mScrewdriver = true;
if (GT_Utility.isStackInList(aStack, GregTech_API.sSoftHammerList) && GT_ModHandler.damageOrDechargeItem(aStack, 1, 1000, aPlayer))
if (GT_Utility.isStackInList(aStack, GregTech_API.sSoftHammerList) && !mSoftHammer && GT_ModHandler.damageOrDechargeItem(aStack, 1, 1000, aPlayer))
mSoftHammer = true;
if (GT_Utility.isStackInList(aStack, GregTech_API.sHardHammerList) && GT_ModHandler.damageOrDechargeItem(aStack, 1, 1000, aPlayer))
if (GT_Utility.isStackInList(aStack, GregTech_API.sHardHammerList) && !mHardHammer && GT_ModHandler.damageOrDechargeItem(aStack, 1, 1000, aPlayer))
mHardHammer = true;
if (GT_Utility.isStackInList(aStack, GregTech_API.sCrowbarList) && GT_ModHandler.damageOrDechargeItem(aStack, 1, 1000, aPlayer))
if (GT_Utility.isStackInList(aStack, GregTech_API.sCrowbarList) && !mCrowbar && GT_ModHandler.damageOrDechargeItem(aStack, 1, 1000, aPlayer))
mCrowbar = true;
if (GT_ModHandler.useSolderingIron(aStack, aPlayer)) mSolderingTool = true;
if (!mSolderingTool && GT_ModHandler.useSolderingIron(aStack, aPlayer)) mSolderingTool = true;
if (GT_OreDictUnificator.isItemStackInstanceOf(aStack, "craftingDuctTape")) {
mWrench = mScrewdriver = mSoftHammer = mHardHammer = mCrowbar = mSolderingTool = true;
getBaseMetaTileEntity().setActive(false);
Expand Down
8 changes: 5 additions & 3 deletions src/main/java/gregtech/api/util/GT_ModHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public class GT_ModHandler {
public static volatile int VERSION = 509;
public static Collection<String> sNativeRecipeClasses = new HashSet<String>(), sSpecialRecipeClasses = new HashSet<String>();
public static GT_HashSet<GT_ItemStack> sNonReplaceableItems = new GT_HashSet<GT_ItemStack>();
public static Object sBoxableWrapper = GT_Utility.callConstructor("gregtechmod.api.util.GT_IBoxableWrapper", 0, null, false);
public static Object sBoxableWrapper = new GT_IBoxableWrapper();
private static Map<IRecipeInput, RecipeOutput> sExtractorRecipes = new /*Concurrent*/HashMap<IRecipeInput, RecipeOutput>();
private static Map<IRecipeInput, RecipeOutput> sMaceratorRecipes = new /*Concurrent*/HashMap<IRecipeInput, RecipeOutput>();
private static Map<IRecipeInput, RecipeOutput> sCompressorRecipes = new /*Concurrent*/HashMap<IRecipeInput, RecipeOutput>();
Expand Down Expand Up @@ -1886,11 +1886,13 @@ public static void registerBoxableItemToToolBox(ItemStack aStack) {
if (aStack != null) registerBoxableItemToToolBox(aStack.getItem());
}

public static void registerBoxableItemToToolBox(Item aItem) {
public static void registerBoxableItemToToolBox(Item aItem) {
if (aItem != null && sBoxableWrapper != null) {
try {
ic2.api.item.ItemWrapper.registerBoxable(aItem, (IBoxable) sBoxableWrapper);
} catch (Throwable e) {/*Do nothing*/}
} catch (Throwable e) {
e.printStackTrace();
}
}
}

Expand Down