mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-14 17:33:52 +01:00
cleanup
This commit is contained in:
parent
8145014847
commit
6107b939a5
3 changed files with 23 additions and 9 deletions
|
@ -33,7 +33,7 @@ public class FurnaceEngineBlock extends EngineBlock implements ITE<FurnaceEngine
|
|||
|
||||
@Override
|
||||
protected boolean isValidBaseBlock(BlockState baseBlock, BlockGetter world, BlockPos pos) {
|
||||
return FurnaceEngineModifiers.INSTANCE.getEngineState(baseBlock).isEngine();
|
||||
return FurnaceEngineModifiers.get().getEngineState(baseBlock).isEngine();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -7,16 +7,20 @@ import java.util.function.Function;
|
|||
import net.minecraft.world.level.block.AbstractFurnaceBlock;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.RedstoneLampBlock;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraftforge.registries.IRegistryDelegate;
|
||||
|
||||
public class FurnaceEngineModifiers {
|
||||
|
||||
public final static FurnaceEngineModifiers INSTANCE = new FurnaceEngineModifiers();
|
||||
private final static FurnaceEngineModifiers INSTANCE = new FurnaceEngineModifiers();
|
||||
|
||||
protected FurnaceEngineModifiers() {
|
||||
blockModifiers = new HashMap<>();
|
||||
blockActivators = new HashMap<>();
|
||||
}
|
||||
|
||||
protected Map<IRegistryDelegate<Block>, Float> blockModifiers = new HashMap<>();
|
||||
protected Map<IRegistryDelegate<Block>, Function<BlockState, EngineState>> blockActivators = new HashMap<>();
|
||||
private final Map<IRegistryDelegate<Block>, Float> blockModifiers;
|
||||
private final Map<IRegistryDelegate<Block>, Function<BlockState, EngineState>> blockActivators;
|
||||
|
||||
public void register(IRegistryDelegate<Block> block, float modifier) {
|
||||
this.blockModifiers.put(block, modifier);
|
||||
|
@ -40,12 +44,22 @@ public class FurnaceEngineModifiers {
|
|||
}
|
||||
|
||||
public EngineState getEngineState(BlockState state) {
|
||||
return getEngineStateOrDefault(state, s -> s.getBlock() instanceof AbstractFurnaceBlock && s.hasProperty(AbstractFurnaceBlock.LIT) ? (s.getValue(AbstractFurnaceBlock.LIT) ? EngineState.ACTIVE : EngineState.VALID) : EngineState.EMPTY).apply(state);
|
||||
return getEngineStateOrDefault(state,
|
||||
s -> s.getBlock() instanceof AbstractFurnaceBlock && s.hasProperty(AbstractFurnaceBlock.LIT) ?
|
||||
(s.getValue(AbstractFurnaceBlock.LIT) ? EngineState.ACTIVE : EngineState.VALID) : EngineState.EMPTY).apply(state);
|
||||
}
|
||||
|
||||
public static void register() {
|
||||
INSTANCE.register(Blocks.BLAST_FURNACE.delegate, 2f);
|
||||
//INSTANCE.register(Blocks.REDSTONE_LAMP.delegate, 1f, s -> s.getBlock() instanceof RedstoneLampBlock && s.hasProperty(RedstoneLampBlock.LIT) ? (s.getValue(RedstoneLampBlock.LIT) ? EngineState.ACTIVE : EngineState.VALID) : EngineState.EMPTY);
|
||||
|
||||
// Example:
|
||||
// INSTANCE.register(Blocks.REDSTONE_LAMP.delegate, 1f,
|
||||
// s -> s.getBlock() instanceof RedstoneLampBlock && s.hasProperty(RedstoneLampBlock.LIT) ?
|
||||
// (s.getValue(RedstoneLampBlock.LIT) ? EngineState.ACTIVE : EngineState.VALID) : EngineState.EMPTY);
|
||||
}
|
||||
|
||||
public static FurnaceEngineModifiers get() {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
public enum EngineState {
|
||||
|
|
|
@ -22,11 +22,11 @@ public class FurnaceEngineTileEntity extends EngineTileEntity {
|
|||
|
||||
public void updateFurnace() {
|
||||
BlockState state = level.getBlockState(EngineBlock.getBaseBlockPos(getBlockState(), worldPosition));
|
||||
EngineState engineState = FurnaceEngineModifiers.INSTANCE.getEngineState(state);
|
||||
EngineState engineState = FurnaceEngineModifiers.get().getEngineState(state);
|
||||
if (engineState.isEmpty())
|
||||
return;
|
||||
|
||||
float modifier = FurnaceEngineModifiers.INSTANCE.getModifier(state);
|
||||
float modifier = FurnaceEngineModifiers.get().getModifier(state);
|
||||
boolean active = engineState.isActive();
|
||||
float speed = active ? 16 * modifier : 0;
|
||||
float capacity =
|
||||
|
|
Loading…
Reference in a new issue