Skip to content

Commit 0cb6427

Browse files
authored
Primitive Multi Rewrite (GregTechCEu#85)
* new PBF working * implement primitive recipes * finish PBF * refactor Coke Oven * update changelog * fix tech memeing on me
1 parent 61a52db commit 0cb6427

22 files changed

+282
-1151
lines changed

CHANGELOG-GTCEU.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@
178178
### CraftTweaker
179179
- Materials can now automatically generate IDs
180180
- Be careful, as changing the order of this will cause items in-world to disappear
181-
181+
- Coke Oven and PBF have normal RecipeMaps now, instead of using custom ones
182182

183183
### Removals
184184
- Potion Fluids placeable in-world were removed
@@ -210,3 +210,7 @@
210210
- OrePrefix is no longer an Enum, and can easily be added to by addons
211211
- Shaped and Shapeless Recipe methods in `ModHandler` can now accept more types
212212
- `debug` config will now log failed recipe removals and additions
213+
- There is now a "PrimitiveMultiblockController" base class, which uses a normal RecipeMap. When paired with the `PrimitiveRecipeBuilder`, it will:
214+
- Allow recipes to be run without power
215+
- (by default) Initialize inventory for items and fluids to the Controller instead of Multiblock Parts (overridable)
216+
- Hide the EU/t and Total EU info from the JEI page
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
package gregtech.api.capability.impl;
2+
3+
import gregtech.api.GTValues;
4+
import gregtech.api.metatileentity.multiblock.RecipeMapPrimitiveMultiblockController;
5+
import gregtech.api.recipes.RecipeMap;
6+
7+
/**
8+
* Recipe Logic for a Multiblock that does not require power.
9+
*/
10+
public class PrimitiveRecipeLogic extends AbstractRecipeLogic {
11+
12+
public PrimitiveRecipeLogic(RecipeMapPrimitiveMultiblockController tileEntity, RecipeMap<?> recipeMap) {
13+
super(tileEntity, recipeMap);
14+
}
15+
16+
@Override
17+
protected long getEnergyStored() {
18+
return Integer.MAX_VALUE;
19+
}
20+
21+
@Override
22+
protected long getEnergyCapacity() {
23+
return Integer.MAX_VALUE;
24+
}
25+
26+
@Override
27+
protected boolean drawEnergy(int recipeEUt) {
28+
return true; // spoof energy being drawn
29+
}
30+
31+
@Override
32+
protected long getMaxVoltage() {
33+
return GTValues.LV;
34+
}
35+
36+
@Override
37+
protected int[] calculateOverclock(int EUt, long voltage, int duration) {
38+
return new int[]{1, duration};
39+
}
40+
41+
@Override
42+
protected int getOverclockingTier(long voltage) {
43+
return GTValues.LV; // just return something reasonable
44+
}
45+
46+
/**
47+
* Used to reset cached values in the Recipe Logic on structure deform
48+
*/
49+
public void invalidate() {
50+
lastItemInputs = null;
51+
lastFluidInputs = null;
52+
previousRecipe = null;
53+
progressTime = 0;
54+
maxProgressTime = 0;
55+
recipeEUt = 0;
56+
fluidOutputs = null;
57+
itemOutputs = null;
58+
setActive(false); // this marks dirty for us
59+
}
60+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
package gregtech.api.metatileentity.multiblock;
2+
3+
import gregtech.api.capability.impl.*;
4+
import gregtech.api.recipes.RecipeMap;
5+
import net.minecraft.util.ResourceLocation;
6+
import net.minecraftforge.fluids.FluidTank;
7+
import net.minecraftforge.items.ItemStackHandler;
8+
9+
import java.util.ArrayList;
10+
import java.util.List;
11+
12+
public abstract class RecipeMapPrimitiveMultiblockController extends MultiblockWithDisplayBase {
13+
14+
protected PrimitiveRecipeLogic recipeMapWorkable;
15+
16+
public RecipeMapPrimitiveMultiblockController(ResourceLocation metaTileEntityId, RecipeMap<?> recipeMap) {
17+
super(metaTileEntityId);
18+
this.recipeMapWorkable = new PrimitiveRecipeLogic(this, recipeMap);
19+
initializeAbilities();
20+
}
21+
22+
// just initialize inventories based on RecipeMap values by default
23+
protected void initializeAbilities() {
24+
this.importItems = new ItemStackHandler(recipeMapWorkable.recipeMap.getMaxInputs());
25+
this.importFluids = new FluidTankList(true, makeFluidTanks(recipeMapWorkable.recipeMap.getMaxFluidInputs()));
26+
this.exportItems = new ItemStackHandler(recipeMapWorkable.recipeMap.getMaxOutputs());
27+
this.exportFluids = new FluidTankList(false, makeFluidTanks(recipeMapWorkable.recipeMap.getMaxFluidOutputs()));
28+
29+
this.itemInventory = new ItemHandlerProxy(this.importItems, this.exportItems);
30+
this.fluidInventory = new FluidHandlerProxy(this.importFluids, this.exportFluids);
31+
}
32+
33+
private List<FluidTank> makeFluidTanks(int length) {
34+
List<FluidTank> fluidTankList = new ArrayList<>(length);
35+
for (int i = 0; i < length; i++) {
36+
fluidTankList.add(new FluidTank(32000));
37+
}
38+
return fluidTankList;
39+
}
40+
41+
@Override
42+
protected void updateFormedValid() {
43+
recipeMapWorkable.update();
44+
}
45+
46+
@Override
47+
public void invalidateStructure() {
48+
super.invalidateStructure();
49+
recipeMapWorkable.invalidate();
50+
}
51+
}

src/main/java/gregtech/api/recipes/RecipeMap.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import gregtech.api.gui.widgets.SlotWidget;
1919
import gregtech.api.gui.widgets.TankWidget;
2020
import gregtech.api.recipes.builders.IntCircuitRecipeBuilder;
21+
import gregtech.api.recipes.builders.PrimitiveRecipeBuilder;
2122
import gregtech.api.recipes.crafttweaker.CTRecipe;
2223
import gregtech.api.recipes.crafttweaker.CTRecipeBuilder;
2324
import gregtech.api.unification.material.Material;
@@ -93,6 +94,7 @@ public static List<RecipeMap<?>> getRecipeMaps() {
9394

9495
public static void sortMaps() {
9596
for (RecipeMap<?> rmap : RECIPE_MAP_REGISTRY.values()) {
97+
if (rmap.recipeBuilder() instanceof PrimitiveRecipeBuilder) continue; // just for cleanliness
9698
rmap.recipeList.sort(Comparator.comparingInt(Recipe::getDuration)
9799
.thenComparingInt(Recipe::getEUt));
98100
}

src/main/java/gregtech/api/recipes/RecipeMaps.java

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -704,36 +704,27 @@ public class RecipeMaps {
704704
.setProgressBar(GuiTextures.PROGRESS_BAR_BATH, MoveType.HORIZONTAL);
705705

706706
@ZenProperty
707-
public static final FuelRecipeMap COMBUSTION_GENERATOR_FUELS = new FuelRecipeMap("combustion_generator");
708-
707+
public static final RecipeMap<PrimitiveRecipeBuilder> PRIMITIVE_BLAST_FURNACE_RECIPES = new RecipeMap<>("primitive_blast_furnace", 2, 2, 1, 2, 0, 0, 0, 0, new PrimitiveRecipeBuilder(), false);
709708

710709
@ZenProperty
711-
public static final FuelRecipeMap GAS_TURBINE_FUELS = new FuelRecipeMap("gas_turbine");
710+
public static final RecipeMap<PrimitiveRecipeBuilder> COKE_OVEN_RECIPES = new RecipeMap<>("coke_oven", 1, 1, 0, 1, 0, 0, 0, 1, new PrimitiveRecipeBuilder(), false);
712711

712+
//////////////////////////////////////
713+
// Fuel Recipe Maps //
714+
//////////////////////////////////////
713715

714716
@ZenProperty
715-
public static final FuelRecipeMap STEAM_TURBINE_FUELS = new FuelRecipeMap("steam_turbine");
717+
public static final FuelRecipeMap COMBUSTION_GENERATOR_FUELS = new FuelRecipeMap("combustion_generator");
716718

717719
@ZenProperty
718-
public static final FuelRecipeMap SEMI_FLUID_GENERATOR_FUELS = new FuelRecipeMap("semi_fluid_generator");
720+
public static final FuelRecipeMap GAS_TURBINE_FUELS = new FuelRecipeMap("gas_turbine");
719721

720722
@ZenProperty
721-
public static final FuelRecipeMap PLASMA_GENERATOR_FUELS = new FuelRecipeMap("plasma_generator");
723+
public static final FuelRecipeMap STEAM_TURBINE_FUELS = new FuelRecipeMap("steam_turbine");
722724

723725
@ZenProperty
724-
public static final List<PrimitiveBlastFurnaceRecipe> PRIMITIVE_BLAST_FURNACE_RECIPES = new CopyOnWriteArrayList<>();
726+
public static final FuelRecipeMap SEMI_FLUID_GENERATOR_FUELS = new FuelRecipeMap("semi_fluid_generator");
725727

726728
@ZenProperty
727-
public static final List<CokeOvenRecipe> COKE_OVEN_RECIPES = new CopyOnWriteArrayList<>();
728-
729-
@ZenMethod
730-
public static List<PrimitiveBlastFurnaceRecipe> getPrimitiveBlastFurnaceRecipes() {
731-
return PRIMITIVE_BLAST_FURNACE_RECIPES;
732-
}
733-
734-
@ZenMethod
735-
public static List<CokeOvenRecipe> getCokeOvenRecipes() {
736-
return COKE_OVEN_RECIPES;
737-
}
738-
729+
public static final FuelRecipeMap PLASMA_GENERATOR_FUELS = new FuelRecipeMap("plasma_generator");
739730
}

src/main/java/gregtech/api/recipes/builders/CokeOvenRecipeBuilder.java

Lines changed: 0 additions & 137 deletions
This file was deleted.

0 commit comments

Comments
 (0)