mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-27 23:47:38 +01:00
Update FurnaceEngineModifiers.java
- Use registry delegates - Reduce boilerplate
This commit is contained in:
parent
6173f9600c
commit
855fc52d62
1 changed files with 13 additions and 20 deletions
|
@ -6,34 +6,27 @@ import java.util.Map;
|
|||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraftforge.registries.IRegistryDelegate;
|
||||
|
||||
public class FurnaceEngineModifiers {
|
||||
|
||||
|
||||
public final static FurnaceEngineModifiers INSTANCE = new FurnaceEngineModifiers();
|
||||
|
||||
protected Map<Block, Float> blockModifiers;
|
||||
|
||||
public FurnaceEngineModifiers(Map<Block, Float> blockModifiers) {
|
||||
this.blockModifiers = blockModifiers;
|
||||
}
|
||||
|
||||
public FurnaceEngineModifiers() {
|
||||
this(new HashMap<>());
|
||||
}
|
||||
|
||||
public void set(Block block, float modifier) {
|
||||
|
||||
protected Map<IRegistryDelegate<Block>, Float> blockModifiers = new HashMap<>();
|
||||
|
||||
public void register(IRegistryDelegate<Block> block, float modifier) {
|
||||
this.blockModifiers.put(block, modifier);
|
||||
}
|
||||
|
||||
public float getModifier(BlockState state, float def) {
|
||||
return blockModifiers.getOrDefault(state.getBlock(), def);
|
||||
|
||||
public float getModifierOrDefault(BlockState state, float defaultValue) {
|
||||
return blockModifiers.getOrDefault(state.getBlock().delegate, defaultValue);
|
||||
}
|
||||
|
||||
|
||||
public float getModifier(BlockState state) {
|
||||
return getModifier(state, 1f);
|
||||
return getModifierOrDefault(state, 1f);
|
||||
}
|
||||
|
||||
|
||||
public static void register() {
|
||||
INSTANCE.set(Blocks.BLAST_FURNACE, 2f);
|
||||
INSTANCE.register(Blocks.BLAST_FURNACE.delegate, 2f);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue