47 lines
1.4 KiB
Java
47 lines
1.4 KiB
Java
package com.thebrokenrail.energonrelics.block.entity.infuser;
|
|
|
|
import net.minecraft.item.Item;
|
|
import net.minecraft.item.Items;
|
|
import net.minecraft.util.Identifier;
|
|
import net.minecraft.util.registry.Registry;
|
|
|
|
import java.util.HashMap;
|
|
import java.util.Map;
|
|
|
|
public class InfuserRegistry {
|
|
private static final Map<Item, InfuserEntry> map = new HashMap<>();
|
|
|
|
static InfuserEntry get(Item item) {
|
|
return map.get(item);
|
|
}
|
|
|
|
private static void add(Item item, InfuserEntry entry) {
|
|
map.put(item, entry);
|
|
}
|
|
|
|
static String toString(InfuserEntry entry) {
|
|
Item item = null;
|
|
for (Map.Entry<Item, InfuserEntry> mapEntry : map.entrySet()) {
|
|
if (mapEntry.getValue() == entry) {
|
|
item = mapEntry.getKey();
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (item != null) {
|
|
return Registry.ITEM.getId(item).toString();
|
|
} else {
|
|
return "";
|
|
}
|
|
}
|
|
|
|
static InfuserEntry fromString(String str) {
|
|
Item item = Registry.ITEM.get(new Identifier(str));
|
|
return map.getOrDefault(item, null);
|
|
}
|
|
|
|
static {
|
|
add(Items.SUGAR, new InfuserEntry(51, 0.76d, new InfuserAction[]{new InfuserAction.ItemAction(Items.GLOWSTONE_DUST)}, new InfuserAction[]{new InfuserAction.ItemAction(Items.SUGAR_CANE), new InfuserAction.ExplosionAction()}));
|
|
}
|
|
}
|