Implemented support for IC2 Toolbox to fix Maint. issues.

This commit is contained in:
Alkalus 2021-11-12 18:00:15 +00:00
parent 4e1beb536a
commit d7ea46e594

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,7 +190,27 @@ public class GT_MetaTileEntity_Hatch_Maintenance extends GT_MetaTileEntity_Hatch
}
public void onToolClick(ItemStack aStack, EntityLivingBase aPlayer) {
if (aStack == null || aPlayer == null) return;
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) && GT_ModHandler.damageOrDechargeItem(aStack, 1, 1000, aPlayer))
mWrench = true;
if (GT_Utility.isStackInList(aStack, GregTech_API.sScrewdriverList) && GT_ModHandler.damageOrDechargeItem(aStack, 1, 1000, aPlayer))