From 73cc1fa5f474d3d1c7fc2ebb5db2b69be8f937aa Mon Sep 17 00:00:00 2001 From: DrParadox7 Date: Sun, 29 Jan 2023 21:36:42 +0100 Subject: [PATCH 1/8] Added API for Chemical Injection Chamber This allows other mods to modify the valid gases and items to gasify for their own recipe --- .../mekanism/api/gas/GasifyableItems.java | 41 +++++++++++++++++++ src/main/java/mekanism/common/Mekanism.java | 16 ++++---- .../TileEntityChemicalInjectionChamber.java | 16 ++++---- 3 files changed, 57 insertions(+), 16 deletions(-) create mode 100644 src/main/java/mekanism/api/gas/GasifyableItems.java diff --git a/src/main/java/mekanism/api/gas/GasifyableItems.java b/src/main/java/mekanism/api/gas/GasifyableItems.java new file mode 100644 index 000000000..a17641391 --- /dev/null +++ b/src/main/java/mekanism/api/gas/GasifyableItems.java @@ -0,0 +1,41 @@ +package mekanism.api.gas; + +import mekanism.common.util.MekanismUtils; +import net.minecraft.item.ItemStack; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.List; + +public class GasifyableItems { + + static HashMap gasifyableItems = new HashMap(); + static List validGases = new ArrayList<>(); + + public static void registerGasifyables(String oredict, Gas gas, Integer quantity) { + System.out.println("oredict = " + oredict); + System.out.println("gas = " + gas); + System.out.println("quantity = " + quantity); + + GasStack gasifyEntry = new GasStack(gas, quantity); + + gasifyableItems.put(oredict, gasifyEntry); + validGases.add(gas); + } + + public static GasStack getGasFromItem(ItemStack itemstack) { + + List oredict = MekanismUtils.getOreDictName(itemstack); + + for (String s : oredict) { + if (gasifyableItems.containsKey(s)) + return gasifyableItems.get(s); + } + return null; + } + + public static boolean isGasValidGasifyable(Gas gas) { + return validGases.contains(gas); + } +} diff --git a/src/main/java/mekanism/common/Mekanism.java b/src/main/java/mekanism/common/Mekanism.java index c68b6267f..f22e96f98 100644 --- a/src/main/java/mekanism/common/Mekanism.java +++ b/src/main/java/mekanism/common/Mekanism.java @@ -18,11 +18,8 @@ import mekanism.api.MekanismAPI.BoxBlacklistEvent; import mekanism.api.MekanismConfig; import mekanism.api.MekanismConfig.general; import mekanism.api.MekanismConfig.usage; -import mekanism.api.gas.Gas; +import mekanism.api.gas.*; import mekanism.api.gas.GasNetwork.GasTransferEvent; -import mekanism.api.gas.GasRegistry; -import mekanism.api.gas.GasStack; -import mekanism.api.gas.OreGas; import mekanism.api.infuse.InfuseObject; import mekanism.api.infuse.InfuseRegistry; import mekanism.api.infuse.InfuseType; @@ -1440,14 +1437,19 @@ public class Mekanism FluidRegistry.registerFluid(new Fluid("heavyWater")); FluidRegistry.registerFluid(new Fluid("steam").setGaseous(true)); - for(Resource resource : Resource.values()) - { + for(Resource resource : Resource.values()) { String name = resource.getName(); - OreGas clean = (OreGas)GasRegistry.register(new OreGas("clean" + name, "oregas." + name.toLowerCase()).setVisible(false)); + OreGas clean = (OreGas) GasRegistry.register(new OreGas("clean" + name, "oregas." + name.toLowerCase()).setVisible(false)); GasRegistry.register(new OreGas(name.toLowerCase(), "oregas." + name.toLowerCase()).setCleanGas(clean).setVisible(false)); } + //Register Gasifyable Items + GasifyableItems.registerGasifyables("dustSulfur", GasRegistry.getGas("sulfuricAcid"), 2); + GasifyableItems.registerGasifyables("dustSalt", GasRegistry.getGas("hydrogenChloride"), 2); + GasifyableItems.registerGasifyables("dustSugar", GasRegistry.getGas("molasse"), 90); + GasifyableItems.registerGasifyables("listAllSugar", GasRegistry.getGas("molasse"), 90); + Mekanism.proxy.preInit(); //Register blocks and items diff --git a/src/main/java/mekanism/common/tile/TileEntityChemicalInjectionChamber.java b/src/main/java/mekanism/common/tile/TileEntityChemicalInjectionChamber.java index eb5be0323..58bfa7b55 100644 --- a/src/main/java/mekanism/common/tile/TileEntityChemicalInjectionChamber.java +++ b/src/main/java/mekanism/common/tile/TileEntityChemicalInjectionChamber.java @@ -4,11 +4,7 @@ import java.util.Map; import mekanism.api.EnumColor; import mekanism.api.MekanismConfig.usage; -import mekanism.api.gas.Gas; -import mekanism.api.gas.GasRegistry; -import mekanism.api.gas.GasStack; -import mekanism.api.gas.GasTransmission; -import mekanism.api.gas.IGasItem; +import mekanism.api.gas.*; import mekanism.api.transmitters.TransmissionType; import mekanism.common.MekanismBlocks; import mekanism.common.SideData; @@ -43,9 +39,11 @@ public class TileEntityChemicalInjectionChamber extends TileEntityAdvancedElectr @Override public GasStack getItemGas(ItemStack itemstack) { - if(MekanismUtils.getOreDictName(itemstack).contains("dustSulfur")) return new GasStack(GasRegistry.getGas("sulfuricAcid"), 2); - if(MekanismUtils.getOreDictName(itemstack).contains("dustSalt")) return new GasStack(GasRegistry.getGas("hydrogenChloride"), 2); - if(MekanismUtils.getOreDictName(itemstack).contains("dustSugar") || MekanismUtils.getOreDictName(itemstack).contains("listAllSugar")) return new GasStack(GasRegistry.getGas("molasse"), 90); + if (GasifyableItems.getGasFromItem(itemstack) != null) { + System.out.println(GasifyableItems.getGasFromItem(itemstack).getGas().getUnlocalizedName()); + return GasifyableItems.getGasFromItem(itemstack); + } + else if(Block.getBlockFromItem(itemstack.getItem()) == MekanismBlocks.GasTank && ((IGasItem)itemstack.getItem()).getGas(itemstack) != null && isValidGas(((IGasItem)itemstack.getItem()).getGas(itemstack).getGas())) return new GasStack(GasRegistry.getGas("sulfuricAcid"), 1); @@ -102,7 +100,7 @@ public class TileEntityChemicalInjectionChamber extends TileEntityAdvancedElectr @Override public boolean isValidGas(Gas gas) { - return gas == GasRegistry.getGas("sulfuricAcid") || gas == GasRegistry.getGas("water") || gas == GasRegistry.getGas("hydrogenChloride")|| gas == GasRegistry.getGas("molasse"); + return (gas == GasRegistry.getGas("water") || GasifyableItems.isGasValidGasifyable(gas)); } @Override From b13b81f6b15f3aeed80aca36acb8c95d35aa93b7 Mon Sep 17 00:00:00 2001 From: DrParadox7 Date: Sun, 29 Jan 2023 21:36:42 +0100 Subject: [PATCH 2/8] Added API for Chemical Injection Chamber This allows other mods to modify the valid gases and items to gasify for their own recipe --- .../mekanism/api/gas/GasifyableItems.java | 37 +++++++++++++++++++ src/main/java/mekanism/common/Mekanism.java | 16 ++++---- .../TileEntityChemicalInjectionChamber.java | 16 ++++---- 3 files changed, 53 insertions(+), 16 deletions(-) create mode 100644 src/main/java/mekanism/api/gas/GasifyableItems.java diff --git a/src/main/java/mekanism/api/gas/GasifyableItems.java b/src/main/java/mekanism/api/gas/GasifyableItems.java new file mode 100644 index 000000000..4548c32d9 --- /dev/null +++ b/src/main/java/mekanism/api/gas/GasifyableItems.java @@ -0,0 +1,37 @@ +package mekanism.api.gas; + +import mekanism.common.util.MekanismUtils; +import net.minecraft.item.ItemStack; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.List; + +public class GasifyableItems { + + static HashMap gasifyableItems = new HashMap(); + static List validGases = new ArrayList<>(); + + public static void registerGasifyables(String oredict, Gas gas, Integer quantity) { + GasStack gasifyEntry = new GasStack(gas, quantity); + + gasifyableItems.put(oredict, gasifyEntry); + validGases.add(gas); + } + + public static GasStack getGasFromItem(ItemStack itemstack) { + + List oredict = MekanismUtils.getOreDictName(itemstack); + + for (String s : oredict) { + if (gasifyableItems.containsKey(s)) + return gasifyableItems.get(s); + } + return null; + } + + public static boolean isGasValidGasifyable(Gas gas) { + return validGases.contains(gas); + } +} diff --git a/src/main/java/mekanism/common/Mekanism.java b/src/main/java/mekanism/common/Mekanism.java index c68b6267f..f22e96f98 100644 --- a/src/main/java/mekanism/common/Mekanism.java +++ b/src/main/java/mekanism/common/Mekanism.java @@ -18,11 +18,8 @@ import mekanism.api.MekanismAPI.BoxBlacklistEvent; import mekanism.api.MekanismConfig; import mekanism.api.MekanismConfig.general; import mekanism.api.MekanismConfig.usage; -import mekanism.api.gas.Gas; +import mekanism.api.gas.*; import mekanism.api.gas.GasNetwork.GasTransferEvent; -import mekanism.api.gas.GasRegistry; -import mekanism.api.gas.GasStack; -import mekanism.api.gas.OreGas; import mekanism.api.infuse.InfuseObject; import mekanism.api.infuse.InfuseRegistry; import mekanism.api.infuse.InfuseType; @@ -1440,14 +1437,19 @@ public class Mekanism FluidRegistry.registerFluid(new Fluid("heavyWater")); FluidRegistry.registerFluid(new Fluid("steam").setGaseous(true)); - for(Resource resource : Resource.values()) - { + for(Resource resource : Resource.values()) { String name = resource.getName(); - OreGas clean = (OreGas)GasRegistry.register(new OreGas("clean" + name, "oregas." + name.toLowerCase()).setVisible(false)); + OreGas clean = (OreGas) GasRegistry.register(new OreGas("clean" + name, "oregas." + name.toLowerCase()).setVisible(false)); GasRegistry.register(new OreGas(name.toLowerCase(), "oregas." + name.toLowerCase()).setCleanGas(clean).setVisible(false)); } + //Register Gasifyable Items + GasifyableItems.registerGasifyables("dustSulfur", GasRegistry.getGas("sulfuricAcid"), 2); + GasifyableItems.registerGasifyables("dustSalt", GasRegistry.getGas("hydrogenChloride"), 2); + GasifyableItems.registerGasifyables("dustSugar", GasRegistry.getGas("molasse"), 90); + GasifyableItems.registerGasifyables("listAllSugar", GasRegistry.getGas("molasse"), 90); + Mekanism.proxy.preInit(); //Register blocks and items diff --git a/src/main/java/mekanism/common/tile/TileEntityChemicalInjectionChamber.java b/src/main/java/mekanism/common/tile/TileEntityChemicalInjectionChamber.java index eb5be0323..58bfa7b55 100644 --- a/src/main/java/mekanism/common/tile/TileEntityChemicalInjectionChamber.java +++ b/src/main/java/mekanism/common/tile/TileEntityChemicalInjectionChamber.java @@ -4,11 +4,7 @@ import java.util.Map; import mekanism.api.EnumColor; import mekanism.api.MekanismConfig.usage; -import mekanism.api.gas.Gas; -import mekanism.api.gas.GasRegistry; -import mekanism.api.gas.GasStack; -import mekanism.api.gas.GasTransmission; -import mekanism.api.gas.IGasItem; +import mekanism.api.gas.*; import mekanism.api.transmitters.TransmissionType; import mekanism.common.MekanismBlocks; import mekanism.common.SideData; @@ -43,9 +39,11 @@ public class TileEntityChemicalInjectionChamber extends TileEntityAdvancedElectr @Override public GasStack getItemGas(ItemStack itemstack) { - if(MekanismUtils.getOreDictName(itemstack).contains("dustSulfur")) return new GasStack(GasRegistry.getGas("sulfuricAcid"), 2); - if(MekanismUtils.getOreDictName(itemstack).contains("dustSalt")) return new GasStack(GasRegistry.getGas("hydrogenChloride"), 2); - if(MekanismUtils.getOreDictName(itemstack).contains("dustSugar") || MekanismUtils.getOreDictName(itemstack).contains("listAllSugar")) return new GasStack(GasRegistry.getGas("molasse"), 90); + if (GasifyableItems.getGasFromItem(itemstack) != null) { + System.out.println(GasifyableItems.getGasFromItem(itemstack).getGas().getUnlocalizedName()); + return GasifyableItems.getGasFromItem(itemstack); + } + else if(Block.getBlockFromItem(itemstack.getItem()) == MekanismBlocks.GasTank && ((IGasItem)itemstack.getItem()).getGas(itemstack) != null && isValidGas(((IGasItem)itemstack.getItem()).getGas(itemstack).getGas())) return new GasStack(GasRegistry.getGas("sulfuricAcid"), 1); @@ -102,7 +100,7 @@ public class TileEntityChemicalInjectionChamber extends TileEntityAdvancedElectr @Override public boolean isValidGas(Gas gas) { - return gas == GasRegistry.getGas("sulfuricAcid") || gas == GasRegistry.getGas("water") || gas == GasRegistry.getGas("hydrogenChloride")|| gas == GasRegistry.getGas("molasse"); + return (gas == GasRegistry.getGas("water") || GasifyableItems.isGasValidGasifyable(gas)); } @Override From a00903dae520583da27308639b3537f9069b8084 Mon Sep 17 00:00:00 2001 From: maggi373 <40539743+maggi373@users.noreply.github.com> Date: Sun, 29 Jan 2023 22:29:59 +0100 Subject: [PATCH 3/8] mek dev building --- .github/workflows/gradle.yml | 26 ++++++++++++++++---------- .github/workflows/maven.yml | 1 + build.gradle | 6 +++--- 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index 6fa4daa8f..96fe50611 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -17,13 +17,19 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - name: Set up JDK 8 - uses: actions/setup-java@v2 - with: - java-version: '8' - distribution: 'adopt' - - name: Grant execute permission for gradlew - run: chmod +x gradlew - - name: Build with Gradle - run: ./gradlew fullbuild + - uses: actions/checkout@v2 + - name: Set up JDK 8 + uses: actions/setup-java@v2 + with: + java-version: '8' + distribution: 'adopt' + - name: Grant execute permission for gradlew + run: chmod +x gradlew + - name: Build and Publish + run: ./gradlew fullbuild artifactoryPublish + env: + MAVEN_URL: ${{ secrets.MAVEN_URL }} + MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }} + MAVEN_PASSWORD: ${{ secrets.MAVEN_TOKEN }} + MAVEN_REPO: ${{ secrets.MAVEN_DEVREPO }} + BUILD_VER: ${{ github.run_number }} diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index e76d82625..abad95469 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -26,3 +26,4 @@ jobs: MAVEN_URL: ${{ secrets.MAVEN_URL }} MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }} MAVEN_PASSWORD: ${{ secrets.MAVEN_TOKEN }} + MAVEN_REPO: ${{ secrets.MAVEN_REPO }} diff --git a/build.gradle b/build.gradle index d5328dbc4..bfaefa2ff 100644 --- a/build.gradle +++ b/build.gradle @@ -175,7 +175,7 @@ artifactory { contextUrl = System.getenv("MAVEN_URL") publish { repository { - repoKey = 'thorfusion' + repoKey = System.getenv("MAVEN_REPO") username = System.getenv("MAVEN_USERNAME") password = System.getenv("MAVEN_PASSWORD") maven = true @@ -189,7 +189,7 @@ artifactory { } resolve { repository { - repoKey = 'central' + repoKey = System.getenv("MAVEN_REPO") username = System.getenv("MAVEN_USERNAME") password = System.getenv("MAVEN_PASSWORD") maven = true @@ -203,7 +203,7 @@ publishing { mavenJava(MavenPublication) { artifactId = project.archivesBaseName groupId = project.group - version = project.version + version = project.version + System.getenv("BUILD_VER") artifacts = [toolsJar, coreJar, generatorsJar, MDKZip, alltJar, apiJar] components.java.withVariantsFromConfiguration(configurations.runtimeElements) { skip() From c7c398cecd8e30c83418f01930c534fc522e9261 Mon Sep 17 00:00:00 2001 From: maggi373 <40539743+maggi373@users.noreply.github.com> Date: Sun, 29 Jan 2023 22:36:05 +0100 Subject: [PATCH 4/8] Update gradle.yml --- .github/workflows/gradle.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index 96fe50611..72c4a5643 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -32,4 +32,4 @@ jobs: MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }} MAVEN_PASSWORD: ${{ secrets.MAVEN_TOKEN }} MAVEN_REPO: ${{ secrets.MAVEN_DEVREPO }} - BUILD_VER: ${{ github.run_number }} + BUILD_VER: '-' + ${{ github.run_number }} From 0cddd7b4101eacc5349ab2e84f1f9d879f8a5424 Mon Sep 17 00:00:00 2001 From: maggi373 <40539743+maggi373@users.noreply.github.com> Date: Sun, 29 Jan 2023 22:40:20 +0100 Subject: [PATCH 5/8] Update gradle.yml --- .github/workflows/gradle.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index 72c4a5643..cd327efe9 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -32,4 +32,4 @@ jobs: MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }} MAVEN_PASSWORD: ${{ secrets.MAVEN_TOKEN }} MAVEN_REPO: ${{ secrets.MAVEN_DEVREPO }} - BUILD_VER: '-' + ${{ github.run_number }} + BUILD_VER: '-${{ github.run_number }}' From c171df5c1803030b348d0509b24722c450ce11ad Mon Sep 17 00:00:00 2001 From: maggi373 <40539743+maggi373@users.noreply.github.com> Date: Tue, 31 Jan 2023 01:59:14 +0100 Subject: [PATCH 6/8] fix null in versioning for release builds for maven --- build.gradle | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index bfaefa2ff..79c51d293 100644 --- a/build.gradle +++ b/build.gradle @@ -203,7 +203,11 @@ publishing { mavenJava(MavenPublication) { artifactId = project.archivesBaseName groupId = project.group - version = project.version + System.getenv("BUILD_VER") + if (System.getenv("BUILD_VER") == null){ + version = project.version + } else { + version = project.version + System.getenv("BUILD_VER") + } artifacts = [toolsJar, coreJar, generatorsJar, MDKZip, alltJar, apiJar] components.java.withVariantsFromConfiguration(configurations.runtimeElements) { skip() From 1869e5c4c127ca2e6912f3d76edfca97c2218c99 Mon Sep 17 00:00:00 2001 From: maggi373 <40539743+maggi373@users.noreply.github.com> Date: Tue, 31 Jan 2023 16:30:09 +0100 Subject: [PATCH 7/8] Update README.md --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 8d195bbc5..030c25383 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,7 @@ You will find the files inside ./output/ ## Mod examples on how to use the new api for MEK:CE + [Thorfusion/TerralizationCompat](https://github.com/Thorfusion/TerralizationCompat) + [Thorfusion/Titanpower](https://github.com/Thorfusion/Titanpower) +Also visit our [wiki](https://github.com/Thorfusion/Mekanism-Community-Edition/wiki/API) explaining how to use the new MEK:CE api ## Official Modpacks ### [Terralization](https://www.technicpack.net/modpack/terralization.654195) @@ -29,6 +30,8 @@ You need to include the [LICENSE](https://raw.githubusercontent.com/Thorfusion/M Mekanism CE has continued the use of the update notifier but changed the config name to v2. This is to notify people making the switch to CE of this feature. It is recommended for modpacks to disable this. +Also visit our [wiki](https://github.com/Thorfusion/Mekanism-Community-Edition/wiki/Configuration) regarding configuration. + ## Required Dependencies Mekanism CE also has two dependencies that it requires, as a modpack creator DO NOT USE the automatic downloader to get those file. It puts alot of strain to my server network. From 48cbc918d214331eb7ebc7c522d1cd81a5b62f21 Mon Sep 17 00:00:00 2001 From: maggi373 <40539743+maggi373@users.noreply.github.com> Date: Tue, 31 Jan 2023 16:30:26 +0100 Subject: [PATCH 8/8] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 030c25383..aa4093a21 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,7 @@ You will find the files inside ./output/ ## Mod examples on how to use the new api for MEK:CE + [Thorfusion/TerralizationCompat](https://github.com/Thorfusion/TerralizationCompat) + [Thorfusion/Titanpower](https://github.com/Thorfusion/Titanpower) + Also visit our [wiki](https://github.com/Thorfusion/Mekanism-Community-Edition/wiki/API) explaining how to use the new MEK:CE api ## Official Modpacks