Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the Large Chemical Reactor #10

Merged
merged 3 commits into from
Jun 29, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,19 @@ public abstract class AbstractRecipeLogic extends MTETrait implements IWorkable
protected boolean hasNotEnoughEnergy;
protected boolean wasActiveAndNeedsUpdate;

protected boolean hasPerfectOC = false;

public AbstractRecipeLogic(MetaTileEntity tileEntity, RecipeMap<?> recipeMap) {
super(tileEntity);
this.recipeMap = recipeMap;
}

public AbstractRecipeLogic(MetaTileEntity tileEntity, RecipeMap<?> recipeMap, boolean hasPerfectOC) {
super(tileEntity);
this.recipeMap = recipeMap;
this.hasPerfectOC = hasPerfectOC;
}

protected abstract long getEnergyStored();

protected abstract long getEnergyCapacity();
Expand Down Expand Up @@ -257,7 +265,16 @@ protected int[] calculateOverclock(int EUt, long voltage, int duration) {
return new int[]{EUt, duration};
if (negativeEU)
EUt = -EUt;
if (EUt <= 16) {
if (hasPerfectOC) {
int resultEUt = EUt;
double resultDuration = duration;
//do not overclock further if duration is already too small
while (resultDuration >= 3 && resultEUt <= GTValues.V[tier - 1]) {
resultEUt *= 4;
resultDuration /= 4.0;
}
return new int[]{negativeEU ? -resultEUt : resultEUt, (int) Math.ceil(resultDuration)};
} else if (EUt <= 16) {
int multiplier = EUt <= 8 ? tier : tier - 1;
int resultEUt = EUt * (1 << multiplier) * (1 << multiplier);
int resultDuration = duration / (1 << multiplier);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ public MultiblockRecipeLogic(RecipeMapMultiblockController tileEntity) {
super(tileEntity, tileEntity.recipeMap);
}

public MultiblockRecipeLogic(RecipeMapMultiblockController tileEntity, boolean hasPerfectOC) {
super(tileEntity, tileEntity.recipeMap, hasPerfectOC);
}

@Override
public void update() {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,19 @@
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.resources.I18n;
import net.minecraft.item.ItemStack;
import net.minecraft.network.PacketBuffer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import net.minecraftforge.common.capabilities.Capability;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.tuple.Pair;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.*;
import java.util.function.BiFunction;
import java.util.function.Predicate;
Expand Down Expand Up @@ -258,4 +262,10 @@ public <T> T getCapability(Capability<T> capability, EnumFacing side) {
public boolean isStructureFormed() {
return structureFormed;
}

@Override
public void addInformation(ItemStack stack, @Nullable World player, List<String> tooltip, boolean advanced) {
super.addInformation(stack, player, tooltip, advanced);
tooltip.add(I18n.format("gregtech.machine.multiblock.universal.controller_information", I18n.format(getMetaFullName())));
}
}
24 changes: 23 additions & 1 deletion src/main/java/gregtech/api/recipes/RecipeMaps.java
Original file line number Diff line number Diff line change
Expand Up @@ -460,14 +460,36 @@ public class RecipeMaps {
*/

@ZenProperty
public static final RecipeMap<SimpleRecipeBuilder> CHEMICAL_RECIPES = new RecipeMap<>("chemical_reactor", 0, 2, 0, 1, 0, 3, 0, 2, new SimpleRecipeBuilder().EUt(30))
public static final RecipeMap<ChemicalReactorRecipeBuilder> CHEMICAL_RECIPES = new RecipeMap<>("chemical_reactor", 0, 2, 0, 2, 0, 3, 0, 2, new ChemicalReactorRecipeBuilder().EUt(30))
.setSlotOverlay(false, false, false, GuiTextures.MOLECULAR_OVERLAY_1)
.setSlotOverlay(false, false, true, GuiTextures.MOLECULAR_OVERLAY_2)
.setSlotOverlay(false, true, GuiTextures.MOLECULAR_OVERLAY_3)
.setSlotOverlay(true, false, GuiTextures.VIAL_OVERLAY_1)
.setSlotOverlay(true, true, GuiTextures.VIAL_OVERLAY_2)
.setProgressBar(GuiTextures.PROGRESS_BAR_ARROW_MULTIPLE, MoveType.HORIZONTAL);

/**
* Example:
* <pre>
* RecipeMap.LARGE_CHEMICAL_RECIPES.recipeBuilder()
* .inputs(OreDictUnifier.get(OrePrefix.cell, Materials.NitrogenDioxide, 4), OreDictUnifier.get(OrePrefix.cell, Materials.Oxygen, 1))
* .fluidInputs(Materials.Water.getFluid(2000))
* .fluidOutputs( new FluidStack(ItemList.sNitricAcid,4000))
* .duration(950)
* .EUt(30)
* .buildAndRegister();
* </pre>
*/

@ZenProperty
public static final RecipeMap<SimpleRecipeBuilder> LARGE_CHEMICAL_RECIPES = new RecipeMap<>("large_chemical_reactor", 0, 3, 0, 3, 0, 5, 0, 4, new SimpleRecipeBuilder().EUt(30))
.setSlotOverlay(false, false, false, GuiTextures.MOLECULAR_OVERLAY_1)
.setSlotOverlay(false, false, true, GuiTextures.MOLECULAR_OVERLAY_2)
.setSlotOverlay(false, true, GuiTextures.MOLECULAR_OVERLAY_3)
.setSlotOverlay(true, false, GuiTextures.VIAL_OVERLAY_1)
.setSlotOverlay(true, true, GuiTextures.VIAL_OVERLAY_2)
.setProgressBar(GuiTextures.PROGRESS_BAR_ARROW_MULTIPLE, MoveType.HORIZONTAL);

/**
* If universal every Fluid also gets separate distillation recipes
* Examples:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package gregtech.api.recipes.builders;

import gregtech.api.recipes.*;
import gregtech.api.util.ValidationResult;

public class ChemicalReactorRecipeBuilder extends RecipeBuilder<ChemicalReactorRecipeBuilder> {

private boolean disableLargeRecipe = false;

public ChemicalReactorRecipeBuilder() {

}

public ChemicalReactorRecipeBuilder(Recipe recipe, RecipeMap<ChemicalReactorRecipeBuilder> recipeMap) {
super(recipe, recipeMap);
}

public ChemicalReactorRecipeBuilder(RecipeBuilder<ChemicalReactorRecipeBuilder> recipeBuilder) {
super(recipeBuilder);
}

@Override
public ChemicalReactorRecipeBuilder copy() {
return new ChemicalReactorRecipeBuilder(this);
}

//todo expose to CT
public ChemicalReactorRecipeBuilder disableLargeRecipe() {
disableLargeRecipe = true;
return this;
}

@Override
public void buildAndRegister() {
if (!disableLargeRecipe) {
RecipeMaps.LARGE_CHEMICAL_RECIPES.recipeBuilder().copy()
.inputs(this.inputs.toArray(new CountableIngredient[0]))
TechLord22 marked this conversation as resolved.
Show resolved Hide resolved
.outputs(this.outputs)
.fluidInputs(this.fluidInputs)
.fluidOutputs(this.fluidOutputs)
.duration(this.duration)
.EUt(this.EUt)
.buildAndRegister();
}

super.buildAndRegister();
}

public ValidationResult<Recipe> build() {
return ValidationResult.newResult(finalizeAndValidate(),
new Recipe(inputs, outputs, chancedOutputs, fluidInputs, fluidOutputs, duration, EUt, hidden));
}
}
4 changes: 3 additions & 1 deletion src/main/java/gregtech/api/render/Textures.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public class Textures {
public static SimpleCubeRenderer CLEAN_STAINLESS_STEEL_CASING = new SimpleCubeRenderer("casings/solid/machine_casing_clean_stainless_steel");
public static SimpleCubeRenderer STABLE_TITANIUM_CASING = new SimpleCubeRenderer("casings/solid/machine_casing_stable_titanium");
public static SimpleCubeRenderer ROBUST_TUNGSTENSTEEL_CASING = new SimpleCubeRenderer("casings/solid/machine_casing_robust_tungstensteel");
public static SimpleCubeRenderer INERT_PTFE_CASING = new SimpleCubeRenderer("casings/solid/machine_casing_inert_ptfe");

public static SimpleCubeRenderer BRONZE_FIREBOX = new SimpleCubeRenderer("casings/firebox/machine_casing_firebox_bronze");
public static SimpleCubeRenderer BRONZE_FIREBOX_ACTIVE = new SimpleCubeRenderer("casings/firebox/machine_casing_firebox_bronze_active");
Expand Down Expand Up @@ -89,7 +90,8 @@ public class Textures {
public static OrientedOverlayRenderer VACUUM_FREEZER_OVERLAY = new OrientedOverlayRenderer("multiblock/vacuum_freezer", FRONT);
public static OrientedOverlayRenderer DISTILLATION_TOWER_OVERLAY = new OrientedOverlayRenderer("multiblock/distillation_tower", FRONT);
public static OrientedOverlayRenderer CRACKING_UNIT_OVERLAY = new OrientedOverlayRenderer("multiblock/cracking_unit", FRONT);
public static OrientedOverlayRenderer DIESEL_ENGINE_OVERLAY = new OrientedOverlayRenderer("multiblock/generator/diesel_engine", FRONT);
public static OrientedOverlayRenderer LARGE_CHEMICAL_REACTOR_OVERLAY = new OrientedOverlayRenderer("multiblock/large_chemical_reactor", FRONT);
public static OrientedOverlayRenderer DIESEL_ENGINE_OVERLAY = new OrientedOverlayRenderer("multiblock/generator/large_combustion_engine", FRONT);
public static OrientedOverlayRenderer LARGE_STEAM_TURBINE_OVERLAY = new OrientedOverlayRenderer("multiblock/generator/large_steam_turbine", FRONT);
public static OrientedOverlayRenderer LARGE_GAS_TURBINE_OVERLAY = new OrientedOverlayRenderer("multiblock/generator/large_gas_turbine", FRONT);
public static OrientedOverlayRenderer LARGE_PLASMA_TURBINE_OVERLAY = new OrientedOverlayRenderer("multiblock/generator/large_plasma_turbine", FRONT);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package gregtech.api.unification.material;

import com.google.common.collect.ImmutableList;
import gregtech.api.GTValues;
import gregtech.api.unification.Elements;
import gregtech.api.unification.material.type.*;
Expand All @@ -9,13 +8,13 @@
import net.minecraft.init.Enchantments;

import static com.google.common.collect.ImmutableList.of;
import static gregtech.api.unification.material.MaterialIconSet.*;
import static gregtech.api.unification.material.type.DustMaterial.MatFlags.*;
import static gregtech.api.unification.material.type.FluidMaterial.MatFlags.*;
import static gregtech.api.unification.material.type.GemMaterial.MatFlags.*;
import static gregtech.api.unification.material.type.IngotMaterial.MatFlags.*;
import static gregtech.api.unification.material.type.Material.MatFlags.*;
import static gregtech.api.unification.material.type.SolidMaterial.MatFlags.*;
import static gregtech.api.unification.material.MaterialIconSet.*;

@SuppressWarnings("unused")
public class Materials {
Expand Down Expand Up @@ -216,7 +215,7 @@ public static void register() {
public static IngotMaterial Epoxy = new IngotMaterial(175, "epoxy", 0xC88C14, DULL, 1, of(new MaterialStack(Carbon, 2), new MaterialStack(Hydrogen, 4), new MaterialStack(Oxygen, 1)), EXT2_METAL | DISABLE_DECOMPOSITION);
public static DustMaterial Polysiloxane = new DustMaterial(176, "polysiloxane", 0xDCDCDC, DULL, 1, of(new MaterialStack(Carbon, 1), new MaterialStack(Hydrogen, 1), new MaterialStack(Silicon, 2), new MaterialStack(Oxygen, 1)), GENERATE_PLATE | FLAMMABLE | NO_SMASHING | SMELT_INTO_FLUID | DISABLE_DECOMPOSITION);
public static IngotMaterial Polycaprolactam = new IngotMaterial(177, "polycaprolactam", 0x323232, DULL, 1, of(new MaterialStack(Carbon, 6), new MaterialStack(Hydrogen, 11), new MaterialStack(Nitrogen, 1), new MaterialStack(Oxygen, 1)), GENERATE_PLATE | DISABLE_DECOMPOSITION);
public static IngotMaterial Polytetrafluoroethylene = new IngotMaterial(178, "polytetrafluoroethylene", 0x646464, DULL, 1, of(new MaterialStack(Carbon, 2), new MaterialStack(Fluorine, 4)), GENERATE_PLATE | SMELT_INTO_FLUID | NO_WORKING | DISABLE_DECOMPOSITION);
public static IngotMaterial Polytetrafluoroethylene = new IngotMaterial(178, "polytetrafluoroethylene", 0x646464, DULL, 1, of(new MaterialStack(Carbon, 2), new MaterialStack(Fluorine, 4)), GENERATE_PLATE | GENERATE_FRAME | SMELT_INTO_FLUID | NO_SMASHING | DISABLE_DECOMPOSITION);
public static DustMaterial Powellite = new DustMaterial(179, "powellite", 0xFFFF00, DULL, 2, of(new MaterialStack(Calcium, 1), new MaterialStack(Molybdenum, 1), new MaterialStack(Oxygen, 4)), GENERATE_ORE);
public static DustMaterial Pyrite = new DustMaterial(180, "pyrite", 0x967828, ROUGH, 1, of(new MaterialStack(Iron, 1), new MaterialStack(Sulfur, 2)), GENERATE_ORE | INDUCTION_SMELTING_LOW_OUTPUT);
public static DustMaterial Pyrolusite = new DustMaterial(181, "pyrolusite", 0x9696AA, DULL, 2, of(new MaterialStack(Manganese, 1), new MaterialStack(Oxygen, 2)), GENERATE_ORE);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
package gregtech.api.unification.material.type;

import com.google.common.collect.ImmutableList;
import crafttweaker.annotations.ZenRegister;
import gregtech.api.unification.Element;
import gregtech.api.unification.material.MaterialIconSet;
import gregtech.api.unification.stack.MaterialStack;
import gregtech.common.pipelike.cable.WireProperties;
import gregtech.common.pipelike.fluidpipe.FluidPipeProperties;
import crafttweaker.annotations.ZenRegister;
import stanhebben.zenscript.annotations.*;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import stanhebben.zenscript.annotations.ZenProperty;

import javax.annotation.Nullable;

import static gregtech.api.unification.material.type.DustMaterial.MatFlags.GENERATE_PLATE;
import static gregtech.api.unification.material.type.DustMaterial.MatFlags.SMELT_INTO_FLUID;
import static gregtech.api.unification.material.type.IngotMaterial.MatFlags.*;
import static gregtech.api.unification.material.type.SolidMaterial.MatFlags.GENERATE_FRAME;
import static gregtech.api.unification.material.type.SolidMaterial.MatFlags.GENERATE_ROD;
import static gregtech.api.util.GTUtility.createFlag;

Expand Down Expand Up @@ -150,6 +153,9 @@ protected long verifyMaterialBits(long generationBits) {
if ((generationBits & GENERATE_BOLT_SCREW) > 0) {
generationBits |= GENERATE_ROD;
}
if ((generationBits & GENERATE_FRAME) > 0) {
generationBits |= GENERATE_ROD;
}
return super.verifyMaterialBits(generationBits);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ public enum BoilerCasingType implements IStringSerializable {
BRONZE_PIPE("bronze_pipe"),
STEEL_PIPE("steel_pipe"),
TITANIUM_PIPE("titanium_pipe"),
TUNGSTENSTEEL_PIPE("tungstensteel_pipe");
TUNGSTENSTEEL_PIPE("tungstensteel_pipe"),
POLYTETRAFLUOROETHYLENE_PIPE("polytetrafluoroethylene_pipe");

private final String name;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ public enum MetalCasingType implements IStringSerializable {
STAINLESS_CLEAN("stainless_clean"),
TITANIUM_STABLE("titanium_stable"),
TUNGSTENSTEEL_ROBUST("tungstensteel_robust"),
COKE_BRICKS("coke_bricks");
COKE_BRICKS("coke_bricks"),
PTFE_INERT_CASING("ptfe_inert");

private final String name;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ public class MetaTileEntities {
public static MetaTileEntityAssemblyLine ASSEMBLY_LINE;
public static MetaTileEntityFusionReactor[] FUSION_REACTOR = new MetaTileEntityFusionReactor[3];

public static MetaTileEntityLargeChemicalReactor LARGE_CHEMICAL_REACTOR;

//STORAGE SECTION
public static MetaTileEntityChest SMALL_WOODEN_CHEST;
public static MetaTileEntityChest WOODEN_CHEST;
Expand Down Expand Up @@ -457,6 +459,8 @@ public static void init() {
FUSION_REACTOR[1] = GregTechAPI.registerMetaTileEntity(1020, new MetaTileEntityFusionReactor(gregtechId("fusion_reactor.zpm"), 7));
FUSION_REACTOR[2] = GregTechAPI.registerMetaTileEntity(1021, new MetaTileEntityFusionReactor(gregtechId("fusion_reactor.uv"), 8));

LARGE_CHEMICAL_REACTOR = GregTechAPI.registerMetaTileEntity(1022, new MetaTileEntityLargeChemicalReactor(gregtechId("large_chemical_reactor")));

// MISC MTE's START: IDs 1300-2000

// Transformer, IDs 1300-1314
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
package gregtech.common.metatileentities.multi.electric;

import gregtech.api.capability.impl.MultiblockRecipeLogic;
import gregtech.api.metatileentity.MetaTileEntity;
import gregtech.api.metatileentity.MetaTileEntityHolder;
import gregtech.api.metatileentity.multiblock.IMultiblockPart;
import gregtech.api.metatileentity.multiblock.MultiblockAbility;
import gregtech.api.metatileentity.multiblock.RecipeMapMultiblockController;
import gregtech.api.multiblock.BlockPattern;
import gregtech.api.multiblock.FactoryBlockPattern;
import gregtech.api.recipes.RecipeMaps;
import gregtech.api.render.ICubeRenderer;
import gregtech.api.render.OrientedOverlayRenderer;
import gregtech.api.render.Textures;
import gregtech.common.blocks.BlockBoilerCasing;
import gregtech.common.blocks.BlockMetalCasing;
import gregtech.common.blocks.BlockWireCoil;
import gregtech.common.blocks.MetaBlocks;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.resources.I18n;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.List;

public class MetaTileEntityLargeChemicalReactor extends RecipeMapMultiblockController {

public static final MultiblockAbility<?>[] ALLOWED_ABILITIES = new MultiblockAbility[]{
MultiblockAbility.INPUT_ENERGY, MultiblockAbility.IMPORT_ITEMS,
MultiblockAbility.EXPORT_ITEMS, MultiblockAbility.IMPORT_FLUIDS,
MultiblockAbility.EXPORT_FLUIDS
};

public MetaTileEntityLargeChemicalReactor(ResourceLocation metaTileEntityId) {
super(metaTileEntityId, RecipeMaps.LARGE_CHEMICAL_RECIPES);
this.recipeMapWorkable = new MultiblockRecipeLogic(this, true);
}

@Override
public MetaTileEntity createMetaTileEntity(MetaTileEntityHolder holder) {
return new MetaTileEntityLargeChemicalReactor(metaTileEntityId);
}

@Override
protected BlockPattern createStructurePattern() {
return FactoryBlockPattern.start()
.aisle("XXX", "XCX", "XXX")
.aisle("XCX", "CPC", "XCX")
.aisle("XXX", "XSX", "XXX")
.setAmountLimit('K', 1, 1)
.setAmountAtLeast('x', 10)
.where('S', selfPredicate())
.where('x', statePredicate(getCasingState()))
.where('X', statePredicate(getCasingState()).or(abilityPartPredicate(ALLOWED_ABILITIES)))
.where('P', statePredicate(getPipeCasingState()))
.where('K', statePredicate(MetaBlocks.WIRE_COIL.getState(BlockWireCoil.CoilType.CUPRONICKEL)))
.where('C', statePredicate(MetaBlocks.WIRE_COIL.getState(BlockWireCoil.CoilType.CUPRONICKEL)).or(statePredicate(getCasingState())))
.build();
}

@Override
public ICubeRenderer getBaseTexture(IMultiblockPart sourcePart) {
return Textures.INERT_PTFE_CASING;
}

protected IBlockState getCasingState() {
return MetaBlocks.METAL_CASING.getState(BlockMetalCasing.MetalCasingType.PTFE_INERT_CASING);
}

protected IBlockState getPipeCasingState() {
return MetaBlocks.BOILER_CASING.getState(BlockBoilerCasing.BoilerCasingType.POLYTETRAFLUOROETHYLENE_PIPE);
}

@Override
public void addInformation(ItemStack stack, @Nullable World player, List<String> tooltip, boolean advanced) {
super.addInformation(stack, player, tooltip, advanced);
tooltip.add(I18n.format("gregtech.machine.perfect_oc"));
}

@Nonnull
@Override
protected OrientedOverlayRenderer getFrontOverlay() {
return Textures.LARGE_CHEMICAL_REACTOR_OVERLAY;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public MultiblockInfoCategory(IJeiHelpers helpers) {
put("distillation_tower", new MultiblockInfoRecipeWrapper(new DistillationTowerInfo()));
put("electric_blast_furnace", new MultiblockInfoRecipeWrapper(new ElectricBlastFurnaceInfo()));
put("multi_smelter", new MultiblockInfoRecipeWrapper(new MultiSmelterInfo()));
put("large_chemical_reactor", new MultiblockInfoRecipeWrapper(new LargeChemicalReactorInfo()));
put("large_bronze_boiler", new MultiblockInfoRecipeWrapper(new LargeBoilerInfo(MetaTileEntities.LARGE_BRONZE_BOILER)));
put("large_steel_boiler", new MultiblockInfoRecipeWrapper(new LargeBoilerInfo(MetaTileEntities.LARGE_STEEL_BOILER)));
put("large_titanium_boiler", new MultiblockInfoRecipeWrapper(new LargeBoilerInfo(MetaTileEntities.LARGE_TITANIUM_BOILER)));
Expand Down
Loading