This commit is contained in:
parent
3a8fa37f12
commit
96f7dd2fce
@ -4,10 +4,24 @@ import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.registry.RegistryKey;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**
|
||||
* Block Position Including Dimension
|
||||
*/
|
||||
public class BlockPosWithDimension {
|
||||
/**
|
||||
* Position
|
||||
*/
|
||||
public final BlockPos pos;
|
||||
/**
|
||||
* Dimension
|
||||
*/
|
||||
public final RegistryKey<World> dimension;
|
||||
|
||||
/**
|
||||
* Create
|
||||
* @param pos Position
|
||||
* @param dimension Dimension
|
||||
*/
|
||||
public BlockPosWithDimension(BlockPos pos, RegistryKey<World> dimension) {
|
||||
this.pos = pos;
|
||||
this.dimension = dimension;
|
||||
|
@ -1,5 +1,8 @@
|
||||
package com.thebrokenrail.energonrelics.util;
|
||||
|
||||
/**
|
||||
* Missing Switch Case Exception
|
||||
*/
|
||||
public class MissingCaseException extends RuntimeException {
|
||||
public MissingCaseException(Enum<?> value) {
|
||||
super(value.name());
|
||||
|
@ -4,13 +4,27 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* Weighted List
|
||||
* @param <T> Entry Type
|
||||
*/
|
||||
public class WeightedList<T> {
|
||||
private final Map<T, Integer> map = new HashMap<>();
|
||||
|
||||
/**
|
||||
* Add Entry
|
||||
* @param weight Weight
|
||||
* @param obj Entry
|
||||
*/
|
||||
public void add(int weight, T obj) {
|
||||
map.put(obj, weight);
|
||||
}
|
||||
|
||||
/**
|
||||
* Pick Entry
|
||||
* @param random Random
|
||||
* @return Entry
|
||||
*/
|
||||
public T pick(Random random) {
|
||||
int totalWeight = 0;
|
||||
for (Map.Entry<T, Integer> entry : map.entrySet()) {
|
||||
|
Reference in New Issue
Block a user