From 6173f9600cee712f4806c3919e9b477b2954d61e Mon Sep 17 00:00:00 2001 From: MRH0 Date: Fri, 6 Aug 2021 01:27:14 +0200 Subject: [PATCH] Integration support for Furnace Engine speed modifiers + FurnaceEngineModifiers which hold a Block -> float map of modifiers ~ Changed FurnaceEngineTileEntity to use the FurnaceEngineModifiers map instead of hardcoded modifier fro the Blast Furnace. This will allow addon modders to change the speed modifier of a Furnace block. --- src/main/java/com/simibubi/create/Create.java | 2 + .../engine/FurnaceEngineModifiers.java | 39 +++++++++++++++++++ .../engine/FurnaceEngineTileEntity.java | 2 +- 3 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/simibubi/create/content/contraptions/components/flywheel/engine/FurnaceEngineModifiers.java diff --git a/src/main/java/com/simibubi/create/Create.java b/src/main/java/com/simibubi/create/Create.java index a5bc411e7..c7153e531 100644 --- a/src/main/java/com/simibubi/create/Create.java +++ b/src/main/java/com/simibubi/create/Create.java @@ -9,6 +9,7 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.simibubi.create.content.CreateItemGroup; import com.simibubi.create.content.contraptions.TorquePropagator; +import com.simibubi.create.content.contraptions.components.flywheel.engine.FurnaceEngineModifiers; import com.simibubi.create.content.contraptions.components.structureMovement.train.capability.CapabilityMinecartController; import com.simibubi.create.content.curiosities.weapons.PotatoCannonProjectileTypes; import com.simibubi.create.content.logistics.RedstoneLinkNetworkHandler; @@ -92,6 +93,7 @@ public class Create { AllWorldFeatures.register(); AllEnchantments.register(); AllConfigs.register(ModLoadingContext.get()); + FurnaceEngineModifiers.register(); ForgeMod.enableMilkFluid(); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/engine/FurnaceEngineModifiers.java b/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/engine/FurnaceEngineModifiers.java new file mode 100644 index 000000000..e785540de --- /dev/null +++ b/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/engine/FurnaceEngineModifiers.java @@ -0,0 +1,39 @@ +package com.simibubi.create.content.contraptions.components.flywheel.engine; + +import java.util.HashMap; +import java.util.Map; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; + +public class FurnaceEngineModifiers { + + public final static FurnaceEngineModifiers INSTANCE = new FurnaceEngineModifiers(); + + protected Map blockModifiers; + + public FurnaceEngineModifiers(Map blockModifiers) { + this.blockModifiers = blockModifiers; + } + + public FurnaceEngineModifiers() { + this(new HashMap<>()); + } + + public void set(Block block, float modifier) { + this.blockModifiers.put(block, modifier); + } + + public float getModifier(BlockState state, float def) { + return blockModifiers.getOrDefault(state.getBlock(), def); + } + + public float getModifier(BlockState state) { + return getModifier(state, 1f); + } + + public static void register() { + INSTANCE.set(Blocks.BLAST_FURNACE, 2f); + } +} diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/engine/FurnaceEngineTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/engine/FurnaceEngineTileEntity.java index 22742c712..03f22efe0 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/engine/FurnaceEngineTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/engine/FurnaceEngineTileEntity.java @@ -25,7 +25,7 @@ public class FurnaceEngineTileEntity extends EngineTileEntity { if (!(state.getBlock() instanceof AbstractFurnaceBlock)) return; - float modifier = state.getBlock() == Blocks.BLAST_FURNACE ? 2 : 1; + float modifier = FurnaceEngineModifiers.INSTANCE.getModifier(state); boolean active = state.hasProperty(AbstractFurnaceBlock.LIT) && state.getValue(AbstractFurnaceBlock.LIT); float speed = active ? 16 * modifier : 0; float capacity =