diff --git a/build.gradle b/build.gradle index 07420532..38ead8da 100644 --- a/build.gradle +++ b/build.gradle @@ -1,15 +1,10 @@ buildscript { repositories { mavenCentral() - jcenter() - //maven { - // name = "forge" - // url = "http://files.minecraftforge.net/maven" - //} - maven { - name = "gt" - url = "https://gregtech.overminddl1.com/" - } + maven { + name = "forge" + url = "http://files.minecraftforge.net/maven" + } maven { name = "sonatype" url = "https://oss.sonatype.org/content/repositories/snapshots/" @@ -20,30 +15,10 @@ buildscript { } } -// Because Forge is too stupid to fix Deprecation Issues, and we cannot fix it on our end! (until we fork Forge) -allprojects { - tasks.withType(JavaCompile) { - options.compilerArgs << "-Xlint:deprecation" - } -} - -apply plugin: 'eclipse' -eclipse { - classpath { - downloadJavadoc = true - downloadSources = true - } -} - -apply plugin: 'idea' -idea{ - module { - downloadJavadoc = true - downloadSources = true - } -} - apply plugin: 'forge' +apply plugin: 'idea' + +idea.module.inheritOutputDirs = true file "build.properties" withReader { def prop = new Properties() @@ -51,24 +26,24 @@ file "build.properties" withReader { ext.config = new ConfigSlurper().parse prop } +allprojects { + tasks.withType(JavaCompile) { + options.compilerArgs << "-Xlint:deprecation" + } +} + version = "${config.gt.version}" group= "gregtech" archivesBaseName = "gregtech" sourceCompatibility = 1.7 targetCompatibility = 1.7 -compileJava.options.bootClasspath = org.gradle.internal.jvm.Jvm.current().getJre().getHomeDir().toString() +"/lib/rt.jar" -compileJava { - options.encoding = "UTF-8" -} minecraft { version = "${config.minecraft.version}-${config.forge.version}" runDir = "eclipse" } -idea { module { inheritOutputDirs = true } } - configurations { provided embedded @@ -76,22 +51,41 @@ configurations { } repositories { - maven { - name = "gt" - url = "http://gregtech.overminddl1.com/" - } - maven { - name = "ic2" - url = "http://maven.ic2.player.to/" - } + //maven { + // name 'Forge' + // url 'http://files.minecraftforge.net/maven' + //} + maven { + name = "gt" + url = "https://gregtech.overminddl1.com/" + } + maven { + name = "chickenbones" + url = "http://chickenbones.net/maven/" + } + maven { + name = "ic2, forestry" + url = "http://maven.ic2.player.to/" + } + maven { // EnderIO & EnderCore + name 'tterrag Repo' + url "http://maven.tterrag.com" + } + maven { // AppleCore + url "http://www.ryanliptak.com/maven/" + } + maven { + name = "Covers (COFH)" + url = "http://maven.covers1624.net/" + } + maven { + name = "local" + url = "file:///C:/Users/michael/Documents/forge/maven/" + } } dependencies { -// compile fileTree(dir: 'libs', include: '*.jar') - - // Mostly Used for compileOnly, if you prefer normal IC2, uncomment it instead. - //provided "net.industrial-craft:industrialcraft-2:${config.ic2.version}:dev" - compile "ic2:IC2Classic:1.2.1.8:dev" + compile "ic2:IC2Classic:1.2.1.8:dev" compile "mcp.mobius.waila:Waila:1.5.11-RC2-NONEI_1.7.10:dev" compile "codechicken:CodeChickenLib:1.7.10-1.1.3.140:dev" @@ -116,7 +110,6 @@ dependencies { compileOnly "appeng:appliedenergistics2:rv3-beta-6:dev" compileOnly "applecore:AppleCore:1.7.10-3.1.1:deobf" compileOnly "com.shedar.IC2NuclearControl:IC2NuclearControl:2.4.3a:dev" - } processResources @@ -125,35 +118,34 @@ processResources inputs.property "version", project.version inputs.property "mcversion", project.minecraft.version - // replace stuff in mcmod.info, nothing else - from(sourceSets.main.resources.srcDirs) { + ext.srcFiles = "$projectDir/src/main/resources" + ext.destDir = "$projectDir/build/classes/main" + + // registering inputs & outputs allow gradle to skip if UP-TO-DATE + inputs.files srcFiles + outputs.dir destDir + + println 'starting processResources' + println 'srcFiles: ' + srcFiles + println 'destDir: ' + destDir + + + copy { + // replace stuff in mcmod.info, nothing else + from(srcFiles) + into(destDir) include 'mcmod.info' - - // replace version and mcversion - expand 'version':project.version, 'mcversion':project.minecraft.version + // replace version and mcversion + expand 'version': project.version, 'mcversion': project.minecraft.version + } - - // copy everything else, thats not the mcmod.info - from(sourceSets.main.resources.srcDirs) { + + + copy { + // copy everything else, thats not the mcmod.info + from(srcFiles) + into(destDir) exclude 'mcmod.info' - } - exclude '**/Thumbs.db' -} -task sourceJar(type: Jar) { - from sourceSets.main.allSource - classifier = 'sources' -} - -task devJar(type: Jar) { - from sourceSets.main.output - classifier = 'dev' - manifest { - //attributes 'FMLCorePlugin': 'WhateverLoaderClass' - //attributes 'FMLCorePluginContainsFMLMod': 'true' } } - -artifacts { - archives devJar -} \ No newline at end of file diff --git a/build.properties b/build.properties index 599c8cf0..939e084f 100644 --- a/build.properties +++ b/build.properties @@ -1,4 +1,24 @@ minecraft.version=1.7.10 -forge.version=10.13.4.1614-1.7.10 +forge.version=10.13.4.1566-1.7.10 + +gt.version=5.09.31.1 + +ae2.version=rv2-beta-33 +applecore.version=1.7.10-1.2.1+107.59407 +buildcraft.version=7.1.11 +codechickenlib.version=1.1.3.140 +codechickencore.version=1.0.7.47 +cofhcore.cf=2246/920 +cofhcore.version=[1.7.10]3.0.3-303-dev +cofhlib.cf=2246/918 +cofhlib.version=[1.7.10]1.0.3-175-dev +enderio.cf=2219/296 +enderio.version=1.7.10-2.3.0.417_beta +enderiocore.version=1.7.10-0.1.0.25_beta +forestry.version=4.2.10.58 ic2.version=2.2.790-experimental -gt.version=5.09.31 \ No newline at end of file +nei.version=1.0.3.57 +railcraft.cf=2219/321 +railcraft.version=1.7.10-9.4.0.0 +nc.cf=2275/987 +nc.version=2.3.4a \ No newline at end of file diff --git a/src/main/java/gregtech/api/items/GT_MetaGenerated_Item_X32.java b/src/main/java/gregtech/api/items/GT_MetaGenerated_Item_X32.java index a2ba451f..3869749a 100644 --- a/src/main/java/gregtech/api/items/GT_MetaGenerated_Item_X32.java +++ b/src/main/java/gregtech/api/items/GT_MetaGenerated_Item_X32.java @@ -7,6 +7,7 @@ import gregtech.api.enums.Materials; import gregtech.api.enums.OrePrefixes; import gregtech.api.interfaces.IIconContainer; 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 net.minecraft.creativetab.CreativeTabs; @@ -61,6 +62,7 @@ public abstract class GT_MetaGenerated_Item_X32 extends GT_MetaGenerated_Item { } if ((tPrefix == OrePrefixes.stick || tPrefix == OrePrefixes.wireFine || tPrefix == OrePrefixes.ingot) && (tMaterial == Materials.Lead || tMaterial == Materials.Tin || tMaterial == Materials.SolderingAlloy)) { GregTech_API.sSolderingMetalList.add(tStack); + GT_ModHandler.registerBoxableItemToToolBox(tStack); } } } diff --git a/src/main/java/gregtech/api/items/GT_MetaGenerated_Tool.java b/src/main/java/gregtech/api/items/GT_MetaGenerated_Tool.java index d8b09765..576480b2 100644 --- a/src/main/java/gregtech/api/items/GT_MetaGenerated_Tool.java +++ b/src/main/java/gregtech/api/items/GT_MetaGenerated_Tool.java @@ -78,7 +78,6 @@ public abstract class GT_MetaGenerated_Tool extends GT_MetaBase_Item implements */ public GT_MetaGenerated_Tool(String aUnlocalized) { super(aUnlocalized); - GT_ModHandler.registerBoxableItemToToolBox(this); setCreativeTab(GregTech_API.TAB_GREGTECH); setMaxStackSize(1); sInstances.put(getUnlocalizedName(), this); @@ -166,6 +165,7 @@ public abstract class GT_MetaGenerated_Tool extends GT_MetaBase_Item implements } if (GregTech_API.sThaumcraftCompat != null) GregTech_API.sThaumcraftCompat.registerThaumcraftAspectsToItem(rStack, tAspects, false); + GT_ModHandler.registerBoxableItemToToolBox(rStack); return rStack; } return null; diff --git a/src/main/java/gregtech/api/items/GT_Tool_Item.java b/src/main/java/gregtech/api/items/GT_Tool_Item.java index c6670349..98e376de 100644 --- a/src/main/java/gregtech/api/items/GT_Tool_Item.java +++ b/src/main/java/gregtech/api/items/GT_Tool_Item.java @@ -1,6 +1,7 @@ package gregtech.api.items; import gregtech.api.util.GT_ModHandler; +import net.minecraft.item.ItemStack; /** * This is just a basic Tool, which has normal durability and could break Blocks. @@ -20,6 +21,6 @@ public class GT_Tool_Item extends GT_Generic_Item { setMaxStackSize(1); setNoRepair(); setFull3D(); - GT_ModHandler.registerBoxableItemToToolBox(this); + GT_ModHandler.registerBoxableItemToToolBox(new ItemStack(this)); } } \ No newline at end of file diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Maintenance.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Maintenance.java index d7dcbdd9..76e2793c 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Maintenance.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Maintenance.java @@ -17,14 +17,22 @@ 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; import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.common.util.FakePlayer; + +import com.mojang.authlib.GameProfile; import java.util.Arrays; +import java.util.HashSet; import java.util.List; public class GT_MetaTileEntity_Hatch_Maintenance extends GT_MetaTileEntity_Hatch { @@ -110,12 +118,22 @@ public class GT_MetaTileEntity_Hatch_Maintenance extends GT_MetaTileEntity_Hatch } @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer, byte aSide, float aX, float aY, float aZ) { - if (aBaseMetaTileEntity.isClientSide()) return true; - if (aSide == aBaseMetaTileEntity.getFrontFacing()) aBaseMetaTileEntity.openGUI(aPlayer); + if (aBaseMetaTileEntity.isClientSide()) + return true; + if (aSide == aBaseMetaTileEntity.getFrontFacing()) { + // only allow OC robot fake player + if (aPlayer instanceof FakePlayer && !aPlayer.getGameProfile().getName().endsWith(".robot")) + return true; + if (aPlayer.getCurrentEquippedItem() != null && aPlayer.getCurrentEquippedItem().getItem() instanceof ItemToolbox) + applyToolbox(aPlayer.getCurrentEquippedItem(), aPlayer); + else + aBaseMetaTileEntity.openGUI(aPlayer); + } return true; } - + @Override public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { if (mAuto) return new GT_Container_2by2(aPlayerInventory, aBaseMetaTileEntity); @@ -185,19 +203,24 @@ public class GT_MetaTileEntity_Hatch_Maintenance extends GT_MetaTileEntity_Hatch return false; } - public void onToolClick(ItemStack aStack, EntityLivingBase aPlayer) { + public void onToolClick(ItemStack aStack, EntityLivingBase aPlayer, IInventory aToolboxInventory) { if (aStack == null || aPlayer == null) return; - if (GT_Utility.isStackInList(aStack, GregTech_API.sWrenchList) && GT_ModHandler.damageOrDechargeItem(aStack, 1, 1000, aPlayer)) + if (aStack.getItem() instanceof ItemToolbox && aPlayer instanceof EntityPlayer) { + applyToolbox(aStack, (EntityPlayer)aPlayer); + return; + } + 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, aToolboxInventory)) + mSolderingTool = true; if (GT_OreDictUnificator.isItemStackInstanceOf(aStack, "craftingDuctTape")) { mWrench = mScrewdriver = mSoftHammer = mHardHammer = mCrowbar = mSolderingTool = true; getBaseMetaTileEntity().setActive(false); @@ -211,6 +234,18 @@ public class GT_MetaTileEntity_Hatch_Maintenance extends GT_MetaTileEntity_Hatch } } } + + + public void onToolClick(ItemStack aStack, EntityLivingBase aPlayer) { + onToolClick(aStack, aPlayer, null); + } + + private void applyToolbox(ItemStack aStack, EntityPlayer aPlayer) { + ItemToolbox aToolbox = (ItemToolbox) aStack.getItem(); + IHasGui aToolboxGUI = aToolbox.getInventory(aPlayer, aStack); + for (int i=0; i sNativeRecipeClasses = new HashSet(), sSpecialRecipeClasses = new HashSet(); public static GT_HashSet sNonReplaceableItems = new GT_HashSet(); - public static Object sBoxableWrapper = GT_Utility.callConstructor("gregtechmod.api.util.GT_IBoxableWrapper", 0, null, false); + public static Object sBoxableWrapper = new GT_IBoxableWrapper(); + public static Collection sBoxableItems = new ArrayList<>(); private static Map sExtractorRecipes = new /*Concurrent*/HashMap(); private static Map sMaceratorRecipes = new /*Concurrent*/HashMap(); private static Map sCompressorRecipes = new /*Concurrent*/HashMap(); @@ -1810,47 +1812,68 @@ public class GT_ModHandler { /** * Uses a Soldering Iron */ - public static boolean useSolderingIron(ItemStack aStack, EntityLivingBase aPlayer) { - if (aPlayer == null || aStack == null) return false; - if (GT_Utility.isStackInList(aStack, GregTech_API.sSolderingToolList)) { - if (aPlayer instanceof EntityPlayer) { - EntityPlayer tPlayer = (EntityPlayer) aPlayer; - if (tPlayer.capabilities.isCreativeMode) return true; - if (isElectricItem(aStack) && ic2.api.item.ElectricItem.manager.getCharge(aStack) > 1000.0d) { - if (consumeSolderingMaterial(tPlayer)) { - if (canUseElectricItem(aStack, 10000)) { - return GT_ModHandler.useElectricItem(aStack, 10000, (EntityPlayer) aPlayer); + public static boolean useSolderingIron(ItemStack aStack, EntityLivingBase aPlayer, IInventory aExternalInventory) { + if (aPlayer == null || aStack == null) return false; + if (GT_Utility.isStackInList(aStack, GregTech_API.sSolderingToolList)) { + if (aPlayer instanceof EntityPlayer) { + EntityPlayer tPlayer = (EntityPlayer) aPlayer; + if (tPlayer.capabilities.isCreativeMode) return true; + if (isElectricItem(aStack) && ic2.api.item.ElectricItem.manager.getCharge(aStack) > 1000.0d) { + if (consumeSolderingMaterial(tPlayer) + || (aExternalInventory != null && consumeSolderingMaterial(aExternalInventory))) { + if (canUseElectricItem(aStack, 10000)) { + return GT_ModHandler.useElectricItem(aStack, 10000, (EntityPlayer) aPlayer); + } + GT_ModHandler.useElectricItem(aStack, (int) ic2.api.item.ElectricItem.manager.getCharge(aStack), (EntityPlayer) aPlayer); + return false; } - GT_ModHandler.useElectricItem(aStack, (int) ic2.api.item.ElectricItem.manager.getCharge(aStack), (EntityPlayer) aPlayer); - return false; - } + } + }else { + damageOrDechargeItem(aStack, 1, 1000, aPlayer); + return true; } - } else { - damageOrDechargeItem(aStack, 1, 1000, aPlayer); - return true; } + return false; } - return false; - } /** * Simply consumes some soldering material */ + public static boolean useSolderingIron(ItemStack aStack, EntityLivingBase aPlayer) { + return useSolderingIron(aStack, aPlayer, null); + } + public static boolean consumeSolderingMaterial(EntityPlayer aPlayer) { if (aPlayer.capabilities.isCreativeMode) return true; - for (int i = 0; i < aPlayer.inventory.mainInventory.length; i++) { - if (GT_Utility.isStackInList(aPlayer.inventory.mainInventory[i], GregTech_API.sSolderingMetalList)) { - if (aPlayer.inventory.mainInventory[i].stackSize < 1) return false; - if (aPlayer.inventory.mainInventory[i].stackSize == 1) { - aPlayer.inventory.mainInventory[i] = null; + if (consumeSolderingMaterial(aPlayer.inventory)) { + if (aPlayer.inventoryContainer != null) { + aPlayer.inventoryContainer.detectAndSendChanges(); + } + return true; + } + return false; + } + + /** + * Consumes soldering material from given inventory + */ + + public static boolean consumeSolderingMaterial(IInventory aInventory) { + for (int i = 0; i < aInventory.getSizeInventory(); i++) { + ItemStack tStack = aInventory.getStackInSlot(i); + if (GT_Utility.isStackInList(tStack, GregTech_API.sSolderingMetalList)) { + if (tStack.stackSize < 1) return false; + if (tStack.stackSize == 1) { + tStack = null; } else { - aPlayer.inventory.mainInventory[i].stackSize--; + tStack.stackSize--; } - if (aPlayer.inventoryContainer != null) aPlayer.inventoryContainer.detectAndSendChanges(); + aInventory.setInventorySlotContents(i, tStack); + aInventory.markDirty(); return true; } } - return false; + return false; } /** @@ -1882,8 +1905,17 @@ public class GT_ModHandler { return false; } + + /** + * Allow item to be inserted into ic2 toolbox + */ public static void registerBoxableItemToToolBox(ItemStack aStack) { - if (aStack != null) registerBoxableItemToToolBox(aStack.getItem()); + if (aStack != null) { + try { + ic2.api.item.ItemWrapper.registerBoxable(aStack.getItem(), (IBoxable) sBoxableWrapper); + } catch (Throwable ignored) {/*Do nothing*/} + sBoxableItems.add(new GT_ItemStack(aStack)); + } } public static void registerBoxableItemToToolBox(Item aItem) {