diff --git a/src/main/java/com/simibubi/create/api/boiler/BoilerHeater.java b/src/main/java/com/simibubi/create/api/boiler/BoilerHeater.java
new file mode 100644
index 0000000000..71620b24d7
--- /dev/null
+++ b/src/main/java/com/simibubi/create/api/boiler/BoilerHeater.java
@@ -0,0 +1,51 @@
+package com.simibubi.create.api.boiler;
+
+import com.simibubi.create.api.registry.SimpleRegistry;
+import com.simibubi.create.content.fluids.tank.BoilerHeaters;
+
+import net.minecraft.core.BlockPos;
+import net.minecraft.world.level.Level;
+import net.minecraft.world.level.block.Block;
+import net.minecraft.world.level.block.state.BlockState;
+
+/**
+ * A BoilerHeater provides heat to boilers.
+ * Boilers will query blocks for heaters through the registry, usually with {@link #findHeat(Level, BlockPos, BlockState) findHeat}.
+ * Heaters can provide a heat level by returning any positive integer from their {@link #getHeat(Level, BlockPos, BlockState) getHeat} method.
+ * Returning any negative number counts as no heat - {@link #NO_HEAT} is provided for convenience.
+ *
+ * Returning {@link #PASSIVE_HEAT} is special - passive heat can be used to provide a small amount of heat, highly limiting
+ * in its abilities. This is usually used for free sources of heat, such as fire or magma blocks.
+ */
+@FunctionalInterface
+public interface BoilerHeater {
+ int PASSIVE_HEAT = 0;
+ int NO_HEAT = -1;
+
+ /**
+ * The heater used by common passively-heating blocks. Automatically provides
+ * heat for any block in the {@code create:passive_boiler_heaters} block tag.
+ */
+ BoilerHeater PASSIVE = BoilerHeaters::passive;
+ /**
+ * The heater used by Blaze Burners. Addons can register this to their own blocks if they use the same functionality.
+ */
+ BoilerHeater BLAZE_BURNER = BoilerHeaters::blazeBurner;
+
+ SimpleRegistry REGISTRY = SimpleRegistry.create();
+
+ /**
+ * Gets the heat at the given location. If a heater is present, queries it for heat. If not, returns {@link #NO_HEAT}.
+ */
+ static float findHeat(Level level, BlockPos pos, BlockState state) {
+ BoilerHeater heater = REGISTRY.get(state);
+ return heater != null ? heater.getHeat(level, pos, state) : NO_HEAT;
+ }
+
+ /**
+ * @return the amount of heat to provide.
+ * @see #NO_HEAT
+ * @see #PASSIVE_HEAT
+ */
+ float getHeat(Level level, BlockPos pos, BlockState state);
+}
diff --git a/src/main/java/com/simibubi/create/content/fluids/tank/BoilerData.java b/src/main/java/com/simibubi/create/content/fluids/tank/BoilerData.java
index 45f9a61741..e0750e75d6 100644
--- a/src/main/java/com/simibubi/create/content/fluids/tank/BoilerData.java
+++ b/src/main/java/com/simibubi/create/content/fluids/tank/BoilerData.java
@@ -10,6 +10,7 @@ import org.jetbrains.annotations.NotNull;
import com.simibubi.create.AllBlocks;
import com.simibubi.create.AllSoundEvents;
+import com.simibubi.create.api.boiler.BoilerHeater;
import com.simibubi.create.content.decoration.steamWhistle.WhistleBlock;
import com.simibubi.create.content.decoration.steamWhistle.WhistleBlockEntity;
import com.simibubi.create.content.kinetics.BlockStressValues;
@@ -392,7 +393,7 @@ public class BoilerData {
for (int zOffset = 0; zOffset < controller.width; zOffset++) {
BlockPos pos = controllerPos.offset(xOffset, -1, zOffset);
BlockState blockState = level.getBlockState(pos);
- float heat = BoilerHeaters.getActiveHeat(level, pos, blockState);
+ float heat = BoilerHeater.findHeat(level, pos, blockState);
if (heat == 0) {
passiveHeat = true;
} else if (heat > 0) {
diff --git a/src/main/java/com/simibubi/create/content/fluids/tank/BoilerHeaters.java b/src/main/java/com/simibubi/create/content/fluids/tank/BoilerHeaters.java
index 2ea86b27db..7f6cc94245 100644
--- a/src/main/java/com/simibubi/create/content/fluids/tank/BoilerHeaters.java
+++ b/src/main/java/com/simibubi/create/content/fluids/tank/BoilerHeaters.java
@@ -2,6 +2,7 @@ package com.simibubi.create.content.fluids.tank;
import com.simibubi.create.AllBlocks;
import com.simibubi.create.AllTags.AllBlockTags;
+import com.simibubi.create.api.boiler.BoilerHeater;
import com.simibubi.create.api.registry.SimpleRegistry;
import com.simibubi.create.content.processing.burner.BlazeBurnerBlock;
import com.simibubi.create.content.processing.burner.BlazeBurnerBlock.HeatLevel;
@@ -9,51 +10,29 @@ import com.simibubi.create.foundation.utility.BlockHelper;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.Level;
-import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
public class BoilerHeaters {
- public static final int PASSIVE_HEAT = 0;
- public static final int NO_HEAT = -1;
-
- public static final SimpleRegistry REGISTRY = SimpleRegistry.create();
-
- public static final Heater PASSIVE_HEATER = (level, pos, state) -> BlockHelper.isNotUnheated(state) ? PASSIVE_HEAT : NO_HEAT;
-
- /**
- * Gets the heat at the given location. If a heater is present, queries it for heat. If not, returns {@link #NO_HEAT}.
- * @see Heater#getActiveHeat(Level, BlockPos, BlockState)
- */
- public static float getActiveHeat(Level level, BlockPos pos, BlockState state) {
- Heater heater = REGISTRY.get(state.getBlock());
- return heater != null ? heater.getActiveHeat(level, pos, state) : NO_HEAT;
- }
-
public static void registerDefaults() {
- REGISTRY.register(AllBlocks.BLAZE_BURNER.get(), (level, pos, state) -> {
- HeatLevel value = state.getValue(BlazeBurnerBlock.HEAT_LEVEL);
- if (value == HeatLevel.NONE) {
- return NO_HEAT;
- }
- if (value == HeatLevel.SEETHING) {
- return 2;
- }
- if (value.isAtLeast(HeatLevel.FADING)) {
- return 1;
- }
- return PASSIVE_HEAT;
- });
-
- REGISTRY.registerProvider(SimpleRegistry.Provider.forBlockTag(AllBlockTags.PASSIVE_BOILER_HEATERS.tag, PASSIVE_HEATER));
+ BoilerHeater.REGISTRY.register(AllBlocks.BLAZE_BURNER.get(), BoilerHeater.BLAZE_BURNER);
+ BoilerHeater.REGISTRY.registerProvider(SimpleRegistry.Provider.forBlockTag(AllBlockTags.PASSIVE_BOILER_HEATERS.tag, BoilerHeater.PASSIVE));
}
- @FunctionalInterface
- public interface Heater {
- /**
- * @return the amount of heat to provide.
- * @see #NO_HEAT
- * @see #PASSIVE_HEAT
- */
- float getActiveHeat(Level level, BlockPos pos, BlockState state);
+ public static int passive(Level level, BlockPos pos, BlockState state) {
+ return BlockHelper.isNotUnheated(state) ? BoilerHeater.PASSIVE_HEAT : BoilerHeater.NO_HEAT;
+ }
+
+ public static int blazeBurner(Level level, BlockPos pos, BlockState state) {
+ HeatLevel value = state.getValue(BlazeBurnerBlock.HEAT_LEVEL);
+ if (value == HeatLevel.NONE) {
+ return BoilerHeater.NO_HEAT;
+ }
+ if (value == HeatLevel.SEETHING) {
+ return 2;
+ }
+ if (value.isAtLeast(HeatLevel.FADING)) {
+ return 1;
+ }
+ return BoilerHeater.PASSIVE_HEAT;
}
}