Compare commits

...

3 commits

Author SHA1 Message Date
Alkalus
76bceb8b83 Only damage tools when doing maintenance if they actually need to be. 2021-11-12 18:23:42 +00:00
Alkalus
d7ea46e594 Implemented support for IC2 Toolbox to fix Maint. issues. 2021-11-12 18:00:15 +00:00
Alkalus
4e1beb536a Updated IC2 version.
Fixed IC2 IBoxable handler.
2021-11-12 17:32:28 +00:00
3 changed files with 37 additions and 11 deletions

View file

@ -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

View file

@ -17,6 +17,9 @@ import gregtech.api.objects.GT_RenderedTexture;
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;
@ -25,6 +28,7 @@ import net.minecraft.item.ItemStack;
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 {
@ -186,18 +190,38 @@ public class GT_MetaTileEntity_Hatch_Maintenance extends GT_MetaTileEntity_Hatch
}
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);

View file

@ -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>();
@ -1886,11 +1886,13 @@ public class GT_ModHandler {
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();
}
}
}