This repository has been archived on 2023-11-26. You can view files and clone it, but cannot push or open issues or pull requests.
EnergonRelics/src/main/java/com/thebrokenrail/energonrelics/block/entity/forcefield/laser/IndustrialLaserRegistry.java

48 lines
1.7 KiB
Java

package com.thebrokenrail.energonrelics.block.entity.forcefield.laser;
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 {
add(Blocks.COAL_ORE, Items.COAL, Blocks.COAL_BLOCK);
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);
}
}