diff options
5 files changed, 251 insertions, 66 deletions
diff --git a/build.gradle b/build.gradle index b647108772..7914dd81b4 100644 --- a/build.gradle +++ b/build.gradle @@ -1,4 +1,4 @@ -//version: 1642484596 +//version: 1643020202 /* DO NOT CHANGE THIS FILE! @@ -32,16 +32,18 @@ buildscript { } } dependencies { - classpath 'com.github.GTNewHorizons:ForgeGradle:1.2.5' + classpath 'com.github.GTNewHorizons:ForgeGradle:1.2.7' } } plugins { id 'idea' + id 'eclipse' id 'scala' id("org.ajoberstar.grgit") version("3.1.1") id("com.github.johnrengelman.shadow") version("4.0.4") id("com.palantir.git-version") version("0.12.3") + id('de.undercouch.download') version('4.1.2') id("maven-publish") } @@ -172,6 +174,19 @@ else { archivesBaseName = modId } + +def arguments = [] +def jvmArguments = [] + +if(usesMixins.toBoolean()) { + arguments += [ + "--tweakClass org.spongepowered.asm.launch.MixinTweaker" + ] + jvmArguments += [ + "-Dmixin.debug.countInjections=true", "-Dmixin.debug.verbose=true", "-Dmixin.debug.export=true" + ] +} + minecraft { version = minecraftVersion + "-" + forgeVersion + "-" + minecraftVersion runDir = "run" @@ -191,6 +206,20 @@ minecraft { replace gradleTokenGroupName, modGroup } } + + clientIntellijRun { + args(arguments) + jvmArgs(jvmArguments) + + if(developmentEnvironmentUserName) { + args("--username", developmentEnvironmentUserName) + } + } + + serverIntellijRun { + args(arguments) + jvmArgs(jvmArguments) + } } if(file("addon.gradle").exists()) { @@ -322,15 +351,6 @@ afterEvaluate { } runClient { - def arguments = [] - - if(usesMixins.toBoolean()) { - arguments += [ - "--mods=../build/libs/$modId-${version}.jar", - "--tweakClass org.spongepowered.asm.launch.MixinTweaker" - ] - } - if(developmentEnvironmentUserName) { arguments += [ "--username", @@ -339,19 +359,12 @@ runClient { } args(arguments) + jvmArgs(jvmArguments) } runServer { - def arguments = [] - - if (usesMixins.toBoolean()) { - arguments += [ - "--mods=../build/libs/$modId-${version}.jar", - "--tweakClass org.spongepowered.asm.launch.MixinTweaker" - ] - } - args(arguments) + jvmArgs(jvmArguments) } tasks.withType(JavaExec).configureEach { @@ -494,11 +507,21 @@ artifacts { } } +// The gradle metadata includes all of the additional deps that we disabled from POM generation (including forgeBin with no groupID), +// and isn't strictly needed with the POM so just disable it. +tasks.withType(GenerateModuleMetadata) { + enabled = false +} + + // publishing publishing { publications { maven(MavenPublication) { - artifact source: usesShadowedDependencies.toBoolean() ? shadowJar : jar, classifier: "" + from components.java + if(usesShadowedDependencies.toBoolean()) { + artifact source: shadowJar, classifier: "" + } if(!noPublishedSources) { artifact source: sourcesJar, classifier: "src" } @@ -511,6 +534,18 @@ publishing { artifactId = System.getenv("ARTIFACT_ID") ?: project.name // Using the identified version, not project.version as it has the prepended 1.7.10 version = System.getenv("RELEASE_VERSION") ?: identifiedVersion + + // Remove all non GTNH deps here. + // Original intention was to remove an invalid forgeBin being generated without a groupId (mandatory), but + // it also removes all of the MC deps + pom.withXml { + Node pomNode = asNode() + pomNode.dependencies.'*'.findAll() { + it.groupId.text() != 'com.github.GTNewHorizons' + }.each() { + it.parent().remove(it) + } + } } } @@ -581,6 +616,72 @@ configure(updateBuildScript) { description = 'Updates the build script to the latest version' } +// Deobfuscation + +def deobf(String sourceURL) { + try { + URL url = new URL(sourceURL) + String fileName = url.getFile() + + //get rid of directories: + int lastSlash = fileName.lastIndexOf("/") + if(lastSlash > 0) { + fileName = fileName.substring(lastSlash + 1) + } + //get rid of extension: + if(fileName.endsWith(".jar")) { + fileName = fileName.substring(0, fileName.lastIndexOf(".")) + } + + String hostName = url.getHost() + if(hostName.startsWith("www.")) { + hostName = hostName.substring(4) + } + List parts = Arrays.asList(hostName.split("\\.")) + Collections.reverse(parts) + hostName = String.join(".", parts) + + return deobf(sourceURL, hostName + "/" + fileName) + } catch(Exception e) { + return deobf(sourceURL, "deobf/" + String.valueOf(sourceURL.hashCode())) + } +} + +// The method above is to be prefered. Use this method if the filename is not at the end of the URL. +def deobf(String sourceURL, String fileName) { + String cacheDir = System.getProperty("user.home") + "/.gradle/caches/" + String bon2Dir = cacheDir + "forge_gradle/deobf" + String bon2File = bon2Dir + "/BON2-2.5.0.jar" + String obfFile = cacheDir + "modules-2/files-2.1/" + fileName + ".jar" + String deobfFile = cacheDir + "modules-2/files-2.1/" + fileName + "-deobf.jar" + + if(file(deobfFile).exists()) { + return files(deobfFile) + } + + download { + src 'https://github.com/GTNewHorizons/BON2/releases/download/2.5.0/BON2-2.5.0.CUSTOM-all.jar' + dest bon2File + quiet true + overwrite false + } + + download { + src sourceURL + dest obfFile + quiet true + overwrite false + } + + exec { + commandLine 'java', '-jar', bon2File, '--inputJar', obfFile, '--outputJar', deobfFile, '--mcVer', '1.7.10', '--mappingsVer', 'stable_12', '--notch' + workingDir bon2Dir + standardOutput = new ByteArrayOutputStream() + } + + return files(deobfFile) +} + // Helper methods def checkPropertyExists(String propertyName) { diff --git a/dependencies.gradle b/dependencies.gradle index 3aa0e982f2..298fd97adf 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -1,17 +1,11 @@ // Add your dependencies here dependencies { - compile("com.github.GTNewHorizons:GT5-Unofficial:5.09.40.18:dev") - compile("com.github.GTNewHorizons:StructureLib:1.0.14:dev") - compileOnly("com.github.GTNewHorizons:NotEnoughItems:2.1.22-GTNH:dev") { - transitive = false - } - compileOnly("com.github.GTNewHorizons:CodeChickenCore:1.1.3:dev") { - transitive = false - } - compileOnly("com.github.GTNewHorizons:CodeChickenLib:1.1.5.1:dev") { - transitive = false - } + compile("com.github.GTNewHorizons:GT5-Unofficial:5.09.40.19:dev") + compile("com.github.GTNewHorizons:StructureLib:1.0.15:dev") + compile("com.github.GTNewHorizons:NotEnoughItems:2.2.3-GTNH:dev") + compile("com.github.GTNewHorizons:CodeChickenCore:1.1.3:dev") + compile("com.github.GTNewHorizons:CodeChickenLib:1.1.5.1:dev") compile("net.industrial-craft:industrialcraft-2:2.2.828-experimental:dev") compile("curse.maven:cofh-core-69162:2388751") @@ -23,7 +17,7 @@ dependencies { compileOnly("com.github.GTNewHorizons:Baubles:1.0.1.14:dev") { transitive = false } - compileOnly("com.github.GTNewHorizons:ForestryMC:4.4.4:dev") { + compileOnly("com.github.GTNewHorizons:ForestryMC:4.4.5:dev") { transitive = false } compileOnly("com.github.GTNewHorizons:Railcraft:9.13.5:dev") { diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialDehydrator.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialDehydrator.java index 4147f58e36..fabbfbe388 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialDehydrator.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialDehydrator.java @@ -75,7 +75,7 @@ public class GregtechMetaTileEntity_IndustrialDehydrator extends GregtechMeta_Mu .addInfo("Upgraded overclocks reduce recipe time to 25% and increase EU/t to 400%") .addPollutionAmount(getPollutionPerSecond(null)) .addSeparator() - .beginStructureBlock(3, 4, 3, true) + .beginStructureBlock(3, 5, 3, true) .addController("Bottom Center") .addCasingInfo(mCasingName, 10) .addInputBus("Any Casing", 1) diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntityTreeFarm.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntityTreeFarm.java index 2b5320de20..4fc13e3ce3 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntityTreeFarm.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntityTreeFarm.java @@ -1,7 +1,6 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production; -import codechicken.nei.ItemStackMap; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; import com.gtnewhorizon.structurelib.structure.StructureDefinition; import gregtech.api.enums.Materials; @@ -14,18 +13,19 @@ import gregtech.api.items.GT_MetaGenerated_Tool; import gregtech.api.metatileentity.implementations.*; import gregtech.api.render.TextureFactory; import gregtech.api.util.*; -import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.math.MathUtils; -import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; import gtPlusPlus.xmod.gregtech.common.helpers.TreeFarmHelper; import gtPlusPlus.xmod.gregtech.common.helpers.treefarm.TreeGenerator; import net.minecraft.init.Blocks; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import java.util.HashMap; + import static com.gtnewhorizon.structurelib.structure.StructureUtility.*; import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; @@ -34,8 +34,14 @@ public class GregtechMetaTileEntityTreeFarm extends GregtechMeta_MultiBlockBase< public static int CASING_TEXTURE_ID; public static String mCasingName = "Sterile Farm Casing"; public static TreeGenerator mTreeData; + private ItemStack mTreeType; private int mCasing; private IStructureDefinition<GregtechMetaTileEntityTreeFarm> STRUCTURE_DEFINITION = null; + private HashMap<String, ItemStack> sLogCache = new HashMap<String, ItemStack>(); + + private ItemStack currSapling; + private int currSlot = 0; + private GT_MetaTileEntity_Hatch_InputBus currInputBus; static { new Thread("GTPP-TreeDataWorker") { @@ -74,6 +80,7 @@ public class GregtechMetaTileEntityTreeFarm extends GregtechMeta_MultiBlockBase< .addInfo("Converts EU to Oak Logs") .addInfo("Eu Usage: 100% | Parallel: 1") .addInfo("Requires a Saw or Chainsaw in GUI slot") + .addInfo("Add a sapling in the input bus to change wood type output") .addPollutionAmount(getPollutionPerSecond(null)) .addSeparator() .beginStructureBlock(3, 3, 3, true) @@ -122,50 +129,47 @@ public class GregtechMetaTileEntityTreeFarm extends GregtechMeta_MultiBlockBase< } public boolean checkRecipe(final ItemStack aStack) { - if (mTreeData == null) - // not finished somehow - return false; + if (aStack == null && !replaceTool()) // no tool return false; if (!isCorrectMachinePart(aStack)) // not a tool return false; - if (mTreeData != null) { - - long tVoltage = getMaxInputVoltage(); - byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); - this.mMaxProgresstime = 100; - this.mEUt = (int) tVoltage; + long tVoltage = getMaxInputVoltage(); + byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); - this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); - this.mEfficiencyIncrease = 10000; + this.mMaxProgresstime = 100; + this.mEUt = (int) tVoltage; - // Overclock - if (this.mEUt <= 16) { - this.mEUt = (this.mEUt * (1 << tTier - 1) * (1 << tTier - 1)); - this.mMaxProgresstime = (this.mMaxProgresstime / (1 << tTier - 1)); - } else { - while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) { - this.mEUt *= 4; - this.mMaxProgresstime /= 2; - } - } + this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiencyIncrease = 10000; - if (this.mEUt > 0) { - this.mEUt = (-this.mEUt); + // Overclock + if (this.mEUt <= 16) { + this.mEUt = (this.mEUt * (1 << tTier - 1) * (1 << tTier - 1)); + this.mMaxProgresstime = (this.mMaxProgresstime / (1 << tTier - 1)); + } else { + while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) { + this.mEUt *= 4; + this.mMaxProgresstime /= 2; } + } + if (this.mEUt > 0) { + this.mEUt = (-this.mEUt); + } - int aChance = MathUtils.randInt(0, 10); + /* Old Methods with FakeWorld + int aChance = MathUtils.randInt(0, 10); try { if (aChance < 8) { ItemStackMap<Integer> allOutputs = new ItemStackMap<>(); if (aLeaves == null) aLeaves = ItemUtils.getSimpleStack(Blocks.leaves); - //1% Chance per Tick + //1% Chance per Tick for (int u = 0; u < (Math.max(4, (MathUtils.randInt((3 * tTier), 100) * tTier * tTier) / 14)); u++) { AutoMap<ItemStack> aOutputs = mTreeData.generateOutput(0); if (aOutputs.size() > 0) { @@ -187,13 +191,23 @@ public class GregtechMetaTileEntityTreeFarm extends GregtechMeta_MultiBlockBase< } } catch (Throwable t) { t.printStackTrace(GT_Log.err); + */ + getWoodFromSapling(); + try { + int outputAmount = ((2 * (tTier * tTier)) - (2 * tTier) + 5)*(mMaxProgresstime/20); + int lastStack = outputAmount % 64; + mTreeType.stackSize = 64; + for (int i = 0; i < (outputAmount - lastStack) / 64; i++) { + this.addOutput(mTreeType); } - return true; - } else { - return false; + mTreeType.stackSize = lastStack; + this.addOutput(mTreeType); + this.updateSlots(); + } catch (Throwable t) { + t.printStackTrace(GT_Log.err); } + return true; } - @Override public boolean checkHatch() { return super.checkHatch() && mEnergyHatches.size() == 1; @@ -283,6 +297,80 @@ public class GregtechMetaTileEntityTreeFarm extends GregtechMeta_MultiBlockBase< return false; } + public void getWoodFromSapling() { + if(sLogCache.size() == 0) + loadMapWoodFromSapling(); + + if(this.currSapling != null && this.currInputBus != null){ + ItemStack uStack = this.currInputBus.mInventory[this.currSlot]; + if(uStack == this.currSapling) + return; + } + for (GT_MetaTileEntity_Hatch_InputBus mInputBus : this.mInputBusses) { + for (int i = 0; i < mInputBus.mInventory.length; i++) { + ItemStack uStack = mInputBus.mInventory[i]; + if(uStack != null) { + String registryName = Item.itemRegistry.getNameForObject(uStack.getItem()); + ItemStack aWood = sLogCache.get(registryName + ":" + uStack.getItemDamage()); + if (aWood != null) { + this.currSapling = uStack; + this.currInputBus = mInputBus; + this.currSlot = i; + this.mTreeType = aWood; + return; + } + } + } + this.mTreeType = new ItemStack(Blocks.log, 1,0); //default to oak wood + } + } + + public void loadMapWoodFromSapling() { + + //minecraft + sLogCache.put("minecraft:sapling:0", new ItemStack(Blocks.log, 1, 0)); //oak + sLogCache.put("minecraft:sapling:1", new ItemStack(Blocks.log, 1, 1)); //spruce + sLogCache.put("minecraft:sapling:2", new ItemStack(Blocks.log, 1, 2)); //birch + sLogCache.put("minecraft:sapling:3", new ItemStack(Blocks.log, 1, 3)); //jungle + sLogCache.put("minecraft:sapling:4", new ItemStack(Blocks.log2, 1, 0)); //acacia + sLogCache.put("minecraft:sapling:5", new ItemStack(Blocks.log2, 1, 1)); //dark oak + + //galaxySpace + sLogCache.put("GalaxySpace:barnardaCsapling:0", GT_ModHandler.getModItem("GalaxySpace", "barnardaClog", 1)); //barnarda c + + //ic2 + sLogCache.put("IC2:blockRubSapling:0", GT_ModHandler.getModItem("IC2", "blockRubWood", 1)); //rubber + + //natura + sLogCache.put("Natura:florasapling:1", GT_ModHandler.getModItem("Natura","tree", 1, 0)); //eucalyptus + sLogCache.put("Natura:florasapling:2", GT_ModHandler.getModItem("Natura","tree", 1, 3)); //hopseed + sLogCache.put("Natura:florasapling:3", GT_ModHandler.getModItem("Natura","tree", 1, 1)); //sakura + sLogCache.put("Natura:florasapling:4", GT_ModHandler.getModItem("Natura","tree", 1, 2)); //ghostwood + sLogCache.put("Natura:florasapling:5", GT_ModHandler.getModItem("Natura","bloodwood", 1, 0)); //bloodwood + sLogCache.put("Natura:florasapling:6", GT_ModHandler.getModItem("Natura","Dark Tree", 1, 0)); //darkwood + sLogCache.put("Natura:florasapling:7", GT_ModHandler.getModItem("Natura","Dark Tree", 1, 1)); //fusewood + + sLogCache.put("Natura:Rare Sapling:0", GT_ModHandler.getModItem("Natura","Rare Tree", 1, 0)); //maple + sLogCache.put("Natura:Rare Sapling:1", GT_ModHandler.getModItem("Natura","Rare Tree", 1, 1)); //silverbell + sLogCache.put("Natura:Rare Sapling:2", GT_ModHandler.getModItem("Natura","Rare Tree", 1, 2)); //amaranth + sLogCache.put("Natura:Rare Sapling:3", GT_ModHandler.getModItem("Natura","Rare Tree", 1, 3)); //tigerwood + sLogCache.put("Natura:Rare Sapling:4", GT_ModHandler.getModItem("Natura","willow", 1, 0)); //willow + + //TConstruct + sLogCache.put("TConstruct:slime.sapling:0", GT_ModHandler.getModItem("TConstruct","slime.gel", 1)); //green slime blocks + + //TaintedMagic + sLogCache.put("TaintedMagic:BlockWarpwoodSapling:0", GT_ModHandler.getModItem("TaintedMagic","BlockWarpwoodLog", 1)); //warpwood + + //Thaumcraft + sLogCache.put("Thaumcraft:blockCustomPlant:0", GT_ModHandler.getModItem("Thaumcraft","blockMagicalLog", 1, 0)); //greatwood + sLogCache.put("Thaumcraft:blockCustomPlant:0", GT_ModHandler.getModItem("Thaumcraft","blockMagicalLog", 1, 1)); //silverwood + + //gt++ + sLogCache.put("miscutils:blockRainforestOakSapling:0", GT_ModHandler.getModItem("miscutils","blockRainforestOakLog", 1)); //gt++ rainforest + sLogCache.put("miscutils:blockPineSapling:0", GT_ModHandler.getModItem("miscutils","blockPineLogLog", 1)); //gt++ pine + } + public boolean tryDamageTool(ItemStack invItem) { if (invItem != null && invItem.getItem() instanceof GT_MetaGenerated_Tool) { long aDmg = GT_MetaGenerated_Tool.getToolDamage(invItem); diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_Cyclotron.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_Cyclotron.java index 82f3d14426..09bee76272 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_Cyclotron.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_Cyclotron.java @@ -203,6 +203,8 @@ public class GregtechMetaTileEntity_Cyclotron extends GregtechMeta_MultiBlockBas IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus && ((GT_MetaTileEntity_Hatch_InputBus) aMetaTileEntity).mTier >= 5){ return addToMachineList(aTileEntity, aBaseCasingIndex); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Output && ((GT_MetaTileEntity_Hatch_Output) aMetaTileEntity).mTier >= 5) { + return addToMachineList(aTileEntity, aBaseCasingIndex); } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance){ return addToMachineList(aTileEntity, aBaseCasingIndex); } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Energy && ((GT_MetaTileEntity_Hatch_Energy) aMetaTileEntity).mTier >= 5){ |