Skip to content

Commit

Permalink
Fix TR compat recipes, and add automagically generated compat KubeJS …
Browse files Browse the repository at this point in the history
…scripts
  • Loading branch information
Technici4n committed Jul 8, 2021
1 parent 6036a08 commit 8af1b6f
Show file tree
Hide file tree
Showing 9 changed files with 309 additions and 28 deletions.
10 changes: 9 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,14 @@ repositories {
content {
includeGroup "net.fabricmc.fabric-api"
includeGroup "dev.technici4n"
includeGroup "dev.latvian.mods"
}
}
maven {
url "https://maven.saps.dev/minecraft"
content {
includeGroup "dev.latvian.mods"
includeGroup "dev.ftb.mods"
}
}
// for reach entity attributes, required by Magna
Expand Down Expand Up @@ -141,7 +149,7 @@ dependencies {
modImplementation "me.sargunvohra.mcmods:autoconfig1u:${project.auto_config_version}"
include "me.sargunvohra.mcmods:autoconfig1u:${project.auto_config_version}"
modRuntime "com.terraformersmc:modmenu:${project.mod_menu_version}"
//modImplementation "curse.maven:kubejs-395864:${project.kubejs_file}"
modImplementation "dev.latvian.mods:kubejs-fabric:1605.3.10-build.9999"
//modImplementation "curse.maven:architectury-fabric-419697:${project.architectury_file}"
//modRuntime "curse.maven:rhino-416294:${project.rhino_file}"
include modImplementation("com.github.Draylar:magna:${project.magna_version}") {
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ org.gradle.jvmargs=-Xmx1G \
wthit_version=3.6.0
auto_config_version=3.3.1
mod_menu_version=2.0.2
kubejs_file=3211038
architectury_file=3218916
kubejs_file=3355296
architectury_file=3376069
rhino_file=3187177
arrp_version=0.2.9
ftl_version=0.5.2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import aztech.modern_industrialization.api.pipes.item.SpeedUpgrade;
import aztech.modern_industrialization.blocks.forgehammer.ForgeHammerScreen;
import aztech.modern_industrialization.blocks.tank.CreativeTankSetup;
import aztech.modern_industrialization.debug.DumpUnificationScriptCommand;
import aztech.modern_industrialization.debug.MissingTranslationsCommand;
import aztech.modern_industrialization.inventory.ConfigurableInventoryPacketHandlers;
import aztech.modern_industrialization.inventory.ConfigurableInventoryPackets;
Expand Down Expand Up @@ -190,7 +191,9 @@ private void setupTooltips() {
}

private void setupClientCommands() {
ClientCommandManager.DISPATCHER
.register(literal("miclient").then(literal("dump_missing_translations").executes(MissingTranslationsCommand::run)));
ClientCommandManager.DISPATCHER.register(literal("miclient")//
.then(literal("dump_missing_translations").executes(MissingTranslationsCommand::run))//
.then(literal("dump_unification_script").executes(DumpUnificationScriptCommand::run))//
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,37 +25,30 @@

import aztech.modern_industrialization.MIIdentifier;
import aztech.modern_industrialization.ModernIndustrialization;
import java.util.Arrays;
import java.util.List;
import aztech.modern_industrialization.materials.Material;
import aztech.modern_industrialization.materials.MaterialRegistry;
import aztech.modern_industrialization.materials.part.MIParts;
import net.fabricmc.loader.api.FabricLoader;

// TODO: can this cursed class be improved?
public class RecipeCompat {
private static final List<String> CURVED_PLATES = Arrays.asList("aluminum", "battery_alloy", "bronze", "copper", "electrum", "gold", "iron",
"lead", "nickel", "silver", "stainless_steel", "steel", "tin", "titanium");

public static void loadCompatRecipes() {
if (FabricLoader.getInstance().isModLoaded("techreborn")) {
ModernIndustrialization.LOGGER.info("Tech Reborn is detected, loading compatibility recipes for Modern Industrialization!");

addMiRecipe("compressor", "techreborn:advanced_alloy_ingot", "techreborn:advanced_alloy_plate", 1);
addMiRecipe("compressor", "#c:brass_ingots", "techreborn:brass_plate", 1);
addMiRecipe("compressor", "techreborn:carbon_mesh", "techreborn:carbon_plate", 1);
addMiRecipe("compressor", "#c:diamond_dusts", "techreborn:diamond_plate", 1);
addMiRecipe("compressor", "techreborn:emerald_dust", "techreborn:emerald_plate", 1);
addMiRecipe("compressor", "#c:iridium_ingots", "techreborn:iridium_plate", 1);
addMiRecipe("compressor", "techreborn:lazurite_dust", "techreborn:lazurite_plate", 1);
addMiRecipe("compressor", "minecraft:obsidian", "techreborn:obsidian_plate", 9);
addMiRecipe("compressor", "techreborn:obsidian_dust", "techreborn:obsidian_plate", 1);
addMiRecipe("compressor", "#c:peridot_dusts", "techreborn:peridot_plate", 1);
addMiRecipe("compressor", "techreborn:plantball", "techreborn:compressed_plantball", 1);
addMiRecipe("compressor", "#c:platinum_ingots", "techreborn:platinum_plate", 1);
addMiRecipe("compressor", "minecraft:prismarine_crystals", "minecraft:prismarine_shard", 1); // TODO
addMiRecipe("compressor", "techreborn:red_garnet_dust", "techreborn:red_garnet_plate", 1);
addMiRecipe("compressor", "minecraft:redstone_block", "techreborn:redstone_plate", 1);
addMiRecipe("compressor", "#c:ruby_dusts", "techreborn:ruby_plate", 1);
addMiRecipe("compressor", "#c:sapphire_dusts", "techreborn:sapphire_plate", 1);
addMiRecipe("compressor", "#c:tungsten_ingots", "techreborn:tungsten_plate", 1);
addMiRecipe("compressor", "techreborn:tungstensteel_ingot", "techreborn:tungstensteel_plate", 1);
addMiRecipe("compressor", "#minecraft:planks", "techreborn:wood_plate", 1);
addMiRecipe("compressor", "techreborn:yellow_garnet_dust", "techreborn:yellow_garnet_plate", 1);
Expand All @@ -69,7 +62,6 @@ public static void loadCompatRecipes() {
addMiRecipe("macerator", "#c:cinnabar_ores", "techreborn:cinnabar_dust", 2);
addMiRecipe("macerator", "minecraft:clay_ball", "techreborn:clay_dust", 1);
addMiRecipe("macerator", "minecraft:diorite", "techreborn:diorite_dust", 2);
addMiRecipe("macerator", "minecraft:emerald", "techreborn:emerald_dust", 1);
addMiRecipe("macerator", "minecraft:ender_eye", "techreborn:ender_eye_dust", 2);
addMiRecipe("macerator", "minecraft:ender_pearl", "techreborn:ender_pearl_dust", 1);
addMiRecipe("macerator", "minecraft:end_stone", "techreborn:endstone_dust", 2);
Expand All @@ -79,22 +71,23 @@ public static void loadCompatRecipes() {
addMiRecipe("macerator", "minecraft:netherrack", "techreborn:netherrack_dust", 1);
addMiRecipe("macerator", "techreborn:peridot_gem", "techreborn:peridot_dust", 1);
addMiRecipe("macerator", "#c:peridot_ores", "techreborn:peridot_dust", 2);
addMiRecipe("macerator", "#c:platinum_ingots", "techreborn:platinum_dust", 1);
addMiRecipe("macerator", "#c:pyrite_ores", "techreborn:pyrite_dust", 2);
addMiRecipe("macerator", "techreborn:red_garnet_gem", "techreborn:red_garnet_dust", 1);
addMiRecipe("macerator", "techreborn:ruby_gem", "techreborn:ruby_dust", 1);
addMiRecipe("macerator", "#c:ruby_ores", "techreborn:ruby_dust", 2);
addMiRecipe("macerator", "techreborn:ruby_gem", "modern_industrialization:ruby_dust", 1);
addMiRecipe("macerator", "#c:ruby_ores", "modern_industrialization:ruby_dust", 2);
addMiRecipe("macerator", "techreborn:sapphire_gem", "techreborn:sapphire_dust", 1);
addMiRecipe("macerator", "#c:sapphire_ores", "techreborn:sapphire_dust", 2);
addMiRecipe("macerator", "#c:sodalite_ores", "techreborn:sodalite_dust", 2);
addMiRecipe("macerator", "#c:tungsten_ingots", "techreborn:tungsten_dust", 1);
addMiRecipe("macerator", "techreborn:yellow_garnet_gem", "techreborn:yellow_garnet_dust", 1);
addMiRecipe("macerator", "#c:zinc_ingots", "techreborn:zinc_dust", 1);

for (String plate : CURVED_PLATES) {
addRecipe("tr_compat/" + plate + "_curved_plates", String.format(
"{\"type\":\"techreborn:compressor\",\"power\":10,\"time\":300,\"ingredients\":[{\"tag\":\"c:%s_plates\"}],\"results\":[{\"item\":\"modern_industrialization:%s_curved_plate\"}]}",
plate, plate).getBytes());
for (Material material : MaterialRegistry.getMaterials().values()) {
if (material.getParts().containsKey(MIParts.CURVED_PLATE)) {
String plate = material.name;
addRecipe("tr_compat/" + plate + "_curved_plates", String.format(
"{\"type\":\"techreborn:compressor\",\"power\":10,\"time\":300,\"ingredients\":[{\"tag\":\"c:%s_plates\"}],\"results\":[{\"item\":\"modern_industrialization:%s_curved_plate\"}]}",
plate, plate).getBytes());
}
}
}

Expand Down Expand Up @@ -129,8 +122,9 @@ public static void loadCompatRecipes() {
"{\"type\":\"modern_industrialization:quarry\",\"eu\":16,\"duration\":600,\"item_inputs\":{\"item\":\"indrev:cable_mk1\",\"amount\":1,\"probability\":0.6},\"item_outputs\":{\"item\":\"indrev:nikolite_ore\",\"amount\":6,\"probability\":0.03}}"
.getBytes());

for (String plate : CURVED_PLATES) {
if (!plate.equals("tin")) {
for (Material material : MaterialRegistry.getMaterials().values()) {
if (material.getParts().containsKey(MIParts.CURVED_PLATE) && !material.name.equals("tin")) {
String plate = material.name;
addRecipe("ir_compat/" + plate + "_curved_plates", String.format(
"{\"type\":\"indrev:compress\",\"ingredients\":{\"tag\":\"c:%s_plates\"},\"output\":{\"item\":\"modern_industrialization:%s_curved_plate\",\"count\":1},\"processTime\":300}",
plate, plate).getBytes());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,11 @@ private void readItemInput(JsonElement el, int index) {
private void readItemOutput(JsonElement el, int index) {
JsonObject obj = el.getAsJsonObject();
ItemStackJS stack = ItemStackJS.resultFromRecipeJson(obj);
stack.setCount(obj.get("amount").getAsInt());
if (obj.has("amount")) {
stack.setCount(obj.get("amount").getAsInt());
} else {
stack.setCount(1);
}
outputItems.add(stack);
itemOutputProbabilities[index] = readProbability(obj);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* MIT License
*
* Copyright (c) 2020 Azercoco & Technici4n
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package aztech.modern_industrialization.compat.kubejs;

import dev.latvian.kubejs.event.EventJS;
import dev.latvian.kubejs.script.ScriptType;
import java.util.HashSet;
import java.util.Set;

public class RemoveItemsEntrypoint {
public static Set<String> getItemsToRemove() {
return MIReiEvent.gatherItemsToRemove();
}

public static class MIReiEvent extends EventJS {
private final Set<String> removeSet = new HashSet<>();

public void remove(String item) {
removeSet.add(item);
}

private static Set<String> gatherItemsToRemove() {
MIReiEvent event = new MIReiEvent();
event.post(ScriptType.CLIENT, "mi_rei");
return event.removeSet;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* MIT License
*
* Copyright (c) 2020 Azercoco & Technici4n
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package aztech.modern_industrialization.compat.rei;

import aztech.modern_industrialization.compat.kubejs.RemoveItemsEntrypoint;
import java.util.Set;
import me.shedaniel.rei.api.client.plugins.REIClientPlugin;
import me.shedaniel.rei.api.client.registry.entry.EntryRegistry;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.item.ItemStack;
import net.minecraft.util.registry.Registry;

public class KJSRemoveItemsPlugin implements REIClientPlugin {
@Override
public double getPriority() {
return 1e6; // run after other stuff
}

@Override
public void registerEntries(EntryRegistry registry) {
if (FabricLoader.getInstance().isModLoaded("kubejs")) {
Set<String> itemIds = RemoveItemsEntrypoint.getItemsToRemove();
registry.removeEntryIf(entryStack -> {
if (entryStack.getValue() instanceof ItemStack is) {
if (itemIds.contains(Registry.ITEM.getId(is.getItem()).toString())) {
return true;
}
}
return false;
});
}
}
}
Loading

0 comments on commit 8af1b6f

Please sign in to comment.