Skip to content

Commit

Permalink
Merge pull request #9 from Zorbatron/recipe-change
Browse files Browse the repository at this point in the history
Add recipes for the CoAL casings and a couple silly recipes + Config fix
  • Loading branch information
Zorbatron authored Sep 8, 2024
2 parents c362aa9 + 492b4b7 commit f224af7
Show file tree
Hide file tree
Showing 16 changed files with 275 additions and 45 deletions.
18 changes: 15 additions & 3 deletions src/main/java/com/zorbatron/zbgt/ZBGTConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,22 @@ public class ZBGTConfig {

public static class MultiblockSettings {

@Config.Comment("Not all of my multiblocks may allow substation energy hatches, " +
"but this is a global toggle. If false, no multiblock will work with substation hatches.")
@Config.Comment({ "Not all of my multiblocks may allow substation energy hatches, " +
"but this is a global toggle. If false, no multiblock will work with substation hatches.",
"Default: false" })
@Config.RequiresMcRestart
@Config.Name("Allow Substation Hatches")
@Config.Name("allowSubstationHatches")
public boolean allowSubstationHatches = false;
}

public static MiscSettings miscSettings = new MiscSettings();

public static class MiscSettings {

@Config.Comment({ "How silly are you?",
"Default: true" })
@Config.RequiresMcRestart
@Config.Name("sillyRecipes")
public boolean enableSillyRecipes = true;
}
}
39 changes: 36 additions & 3 deletions src/main/java/com/zorbatron/zbgt/api/recipes/ZBGTRecipeMaps.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
package com.zorbatron.zbgt.api.recipes;

import static gregtech.api.recipes.RecipeMaps.POLARIZER_RECIPES;
import static gregtech.api.recipes.RecipeMaps.*;

import java.util.ArrayList;
import java.util.List;

import com.zorbatron.zbgt.api.recipes.builders.CoALRecipeBuilder;
import com.zorbatron.zbgt.api.recipes.helpers.RecipeIOMod;

import gregtech.api.recipes.RecipeMap;

Expand All @@ -15,7 +19,36 @@ private ZBGTRecipeMaps() {}
new CoALRecipeBuilder());

