Skip to content

Commit e5a1362

Browse files
authored
Use normal chest when ironchest not installed (#44)
* Use normal chest when ironchest not installed mostly useful in dev env, as pulling in ironchest is something we usually don't want As a consequence, ironchest is now a runtimeOnly dependency * Revert incorrect substitute
1 parent 6c0e093 commit e5a1362

File tree

12 files changed

+167
-61
lines changed

12 files changed

+167
-61
lines changed

build.gradle

Lines changed: 122 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//version: 1642484596
1+
//version: 1643020202
22
/*
33
DO NOT CHANGE THIS FILE!
44
@@ -32,16 +32,18 @@ buildscript {
3232
}
3333
}
3434
dependencies {
35-
classpath 'com.github.GTNewHorizons:ForgeGradle:1.2.5'
35+
classpath 'com.github.GTNewHorizons:ForgeGradle:1.2.7'
3636
}
3737
}
3838

3939
plugins {
4040
id 'idea'
41+
id 'eclipse'
4142
id 'scala'
4243
id("org.ajoberstar.grgit") version("3.1.1")
4344
id("com.github.johnrengelman.shadow") version("4.0.4")
4445
id("com.palantir.git-version") version("0.12.3")
46+
id('de.undercouch.download') version('4.1.2')
4547
id("maven-publish")
4648
}
4749

@@ -172,6 +174,19 @@ else {
172174
archivesBaseName = modId
173175
}
174176

177+
178+
def arguments = []
179+
def jvmArguments = []
180+
181+
if(usesMixins.toBoolean()) {
182+
arguments += [
183+
"--tweakClass org.spongepowered.asm.launch.MixinTweaker"
184+
]
185+
jvmArguments += [
186+
"-Dmixin.debug.countInjections=true", "-Dmixin.debug.verbose=true", "-Dmixin.debug.export=true"
187+
]
188+
}
189+
175190
minecraft {
176191
version = minecraftVersion + "-" + forgeVersion + "-" + minecraftVersion
177192
runDir = "run"
@@ -191,6 +206,20 @@ minecraft {
191206
replace gradleTokenGroupName, modGroup
192207
}
193208
}
209+
210+
clientIntellijRun {
211+
args(arguments)
212+
jvmArgs(jvmArguments)
213+
214+
if(developmentEnvironmentUserName) {
215+
args("--username", developmentEnvironmentUserName)
216+
}
217+
}
218+
219+
serverIntellijRun {
220+
args(arguments)
221+
jvmArgs(jvmArguments)
222+
}
194223
}
195224

196225
if(file("addon.gradle").exists()) {
@@ -322,15 +351,6 @@ afterEvaluate {
322351
}
323352

324353
runClient {
325-
def arguments = []
326-
327-
if(usesMixins.toBoolean()) {
328-
arguments += [
329-
"--mods=../build/libs/$modId-${version}.jar",
330-
"--tweakClass org.spongepowered.asm.launch.MixinTweaker"
331-
]
332-
}
333-
334354
if(developmentEnvironmentUserName) {
335355
arguments += [
336356
"--username",
@@ -339,19 +359,12 @@ runClient {
339359
}
340360

341361
args(arguments)
362+
jvmArgs(jvmArguments)
342363
}
343364

344365
runServer {
345-
def arguments = []
346-
347-
if (usesMixins.toBoolean()) {
348-
arguments += [
349-
"--mods=../build/libs/$modId-${version}.jar",
350-
"--tweakClass org.spongepowered.asm.launch.MixinTweaker"
351-
]
352-
}
353-
354366
args(arguments)
367+
jvmArgs(jvmArguments)
355368
}
356369

357370
tasks.withType(JavaExec).configureEach {
@@ -494,11 +507,21 @@ artifacts {
494507
}
495508
}
496509

510+
// The gradle metadata includes all of the additional deps that we disabled from POM generation (including forgeBin with no groupID),
511+
// and isn't strictly needed with the POM so just disable it.
512+
tasks.withType(GenerateModuleMetadata) {
513+
enabled = false
514+
}
515+
516+
497517
// publishing
498518
publishing {
499519
publications {
500520
maven(MavenPublication) {
501-
artifact source: usesShadowedDependencies.toBoolean() ? shadowJar : jar, classifier: ""
521+
from components.java
522+
if(usesShadowedDependencies.toBoolean()) {
523+
artifact source: shadowJar, classifier: ""
524+
}
502525
if(!noPublishedSources) {
503526
artifact source: sourcesJar, classifier: "src"
504527
}
@@ -511,6 +534,18 @@ publishing {
511534
artifactId = System.getenv("ARTIFACT_ID") ?: project.name
512535
// Using the identified version, not project.version as it has the prepended 1.7.10
513536
version = System.getenv("RELEASE_VERSION") ?: identifiedVersion
537+
538+
// Remove all non GTNH deps here.
539+
// Original intention was to remove an invalid forgeBin being generated without a groupId (mandatory), but
540+
// it also removes all of the MC deps
541+
pom.withXml {
542+
Node pomNode = asNode()
543+
pomNode.dependencies.'*'.findAll() {
544+
it.groupId.text() != 'com.github.GTNewHorizons'
545+
}.each() {
546+
it.parent().remove(it)
547+
}
548+
}
514549
}
515550
}
516551

@@ -581,6 +616,72 @@ configure(updateBuildScript) {
581616
description = 'Updates the build script to the latest version'
582617
}
583618

619+
// Deobfuscation
620+
621+
def deobf(String sourceURL) {
622+
try {
623+
URL url = new URL(sourceURL)
624+
String fileName = url.getFile()
625+
626+
//get rid of directories:
627+
int lastSlash = fileName.lastIndexOf("/")
628+
if(lastSlash > 0) {
629+
fileName = fileName.substring(lastSlash + 1)
630+
}
631+
//get rid of extension:
632+
if(fileName.endsWith(".jar")) {
633+
fileName = fileName.substring(0, fileName.lastIndexOf("."))
634+
}
635+
636+
String hostName = url.getHost()
637+
if(hostName.startsWith("www.")) {
638+
hostName = hostName.substring(4)
639+
}
640+
List parts = Arrays.asList(hostName.split("\\."))
641+
Collections.reverse(parts)
642+
hostName = String.join(".", parts)
643+
644+
return deobf(sourceURL, hostName + "/" + fileName)
645+
} catch(Exception e) {
646+
return deobf(sourceURL, "deobf/" + String.valueOf(sourceURL.hashCode()))
647+
}
648+
}
649+
650+
// The method above is to be prefered. Use this method if the filename is not at the end of the URL.
651+
def deobf(String sourceURL, String fileName) {
652+
String cacheDir = System.getProperty("user.home") + "/.gradle/caches/"
653+
String bon2Dir = cacheDir + "forge_gradle/deobf"
654+
String bon2File = bon2Dir + "/BON2-2.5.0.jar"
655+
String obfFile = cacheDir + "modules-2/files-2.1/" + fileName + ".jar"
656+
String deobfFile = cacheDir + "modules-2/files-2.1/" + fileName + "-deobf.jar"
657+
658+
if(file(deobfFile).exists()) {
659+
return files(deobfFile)
660+
}
661+
662+
download {
663+
src 'https://github.com/GTNewHorizons/BON2/releases/download/2.5.0/BON2-2.5.0.CUSTOM-all.jar'
664+
dest bon2File
665+
quiet true
666+
overwrite false
667+
}
668+
669+
download {
670+
src sourceURL
671+
dest obfFile
672+
quiet true
673+
overwrite false
674+
}
675+
676+
exec {
677+
commandLine 'java', '-jar', bon2File, '--inputJar', obfFile, '--outputJar', deobfFile, '--mcVer', '1.7.10', '--mappingsVer', 'stable_12', '--notch'
678+
workingDir bon2Dir
679+
standardOutput = new ByteArrayOutputStream()
680+
}
681+
682+
return files(deobfFile)
683+
}
684+
584685
// Helper methods
585686

586687
def checkPropertyExists(String propertyName) {

dependencies.gradle

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
dependencies {
2-
compile("com.github.GTNewHorizons:GT5-Unofficial:5.09.40.17:dev")
3-
compile("com.github.GTNewHorizons:TinkersConstruct:1.9.0.10-GTNH:dev")
4-
compile("com.github.GTNewHorizons:ironchest:6.0.68:dev")
5-
compile("com.github.GTNewHorizons:CodeChickenLib:1.1.5.1:dev")
6-
compile("com.github.GTNewHorizons:NotEnoughItems:2.1.22-GTNH:dev")
2+
compile("com.github.GTNewHorizons:GT5-Unofficial:5.09.40.25:dev")
3+
compile("com.github.GTNewHorizons:TinkersConstruct:1.9.0.12-GTNH:dev")
4+
compile("com.github.GTNewHorizons:NotEnoughItems:2.2.3-GTNH:dev")
75
compile("net.industrial-craft:industrialcraft-2:2.2.828-experimental:dev")
86

97
compileOnly("com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-70-GTNH:api") {
@@ -27,4 +25,6 @@ dependencies {
2725
compileOnly("curse.maven:mekanism-268560:2475797") {
2826
transitive = false
2927
}
28+
29+
runtimeOnly("com.github.GTNewHorizons:ironchest:6.0.68:dev")
3030
}

src/main/java/micdoodle8/mods/galacticraft/core/inventory/SlotBuggyBench.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
package micdoodle8.mods.galacticraft.core.inventory;
22

33
import cpw.mods.fml.common.registry.GameRegistry;
4-
import cpw.mods.ironchest.IronChest;
54
import micdoodle8.mods.galacticraft.core.Constants;
65
import micdoodle8.mods.galacticraft.core.GalacticraftCore;
76
import micdoodle8.mods.galacticraft.core.items.GCItems;
87
import micdoodle8.mods.galacticraft.core.network.PacketSimple;
98
import micdoodle8.mods.galacticraft.core.network.PacketSimple.EnumSimplePacket;
9+
import micdoodle8.mods.galacticraft.core.util.RecipeUtil;
1010
import net.minecraft.entity.player.EntityPlayer;
1111
import net.minecraft.entity.player.EntityPlayerMP;
1212
import net.minecraft.inventory.IInventory;
@@ -75,7 +75,7 @@ public boolean isItemValid(ItemStack itemStack) {
7575
} else if(index >= 25 && index <= 34) {
7676
return itemStack.getItem() == GCItems.heavyPlatingTier1;
7777
} else if(index == 35) {
78-
return itemStack.getItem() == Item.getItemFromBlock(IronChest.ironChestBlock) && (itemStack.getItemDamage() == 0 || itemStack.getItemDamage() == 1 || itemStack.getItemDamage() == 3);
78+
return itemStack.getItem() == Item.getItemFromBlock(RecipeUtil.getChestBlock()) && (itemStack.getItemDamage() == 0 || itemStack.getItemDamage() == 1 || itemStack.getItemDamage() == 3);
7979
} else {
8080
return false;
8181
}

src/main/java/micdoodle8/mods/galacticraft/core/nei/NEIGalacticraftConfig.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import codechicken.nei.PositionedStack;
44
import codechicken.nei.api.API;
55
import codechicken.nei.api.IConfigureNEI;
6-
import cpw.mods.ironchest.IronChest;
76
import gregtech.api.enums.Materials;
87
import gregtech.api.enums.OrePrefixes;
98
import gregtech.api.util.GT_ModHandler;
@@ -14,6 +13,7 @@
1413
import micdoodle8.mods.galacticraft.core.blocks.GCBlocks;
1514
import micdoodle8.mods.galacticraft.core.items.GCItems;
1615
import micdoodle8.mods.galacticraft.core.util.ConfigManagerCore;
16+
import micdoodle8.mods.galacticraft.core.util.RecipeUtil;
1717
import net.minecraft.block.Block;
1818
import net.minecraft.init.Blocks;
1919
import net.minecraft.init.Items;
@@ -193,13 +193,13 @@ private void addBuggyRecipes()
193193
input.put(34, new PositionedStack(new ItemStack(GCItems.heavyPlatingTier1), 80 - x, 91 - y));
194194
registerBuggyBenchRecipe(input, new PositionedStack(new ItemStack(GCItems.buggy), 143 - x, 64 - y));
195195
HashMap<Integer, PositionedStack> input2 = new HashMap<>(input);
196-
input2.put(35, new PositionedStack(new ItemStack(IronChest.ironChestBlock, 1, 3), 107 - x, 64 - y));
196+
input2.put(35, new PositionedStack(RecipeUtil.getChestItemStack(1, 3), 107 - x, 64 - y));
197197
registerBuggyBenchRecipe(input2, new PositionedStack(new ItemStack(GCItems.buggy, 1, 1), 143 - x, 64 - y));
198198
input2 = new HashMap<>(input);
199-
input2.put(35, new PositionedStack(new ItemStack(IronChest.ironChestBlock), 107 - x, 64 - y));
199+
input2.put(35, new PositionedStack(RecipeUtil.getChestItemStack(1, 0), 107 - x, 64 - y));
200200
registerBuggyBenchRecipe(input2, new PositionedStack(new ItemStack(GCItems.buggy, 1, 2), 143 - x, 64 - y));
201201
input2 = new HashMap<>(input);
202-
input2.put(35, new PositionedStack(new ItemStack(IronChest.ironChestBlock, 1, 1), 107 - x, 64 - y));
202+
input2.put(35, new PositionedStack(RecipeUtil.getChestItemStack(1, 1), 107 - x, 64 - y));
203203
registerBuggyBenchRecipe(input2, new PositionedStack(new ItemStack(GCItems.buggy, 1, 3), 143 - x, 64 - y));
204204
}
205205

src/main/java/micdoodle8/mods/galacticraft/core/recipe/RecipeManagerGC.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package micdoodle8.mods.galacticraft.core.recipe;
22

33
import cpw.mods.fml.common.Loader;
4-
import cpw.mods.ironchest.IronChest;
54
import gregtech.api.GregTech_API;
65
import gregtech.api.enums.Materials;
76
import gregtech.api.enums.OrePrefixes;
@@ -31,7 +30,6 @@
3130
import net.minecraft.item.ItemStack;
3231
import net.minecraft.item.crafting.CraftingManager;
3332
import net.minecraft.item.crafting.FurnaceRecipes;
34-
import net.minecraftforge.fluids.FluidRegistry;
3533
import net.minecraftforge.oredict.OreDictionary;
3634
import net.minecraftforge.oredict.ShapelessOreRecipe;
3735

@@ -197,15 +195,15 @@ private static void addUniversalRecipes()
197195
RecipeUtil.addBuggyBenchRecipe(new ItemStack(GCItems.buggy, 1, 0), input2);
198196

199197
input2 = new HashMap<Integer, ItemStack>(input);
200-
input2.put(35, new ItemStack(IronChest.ironChestBlock, 1, 3));
198+
input2.put(35, RecipeUtil.getChestItemStack(1, 3));
201199
RecipeUtil.addBuggyBenchRecipe(new ItemStack(GCItems.buggy, 1, 1), input2);
202200

203201
input2 = new HashMap<Integer, ItemStack>(input);
204-
input2.put(35, new ItemStack(IronChest.ironChestBlock));
202+
input2.put(35, RecipeUtil.getChestItemStack(1, 0));
205203
RecipeUtil.addBuggyBenchRecipe(new ItemStack(GCItems.buggy, 1, 2), input2);
206204

207205
input2 = new HashMap<Integer, ItemStack>(input);
208-
input2.put(35, new ItemStack(IronChest.ironChestBlock, 1, 1));
206+
input2.put(35, RecipeUtil.getChestItemStack(1, 1));
209207
RecipeUtil.addBuggyBenchRecipe(new ItemStack(GCItems.buggy, 1, 3), input2);
210208

211209
aluminumIngots.addAll(OreDictionary.getOres("ingotAluminum"));

src/main/java/micdoodle8/mods/galacticraft/core/util/RecipeUtil.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
package micdoodle8.mods.galacticraft.core.util;
22

3+
import cpw.mods.fml.common.registry.GameRegistry;
34
import ic2.api.item.IC2Items;
45
import micdoodle8.mods.galacticraft.api.GalacticraftRegistry;
56
import micdoodle8.mods.galacticraft.api.recipe.INasaWorkbenchRecipe;
67
import micdoodle8.mods.galacticraft.core.inventory.InventoryBuggyBench;
78
import micdoodle8.mods.galacticraft.core.inventory.InventoryRocketBench;
89
import micdoodle8.mods.galacticraft.core.recipe.NasaWorkbenchRecipe;
10+
import net.minecraft.block.Block;
11+
import net.minecraft.init.Blocks;
912
import net.minecraft.item.ItemStack;
1013
import net.minecraft.item.crafting.CraftingManager;
1114
import net.minecraftforge.oredict.OreDictionary;
@@ -74,4 +77,15 @@ public static ItemStack getIndustrialCraftItem(String indentifier)
7477
{
7578
return IC2Items.getItem(indentifier);
7679
}
80+
81+
public static Block getChestBlock() {
82+
Block block = GameRegistry.findBlock("IronChest", "BlockIronChest");
83+
if (block == null)
84+
block = Blocks.chest;
85+
return block;
86+
}
87+
public static ItemStack getChestItemStack(int size, int meta) {
88+
Block block = getChestBlock();
89+
return new ItemStack(block, size, meta);
90+
}
7791
}

src/main/java/micdoodle8/mods/galacticraft/planets/asteroids/AsteroidsModule.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import cpw.mods.fml.common.registry.GameRegistry;
66
import cpw.mods.fml.common.registry.LanguageRegistry;
77
import cpw.mods.fml.relauncher.Side;
8-
import cpw.mods.ironchest.IronChest;
98
import gregtech.api.util.GT_ModHandler;
109
import micdoodle8.mods.galacticraft.api.GalacticraftRegistry;
1110
import micdoodle8.mods.galacticraft.api.galaxies.CelestialBody;
@@ -18,6 +17,7 @@
1817
import micdoodle8.mods.galacticraft.core.items.GCItems;
1918
import micdoodle8.mods.galacticraft.core.items.ItemCanisterGeneric;
2019
import micdoodle8.mods.galacticraft.core.recipe.NasaWorkbenchRecipe;
20+
import micdoodle8.mods.galacticraft.core.util.RecipeUtil;
2121
import micdoodle8.mods.galacticraft.planets.GuiIdsPlanets;
2222
import micdoodle8.mods.galacticraft.planets.IPlanetsModule;
2323
import micdoodle8.mods.galacticraft.planets.asteroids.blocks.AsteroidBlocks;
@@ -45,7 +45,6 @@
4545
import micdoodle8.mods.galacticraft.planets.mars.items.MarsItems;
4646
import net.minecraft.block.Block;
4747
import net.minecraft.entity.player.EntityPlayer;
48-
import net.minecraft.init.Blocks;
4948
import net.minecraft.item.ItemStack;
5049
import net.minecraft.tileentity.TileEntity;
5150
import net.minecraft.util.ResourceLocation;
@@ -251,8 +250,8 @@ public void init(FMLInitializationEvent event)
251250
for(int i = 21; i <= 23; i++) {
252251
input.put(i, new ItemStack(GCItems.heavyPlatingTier1));
253252
}
254-
input.put(24, new ItemStack(IronChest.ironChestBlock, 1, 1));
255-
input.put(25, new ItemStack(IronChest.ironChestBlock, 1, 1));
253+
input.put(24, RecipeUtil.getChestItemStack(1, 1));
254+
input.put(25, RecipeUtil.getChestItemStack(1, 1));
256255
input.put(26, new ItemStack(AsteroidsItems.basicItem, 1, 8));
257256
input.put(27, new ItemStack(AsteroidBlocks.beamReceiver));
258257
input.put(28, GT_ModHandler.getModItem(Constants.MOD_ID_GREGTECH, "gt.metaitem.01", 1, 32603));

0 commit comments

Comments
 (0)