mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-12 10:28:35 +00:00
registry changes
This commit is contained in:
@ -34,69 +34,51 @@ public class ItemCategories {
|
||||
private ItemCategories() {
|
||||
}
|
||||
|
||||
public static final ItemCategory ACACIA_LOGS = new ItemCategory("minecraft:acacia_logs");
|
||||
public static final ItemCategory ANVIL = new ItemCategory("minecraft:anvil");
|
||||
public static final ItemCategory BANNERS = new ItemCategory("minecraft:banners");
|
||||
public static final ItemCategory BIRCH_LOGS = new ItemCategory("minecraft:birch_logs");
|
||||
public static final ItemCategory BOATS = new ItemCategory("minecraft:boats");
|
||||
public static final ItemCategory BUTTONS = new ItemCategory("minecraft:buttons");
|
||||
public static final ItemCategory CARPETS = new ItemCategory("minecraft:carpets");
|
||||
public static final ItemCategory CORAL = new ItemCategory("minecraft:coral");
|
||||
public static final ItemCategory CORAL_PLANTS = new ItemCategory("minecraft:coral_plants");
|
||||
public static final ItemCategory DARK_OAK_LOGS = new ItemCategory("minecraft:dark_oak_logs");
|
||||
public static final ItemCategory DOORS = new ItemCategory("minecraft:doors");
|
||||
public static final ItemCategory FISHES = new ItemCategory("minecraft:fishes");
|
||||
public static final ItemCategory JUNGLE_LOGS = new ItemCategory("minecraft:jungle_logs");
|
||||
public static final ItemCategory LEAVES = new ItemCategory("minecraft:leaves");
|
||||
public static final ItemCategory LOGS = new ItemCategory("minecraft:logs");
|
||||
public static final ItemCategory OAK_LOGS = new ItemCategory("minecraft:oak_logs");
|
||||
public static final ItemCategory PLANKS = new ItemCategory("minecraft:planks");
|
||||
public static final ItemCategory RAILS = new ItemCategory("minecraft:rails");
|
||||
public static final ItemCategory SAND = new ItemCategory("minecraft:sand");
|
||||
public static final ItemCategory SAPLINGS = new ItemCategory("minecraft:saplings");
|
||||
public static final ItemCategory SLABS = new ItemCategory("minecraft:slabs");
|
||||
public static final ItemCategory SPRUCE_LOGS = new ItemCategory("minecraft:spruce_logs");
|
||||
public static final ItemCategory STAIRS = new ItemCategory("minecraft:stairs");
|
||||
public static final ItemCategory STONE_BRICKS = new ItemCategory("minecraft:stone_bricks");
|
||||
public static final ItemCategory WOODEN_BUTTONS = new ItemCategory("minecraft:wooden_buttons");
|
||||
public static final ItemCategory WOODEN_DOORS = new ItemCategory("minecraft:wooden_doors");
|
||||
public static final ItemCategory WOODEN_PRESSURE_PLATES = new ItemCategory("minecraft:wooden_pressure_plates");
|
||||
public static final ItemCategory WOODEN_SLABS = new ItemCategory("minecraft:wooden_slabs");
|
||||
public static final ItemCategory WOODEN_STAIRS = new ItemCategory("minecraft:wooden_stairs");
|
||||
public static final ItemCategory WOOL = new ItemCategory("minecraft:wool");
|
||||
public static final ItemCategory ACACIA_LOGS = register("minecraft:acacia_logs");
|
||||
public static final ItemCategory ANVIL = register("minecraft:anvil");
|
||||
public static final ItemCategory BANNERS = register("minecraft:banners");
|
||||
public static final ItemCategory BIRCH_LOGS = register("minecraft:birch_logs");
|
||||
public static final ItemCategory BOATS = register("minecraft:boats");
|
||||
public static final ItemCategory BUTTONS = register("minecraft:buttons");
|
||||
public static final ItemCategory CARPETS = register("minecraft:carpets");
|
||||
public static final ItemCategory CORAL = register("minecraft:coral");
|
||||
public static final ItemCategory CORAL_PLANTS = register("minecraft:coral_plants");
|
||||
public static final ItemCategory DARK_OAK_LOGS = register("minecraft:dark_oak_logs");
|
||||
public static final ItemCategory DOORS = register("minecraft:doors");
|
||||
public static final ItemCategory FISHES = register("minecraft:fishes");
|
||||
public static final ItemCategory JUNGLE_LOGS = register("minecraft:jungle_logs");
|
||||
public static final ItemCategory LEAVES = register("minecraft:leaves");
|
||||
public static final ItemCategory LOGS = register("minecraft:logs");
|
||||
public static final ItemCategory OAK_LOGS = register("minecraft:oak_logs");
|
||||
public static final ItemCategory PLANKS = register("minecraft:planks");
|
||||
public static final ItemCategory RAILS = register("minecraft:rails");
|
||||
public static final ItemCategory SAND = register("minecraft:sand");
|
||||
public static final ItemCategory SAPLINGS = register("minecraft:saplings");
|
||||
public static final ItemCategory SLABS = register("minecraft:slabs");
|
||||
public static final ItemCategory SPRUCE_LOGS = register("minecraft:spruce_logs");
|
||||
public static final ItemCategory STAIRS = register("minecraft:stairs");
|
||||
public static final ItemCategory STONE_BRICKS = register("minecraft:stone_bricks");
|
||||
public static final ItemCategory WOODEN_BUTTONS = register("minecraft:wooden_buttons");
|
||||
public static final ItemCategory WOODEN_DOORS = register("minecraft:wooden_doors");
|
||||
public static final ItemCategory WOODEN_PRESSURE_PLATES = register("minecraft:wooden_pressure_plates");
|
||||
public static final ItemCategory WOODEN_SLABS = register("minecraft:wooden_slabs");
|
||||
public static final ItemCategory WOODEN_STAIRS = register("minecraft:wooden_stairs");
|
||||
public static final ItemCategory WOOL = register("minecraft:wool");
|
||||
|
||||
private static final Map<String, ItemCategory> categoryMapping = new HashMap<>();
|
||||
|
||||
static {
|
||||
for (Field field : ItemCategories.class.getFields()) {
|
||||
if (field.getType() == ItemCategory.class) {
|
||||
try {
|
||||
registerCategory((ItemCategory) field.get(null));
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
private static ItemCategory register(final String id) {
|
||||
return register(new ItemCategory(id));
|
||||
}
|
||||
|
||||
public static void registerCategory(ItemCategory itemCategory) {
|
||||
if (categoryMapping.containsKey(itemCategory.getId()) && !itemCategory.getId().startsWith("minecraft:")) {
|
||||
throw new IllegalArgumentException("Existing category with this ID already registered");
|
||||
}
|
||||
|
||||
categoryMapping.put(itemCategory.getId(), itemCategory);
|
||||
public static ItemCategory register(final ItemCategory tag) {
|
||||
return ItemCategory.REGISTRY.register(tag.getId(), tag);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static ItemCategory getItemCategory(String id) {
|
||||
// If it has no namespace, assume minecraft.
|
||||
if (id != null && !id.contains(":")) {
|
||||
id = "minecraft:" + id;
|
||||
}
|
||||
return categoryMapping.get(id);
|
||||
public static ItemCategory get(final String id) {
|
||||
return ItemCategory.REGISTRY.get(id);
|
||||
}
|
||||
|
||||
public static Collection<ItemCategory> values() {
|
||||
return categoryMapping.values();
|
||||
return ItemCategory.REGISTRY.values();
|
||||
}
|
||||
}
|
||||
|
@ -22,6 +22,7 @@ package com.sk89q.worldedit.world.item;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.blocks.BaseItem;
|
||||
import com.sk89q.worldedit.extension.platform.Capability;
|
||||
import com.sk89q.worldedit.registry.NamespacedRegistry;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@ -31,6 +32,8 @@ import java.util.Set;
|
||||
*/
|
||||
public class ItemCategory {
|
||||
|
||||
public static final NamespacedRegistry<ItemCategory> REGISTRY = new NamespacedRegistry<>();
|
||||
|
||||
private final String id;
|
||||
|
||||
public ItemCategory(String id) {
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
package com.sk89q.worldedit.world.item;
|
||||
|
||||
import com.sk89q.worldedit.registry.NamespacedRegistry;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import com.sk89q.worldedit.world.registry.BundledItemData;
|
||||
@ -28,6 +29,8 @@ import javax.annotation.Nullable;
|
||||
|
||||
public class ItemType {
|
||||
|
||||
public static final NamespacedRegistry<ItemType> REGISTRY = new NamespacedRegistry<>();
|
||||
|
||||
private String id;
|
||||
|
||||
public ItemType(String id) {
|
||||
@ -73,7 +76,7 @@ public class ItemType {
|
||||
*/
|
||||
@Nullable
|
||||
public BlockType getBlockType() {
|
||||
return BlockTypes.getBlockType(this.id);
|
||||
return BlockTypes.get(this.id);
|
||||
}
|
||||
|
||||
/**
|
||||
|
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user