|
6 | 6 |
|
7 | 7 | import net.minecraft.core.registries.BuiltInRegistries; |
8 | 8 | import net.minecraft.data.recipes.FinishedRecipe; |
| 9 | +import net.minecraft.resources.ResourceLocation; |
9 | 10 | import net.minecraft.world.item.Item; |
10 | | -import net.minecraft.world.level.block.entity.FurnaceBlockEntity; |
11 | 11 | import net.minecraft.world.level.material.Fluids; |
12 | 12 | import net.minecraftforge.fluids.FluidStack; |
| 13 | +import net.minecraftforge.fluids.FluidUtil; |
13 | 14 |
|
14 | 15 | import java.util.HashSet; |
| 16 | +import java.util.Optional; |
15 | 17 | import java.util.Set; |
16 | 18 | import java.util.function.Consumer; |
17 | 19 |
|
|
21 | 23 |
|
22 | 24 | public class FuelRecipes { |
23 | 25 |
|
| 26 | + public static void addBoilerFuel(Consumer<FinishedRecipe> provider, Set<Item> added, |
| 27 | + Item item, int burnTime) { |
| 28 | + if (added.contains(item) || burnTime <= 0) { |
| 29 | + return; |
| 30 | + } |
| 31 | + added.add(item); |
| 32 | + |
| 33 | + Optional<FluidStack> containedFluid = FluidUtil.getFluidContained(item.getDefaultInstance()); |
| 34 | + if (containedFluid.isEmpty()) { |
| 35 | + ResourceLocation id = BuiltInRegistries.ITEM.getKey(item); |
| 36 | + STEAM_BOILER_RECIPES.recipeBuilder(GTCEu.id(id.getNamespace() + "_" + id.getPath())) |
| 37 | + .inputItems(item) |
| 38 | + .duration(burnTime) |
| 39 | + .save(provider); |
| 40 | + } else { |
| 41 | + FluidStack fluid = new FluidStack(containedFluid.get(), 250); |
| 42 | + ResourceLocation id = BuiltInRegistries.FLUID.getKey(fluid.getFluid()); |
| 43 | + |
| 44 | + // the lava recipe's duration is 4/9 of the bucket's burn time |
| 45 | + // the creosote recipe's duration is 7/32 of the bucket's burn time |
| 46 | + // as such, the mean ratio is 191/576, or approximately 1/3. |
| 47 | + STEAM_BOILER_RECIPES.recipeBuilder(id.getNamespace() + "_" + id.getPath()) |
| 48 | + .inputFluids(fluid) |
| 49 | + .duration(burnTime / 3) |
| 50 | + .save(provider); |
| 51 | + } |
| 52 | + } |
| 53 | + |
24 | 54 | public static void init(Consumer<FinishedRecipe> provider) { |
25 | 55 | // TODO this all needs to be cleaned up, but this will make it somewhat work for now |
26 | 56 | // do these first because for some reason vanilla fuels are not set up yet at this phase? |
27 | 57 | Set<Item> addedItems = new HashSet<>(); |
28 | | - for (var fuelEntry : FurnaceBlockEntity.getFuel().entrySet()) { |
29 | | - addedItems.add(fuelEntry.getKey()); |
30 | | - var resLoc = BuiltInRegistries.ITEM.getKey(fuelEntry.getKey()); |
31 | | - STEAM_BOILER_RECIPES.recipeBuilder(GTCEu.id(resLoc.getNamespace() + "_" + resLoc.getPath())) |
32 | | - .inputItems(fuelEntry.getKey()) |
33 | | - .duration(fuelEntry.getValue() * 12) // remove the * 12 if SteamBoilerMachine:240 is uncommented |
34 | | - .save(provider); |
35 | | - } |
36 | 58 | for (Item item : BuiltInRegistries.ITEM) { |
37 | | - var burnTime = GTUtil.getItemBurnTime(item); |
38 | | - if (burnTime > 0 && !addedItems.contains(item)) { |
39 | | - var resLoc = BuiltInRegistries.ITEM.getKey(item); |
40 | | - STEAM_BOILER_RECIPES.recipeBuilder(GTCEu.id(resLoc.getNamespace() + "_" + resLoc.getPath())) |
41 | | - .inputItems(item) |
42 | | - .duration(burnTime * 12) |
43 | | - .save(provider); |
44 | | - } |
| 59 | + int burnTime = GTUtil.getItemBurnTime(item); |
| 60 | + addBoilerFuel(provider, addedItems, item, burnTime); |
45 | 61 | } |
46 | 62 |
|
47 | | - STEAM_BOILER_RECIPES.recipeBuilder("lava") |
| 63 | + // override the default fluid recipes for lava and creosote |
| 64 | + STEAM_BOILER_RECIPES.recipeBuilder("minecraft_lava") |
48 | 65 | .inputFluids(new FluidStack(Fluids.LAVA, 100)) |
49 | | - .duration(100 * 12) |
| 66 | + .duration(900) // 60s -> 45s Might still be too good with drip stone farming. |
50 | 67 | .save(provider); |
51 | 68 |
|
52 | | - STEAM_BOILER_RECIPES.recipeBuilder("creosote") |
| 69 | + STEAM_BOILER_RECIPES.recipeBuilder("gtceu_creosote") |
53 | 70 | .inputFluids(Creosote.getFluid(250)) |
54 | | - .duration(250 * 12) |
| 71 | + .duration(350) // 150s -> 17.5s |
55 | 72 | .save(provider); |
56 | 73 |
|
57 | | - // semi-fluid fuels, like creosote |
58 | | - LARGE_BOILER_RECIPES.recipeBuilder("creosote") |
59 | | - .inputFluids(Creosote.getFluid(160)) |
60 | | - .duration(10) |
| 74 | + // semi-fluid fuels, like creosote - these are awful and need to be scrutinized heavily... |
| 75 | + LARGE_BOILER_RECIPES.recipeBuilder("gtceu_creosote") |
| 76 | + .inputFluids(Creosote.getFluid(250)) |
| 77 | + .duration(35) |
61 | 78 | .save(provider); |
62 | 79 |
|
63 | | - LARGE_BOILER_RECIPES.recipeBuilder("biomass") |
| 80 | + LARGE_BOILER_RECIPES.recipeBuilder("gtceu_biomass") |
64 | 81 | .inputFluids(Biomass.getFluid(40)) |
65 | | - .duration(10) |
| 82 | + .duration(85) |
66 | 83 | .save(provider); |
67 | 84 |
|
68 | | - LARGE_BOILER_RECIPES.recipeBuilder("oil") |
| 85 | + LARGE_BOILER_RECIPES.recipeBuilder("gtceu_oil") |
69 | 86 | .inputFluids(Oil.getFluid(200)) |
70 | | - .duration(10) |
| 87 | + .duration(50) |
71 | 88 | .save(provider); |
72 | 89 |
|
73 | | - LARGE_BOILER_RECIPES.recipeBuilder("oil_heavy") |
| 90 | + LARGE_BOILER_RECIPES.recipeBuilder("gtceu_oil_heavy") |
74 | 91 | .inputFluids(OilHeavy.getFluid(32)) |
75 | | - .duration(10) |
| 92 | + .duration(50) |
76 | 93 | .save(provider); |
77 | 94 |
|
78 | | - LARGE_BOILER_RECIPES.recipeBuilder("sulfuric_heavy_fuel") |
| 95 | + LARGE_BOILER_RECIPES.recipeBuilder("gtceu_sulfuric_heavy_fuel") |
79 | 96 | .inputFluids(SulfuricHeavyFuel.getFluid(32)) |
80 | | - .duration(10) |
| 97 | + .duration(50) |
81 | 98 | .save(provider); |
82 | 99 |
|
83 | | - LARGE_BOILER_RECIPES.recipeBuilder("heavy_fuel") |
| 100 | + LARGE_BOILER_RECIPES.recipeBuilder("gtceu_heavy_fuel") |
84 | 101 | .inputFluids(HeavyFuel.getFluid(16)) |
85 | | - .duration(30) |
| 102 | + .duration(90) |
86 | 103 | .save(provider); |
87 | 104 |
|
88 | | - LARGE_BOILER_RECIPES.recipeBuilder("fish_oil") |
| 105 | + LARGE_BOILER_RECIPES.recipeBuilder("gtceu_fish_oil") |
89 | 106 | .inputFluids(FishOil.getFluid(160)) |
90 | | - .duration(10) |
| 107 | + .duration(50) |
91 | 108 | .save(provider); |
92 | 109 |
|
93 | 110 | // diesel generator fuels |
|
0 commit comments