public static void modifyMaps() {
POLARIZER_RECIPES.setMaxFluidInputs(1);
POLARIZER_RECIPES.setMaxFluidOutputs(1);
List<RecipeIOMod> recipeModList = new ArrayList<>();
recipeModList.add(new RecipeIOMod(POLARIZER_RECIPES, 0, 0, 1, 1));
recipeModList.add(new RecipeIOMod(COMPRESSOR_RECIPES, 0, 0, 1, 1));

recipeModList.forEach(recipeIOMod -> {
int recipeMaxItemInputs = recipeIOMod.recipeMap().getMaxInputs();
int recipeMaxItemOutputs = recipeIOMod.recipeMap().getMaxOutputs();
int recipeMaxFluidInputs = recipeIOMod.recipeMap().getMaxFluidInputs();
int recipeMaxFluidOutputs = recipeIOMod.recipeMap().getMaxFluidOutputs();

int minItemInputs = recipeIOMod.minItemInputs();
int minItemOutputs = recipeIOMod.minItemOutputs();
int minFluidInputs = recipeIOMod.minFluidInputs();
int minFluidOutputs = recipeIOMod.minFluidOutputs();

if (recipeMaxItemInputs < minItemInputs) {
recipeIOMod.recipeMap().setMaxInputs(minItemInputs);
}

if (recipeMaxItemOutputs < minItemOutputs) {
recipeIOMod.recipeMap().setMaxOutputs(minItemOutputs);
}

if (recipeMaxFluidInputs < minFluidInputs) {
recipeIOMod.recipeMap().setMaxFluidInputs(minFluidInputs);
}

if (recipeMaxFluidOutputs < minFluidOutputs) {
recipeIOMod.recipeMap().setMaxFluidOutputs(minFluidOutputs);
}
});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.zorbatron.zbgt.api.recipes.helpers;

import com.github.bsideup.jabel.Desugar;

import gregtech.api.recipes.RecipeMap;

@Desugar
public record RecipeIOMod(RecipeMap<?> recipeMap, int minItemInputs, int minItemOutputs, int minFluidInputs,
int minFluidOutputs) {}
2 changes: 1 addition & 1 deletion src/main/java/com/zorbatron/zbgt/common/CommonProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
import com.zorbatron.zbgt.common.block.ZBGTMetaBlocks;
import com.zorbatron.zbgt.common.covers.ZBGTCovers;
import com.zorbatron.zbgt.common.items.ZBGTMetaItems;
import com.zorbatron.zbgt.loaders.recipe.ZBGTRecipes;
import com.zorbatron.zbgt.materials.ZBGTMaterialOverrides;
import com.zorbatron.zbgt.recipe.ZBGTRecipes;

import gregtech.api.GTValues;
import gregtech.api.GregTechAPI;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.zorbatron.zbgt.common.block.blocks;

import static gregtech.api.GTValues.*;

import javax.annotation.Nonnull;

import net.minecraft.block.SoundType;
Expand Down Expand Up @@ -68,21 +70,21 @@ public int getTier() {
return this.ordinal();
}

public CasingType getCasingByTier(int tier) {
public static CasingType getCasingByTier(int tier) {
return switch (tier) {
case (2) -> CASING_MV;
case (3) -> CASING_HV;
case (4) -> CASING_EV;
case (5) -> CASING_IV;
case (6) -> CASING_LuV;
case (7) -> CASING_ZPM;
case (8) -> CASING_UV;
case (9) -> CASING_UHV;
case (10) -> CASING_UEV;
case (11) -> CASING_UIV;
case (12) -> CASING_UXV;
case (13) -> CASING_OpV;
case (14) -> CASING_MAX;
case (MV) -> CASING_MV;
case (HV) -> CASING_HV;
case (EV) -> CASING_EV;
case (IV) -> CASING_IV;
case (LuV) -> CASING_LuV;
case (ZPM) -> CASING_ZPM;
case (UV) -> CASING_UV;
case (UHV) -> CASING_UHV;
case (UEV) -> CASING_UEV;
case (UIV) -> CASING_UIV;
case (UXV) -> CASING_UXV;
case (OpV) -> CASING_OpV;
case (MAX) -> CASING_MAX;
default -> CASING_LV;
};
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.zorbatron.zbgt.common.block.blocks;

import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.EntityLiving;
import net.minecraft.util.IStringSerializable;
Expand All @@ -11,11 +10,13 @@
import org.jetbrains.annotations.NotNull;

import gregtech.api.block.VariantBlock;
import gregtech.api.unification.material.Material;
import gregtech.api.unification.material.Materials;

public class ZBGTBlockMultiblockCasing extends VariantBlock<ZBGTBlockMultiblockCasing.CasingType> {

public ZBGTBlockMultiblockCasing() {
super(Material.IRON);
super(net.minecraft.block.material.Material.IRON);
setTranslationKey("multiblock_casing");
setHardness(5.0f);
setResistance(10.0f);
Expand All @@ -32,18 +33,24 @@ public boolean canCreatureSpawn(@NotNull IBlockState state, @NotNull IBlockAcces

public enum CasingType implements IStringSerializable {

IRIDIUM_CASING("iridium");
IRIDIUM_CASING("iridium", Materials.Iridium);

private final String name;
private final Material material;

CasingType(String name) {
CasingType(String name, Material material) {
this.name = name;
this.material = material;
}

@NotNull
@Override
public String getName() {
return this.name;
}

public Material getMaterial() {
return this.material;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public static void init() {
densePlates();
frameBoxes();
longRods();
gears();
}

private static void magneticMaterialFluids() {
Expand All @@ -37,7 +38,7 @@ private static void densePlates() {
}

private static void frameBoxes() {
Material[] materials = { NaquadahAlloy };
Material[] materials = { NaquadahAlloy, RhodiumPlatedPalladium, Darmstadtium };

for (Material material : materials) {
material.addFlags(MaterialFlags.GENERATE_FRAME);
Expand All @@ -51,4 +52,12 @@ private static void longRods() {
material.addFlags(MaterialFlags.GENERATE_LONG_ROD);
}
}

private static void gears() {
Material[] materials = { RhodiumPlatedPalladium, Darmstadtium };

for (Material material : materials) {
material.addFlags(MaterialFlags.GENERATE_GEAR);
}
}
}
30 changes: 30 additions & 0 deletions src/main/java/com/zorbatron/zbgt/recipe/AE2Recipes.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.zorbatron.zbgt.recipe;

import static gregtech.api.unification.material.Materials.Water;
import static net.minecraft.init.Blocks.COBBLESTONE;

import net.minecraft.item.ItemStack;

import appeng.api.AEApi;
import appeng.api.definitions.IMaterials;
import gregtech.api.GTValues;
import gregtech.api.recipes.RecipeMaps;

public class AE2Recipes {

public static void init() {
final IMaterials ae2Materials = AEApi.instance().definitions().materials();

RecipeMaps.COMPRESSOR_RECIPES.recipeBuilder()
.input(COBBLESTONE, 256_000)
.outputs(ae2Materials.singularity().maybeStack(1).orElse(ItemStack.EMPTY))
.EUt(GTValues.VA[GTValues.HV]).duration(20 * 60)
.buildAndRegister();

RecipeMaps.COMPRESSOR_RECIPES.recipeBuilder()
.fluidInputs(Water.getFluid(256_000_000))
.outputs(ae2Materials.singularity().maybeStack(1).orElse(ItemStack.EMPTY))
.EUt(GTValues.VA[GTValues.HV]).duration(20 * 60)
.buildAndRegister();
}
}
104 changes: 104 additions & 0 deletions src/main/java/com/zorbatron/zbgt/recipe/CasingRecipes.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
package com.zorbatron.zbgt.recipe;

import static com.zorbatron.zbgt.recipe.helpers.RecipeAssists.*;
import static gregtech.api.GTValues.*;
import static gregtech.api.recipes.RecipeMaps.ASSEMBLER_RECIPES;
import static gregtech.api.recipes.RecipeMaps.ASSEMBLY_LINE_RECIPES;
import static gregtech.api.unification.material.Materials.Naquadria;
import static gregtech.api.unification.ore.OrePrefix.*;

import java.util.Arrays;

import net.minecraft.util.IStringSerializable;

import com.zorbatron.zbgt.common.block.ZBGTMetaBlocks;
import com.zorbatron.zbgt.common.block.blocks.CoALCasing;
import com.zorbatron.zbgt.common.block.blocks.ZBGTBlockMultiblockCasing;

import gregtech.api.block.VariantBlock;
import gregtech.api.recipes.ModHandler;
import gregtech.api.unification.OreDictUnifier;
import gregtech.api.unification.material.Material;
import gregtech.api.unification.material.Materials;
import gregtech.common.ConfigHolder;

public class CasingRecipes {

public static void init() {
ZBGTBlockMultiblockCasings();
CoALCasings();
}

private static void ZBGTBlockMultiblockCasings() {
Arrays.stream(ZBGTBlockMultiblockCasing.CasingType.values()).forEach(
casing -> registerMetalCasingRecipe(casing.getMaterial(), ZBGTMetaBlocks.MULTIBLOCK_CASING, casing));
}

// Copied from GCYL: CEu
private static <
T extends Enum<T> & IStringSerializable> void registerMetalCasingRecipe(Material inputMaterial,
VariantBlock<T> outputCasingType,
T outputCasing) {
ModHandler.addShapedRecipe(String.format("metal_casing_%s", inputMaterial),
outputCasingType.getItemVariant(outputCasing, ConfigHolder.recipes.casingsPerCraft),
"PhP", "PFP", "PwP",
'P', OreDictUnifier.get(plate, inputMaterial),
'F', OreDictUnifier.get(frameGt, inputMaterial));

ASSEMBLER_RECIPES.recipeBuilder().duration(50).EUt(16)
.input(plate, inputMaterial, 6)
.input(frameGt, inputMaterial)
.circuitMeta(6)
.outputs(outputCasingType.getItemVariant(outputCasing, ConfigHolder.recipes.casingsPerCraft))
.buildAndRegister();
}

private static void CoALCasings() {
for (int tier = LV; tier <= IV; tier++) {
ASSEMBLER_RECIPES.recipeBuilder()
.input(frameGt, getMaterialByTier(tier))
.input(plateDense, getMaterialByTier(tier), 4)
.input(getRobotArmByTier(tier), 4)
.input(getPistonByTier(tier), 8)
.input(getMotorByTier(tier), 10)
.input(gear, getMaterialByTier(tier), 4)
.input(cableGtQuadruple, getCableByTier(tier), 6)
.input(circuit, getMarkerMaterialByTier(tier), 8)
.input(circuit, getMarkerMaterialByTier(tier - 1), 16)
.fluidInputs(Materials.SolderingAlloy.getFluid(tier * L * 2))
.outputs(ZBGTMetaBlocks.CoAL_CASING.getItemVariant(CoALCasing.CasingType.getCasingByTier(tier)))
.EUt(VA[tier]).duration(150)
.buildAndRegister();
}

for (int tier = LuV; tier <= UV; tier++) {
int fluidAdditive = (tier - ZPM) * 2;
int finalTier = tier;

ASSEMBLY_LINE_RECIPES.recipeBuilder()
.input(frameGt, getMaterialByTier(tier))
.input(plateDense, getMaterialByTier(tier), 6)
.input(getRobotArmByTier(tier), 8)
.input(getPistonByTier(tier))
.input(getMotorByTier(tier), 16)
.input(gear, getMaterialByTier(tier))
.input(gearSmall, getMaterialByTier(tier))
.input(cableGtQuadruple, getCableByTier(tier), 8)
.input(circuit, getMarkerMaterialByTier(tier), 8)
.input(circuit, getMarkerMaterialByTier(tier - 1), 16)
.fluidInputs(Materials.SolderingAlloy.getFluid((10 + fluidAdditive) * L))
.fluidInputs(tier > ZPM ?
Materials.Polybenzimidazole.getFluid((10 + fluidAdditive) * L * 2) :
Materials.Polyethylene.getFluid((10 + fluidAdditive) * L * 2))
.fluidInputs(tier > ZPM ? Naquadria.getFluid((10 + fluidAdditive) * L * 2) : null)
.outputs(ZBGTMetaBlocks.CoAL_CASING.getItemVariant(CoALCasing.CasingType.getCasingByTier(tier)))
.stationResearch(research -> research
.researchStack(ZBGTMetaBlocks.CoAL_CASING
.getItemVariant(CoALCasing.CasingType.getCasingByTier(finalTier - 1)))
.CWUt((int) Math.pow(16, finalTier - IV))
.EUt(VA[finalTier]))
.EUt(VA[tier]).duration(20 * 15)
.buildAndRegister();
}
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.zorbatron.zbgt.loaders.recipe;
package com.zorbatron.zbgt.recipe;

import static com.zorbatron.zbgt.api.recipes.ZBGTRecipeMaps.CoAL_RECIPES;
import static com.zorbatron.zbgt.loaders.recipe.CoALRecipes.coalRecipeType.*;
import static com.zorbatron.zbgt.loaders.recipe.RecipeAssists.*;
import static com.zorbatron.zbgt.recipe.CoALRecipes.coalRecipeType.*;
import static com.zorbatron.zbgt.recipe.helpers.RecipeAssists.*;
import static gregtech.api.GTValues.*;
import static gregtech.api.unification.material.Materials.*;
import static gregtech.api.unification.ore.OrePrefix.*;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.zorbatron.zbgt.loaders.recipe;
package com.zorbatron.zbgt.recipe;

import static com.zorbatron.zbgt.common.items.ZBGTMetaItems.*;
import static gregtech.api.GTValues.*;
Expand Down
Loading

0 comments on commit f224af7

Please sign in to comment.