2020-07-28 20:46:34 +00:00
|
|
|
package com.thebrokenrail.energonrelics.block.entity.forcefield.laser;
|
2020-07-28 20:38:21 +00:00
|
|
|
|
|
|
|
import com.thebrokenrail.energonrelics.EnergonRelics;
|
|
|
|
import com.thebrokenrail.energonrelics.config.HardcodedConfig;
|
|
|
|
import net.minecraft.block.Block;
|
|
|
|
import net.minecraft.block.Blocks;
|
|
|
|
import net.minecraft.item.Item;
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
import net.minecraft.item.Items;
|
|
|
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.Random;
|
|
|
|
import java.util.function.Function;
|
|
|
|
|
|
|
|
public class IndustrialLaserRegistry {
|
|
|
|
private static final Map<Block, Function<Random, ItemStack>> map = new HashMap<>();
|
|
|
|
|
|
|
|
private static void add(Block ore, Item ingot, Block storage) {
|
|
|
|
map.put(ore, random -> {
|
|
|
|
int min = HardcodedConfig.INDUSTRIAL_LASER_MIN_INGOTS_FROM_ORE;
|
|
|
|
int max = HardcodedConfig.INDUSTRIAL_LASER_MAX_INGOTS_FROM_ORE;
|
|
|
|
|
|
|
|
int count = random.nextInt(max - min + 1) + min;
|
|
|
|
|
|
|
|
return new ItemStack(ingot, count);
|
|
|
|
});
|
|
|
|
map.put(storage, random -> new ItemStack(ingot, HardcodedConfig.INDUSTRIAL_LASER_INGOTS_FROM_STORAGE));
|
|
|
|
}
|
|
|
|
|
|
|
|
static boolean has(Block block) {
|
|
|
|
return map.containsKey(block);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ItemStack get(Block block, Random random) {
|
|
|
|
return map.get(block).apply(random);
|
|
|
|
}
|
|
|
|
|
|
|
|
static {
|
2020-07-29 18:49:14 +00:00
|
|
|
add(Blocks.REDSTONE_ORE, Items.REDSTONE, Blocks.REDSTONE_BLOCK);
|
|
|
|
add(Blocks.LAPIS_ORE, Items.LAPIS_LAZULI, Blocks.LAPIS_BLOCK);
|
2020-07-28 20:46:34 +00:00
|
|
|
add(Blocks.COAL_ORE, Items.COAL, Blocks.COAL_BLOCK);
|
2020-07-28 20:38:21 +00:00
|
|
|
add(Blocks.IRON_ORE, Items.IRON_INGOT, Blocks.IRON_BLOCK);
|
|
|
|
add(Blocks.GOLD_ORE, Items.GOLD_INGOT, Blocks.GOLD_BLOCK);
|
|
|
|
add(Blocks.DIAMOND_ORE, Items.DIAMOND, Blocks.DIAMOND_BLOCK);
|
|
|
|
add(Blocks.EMERALD_ORE, Items.EMERALD, Blocks.EMERALD_BLOCK);
|
|
|
|
add(EnergonRelics.VERIDIUM_ORE_BLOCK, EnergonRelics.VERIDIUM_INGOT_ITEM, EnergonRelics.VERIDIUM_BLOCK_BLOCK);
|
|
|
|
}
|
|
|
|
}
|