Reorganized Imports/Packages
This commit is contained in:
parent
cb9459f176
commit
3ee10482ab
721 changed files with 34873 additions and 33558 deletions
82
src/main/java/org/betterx/bclib/registry/BaseRegistry.java
Normal file
82
src/main/java/org/betterx/bclib/registry/BaseRegistry.java
Normal file
|
@ -0,0 +1,82 @@
|
|||
package org.betterx.bclib.registry;
|
||||
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.CreativeModeTab;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
|
||||
import net.fabricmc.fabric.api.item.v1.FabricItemSettings;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import org.betterx.bclib.config.PathConfig;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public abstract class BaseRegistry<T> {
|
||||
private static final List<BaseRegistry<?>> REGISTRIES = Lists.newArrayList();
|
||||
private static final Map<String, List<Item>> MOD_BLOCK_ITEMS = Maps.newHashMap();
|
||||
private static final Map<String, List<Block>> MOD_BLOCKS = Maps.newHashMap();
|
||||
private static final Map<String, List<Item>> MOD_ITEMS = Maps.newHashMap();
|
||||
|
||||
protected final CreativeModeTab creativeTab;
|
||||
protected final PathConfig config;
|
||||
|
||||
protected BaseRegistry(CreativeModeTab creativeTab, PathConfig config) {
|
||||
this.creativeTab = creativeTab;
|
||||
this.config = config;
|
||||
REGISTRIES.add(this);
|
||||
}
|
||||
|
||||
public abstract T register(ResourceLocation objId, T obj);
|
||||
|
||||
public abstract void registerItem(ResourceLocation id, Item item);
|
||||
|
||||
public FabricItemSettings makeItemSettings() {
|
||||
FabricItemSettings properties = new FabricItemSettings();
|
||||
return (FabricItemSettings) properties.tab(creativeTab);
|
||||
}
|
||||
|
||||
private void registerInternal() {
|
||||
}
|
||||
|
||||
public static Map<String, List<Item>> getRegisteredBlocks() {
|
||||
return MOD_BLOCK_ITEMS;
|
||||
}
|
||||
|
||||
public static Map<String, List<Item>> getRegisteredItems() {
|
||||
return MOD_ITEMS;
|
||||
}
|
||||
|
||||
public static List<Item> getModBlockItems(String modId) {
|
||||
if (MOD_BLOCK_ITEMS.containsKey(modId)) {
|
||||
return MOD_BLOCK_ITEMS.get(modId);
|
||||
}
|
||||
List<Item> modBlocks = Lists.newArrayList();
|
||||
MOD_BLOCK_ITEMS.put(modId, modBlocks);
|
||||
return modBlocks;
|
||||
}
|
||||
|
||||
public static List<Item> getModItems(String modId) {
|
||||
if (MOD_ITEMS.containsKey(modId)) {
|
||||
return MOD_ITEMS.get(modId);
|
||||
}
|
||||
List<Item> modBlocks = Lists.newArrayList();
|
||||
MOD_ITEMS.put(modId, modBlocks);
|
||||
return modBlocks;
|
||||
}
|
||||
|
||||
public static List<Block> getModBlocks(String modId) {
|
||||
if (MOD_BLOCKS.containsKey(modId)) {
|
||||
return MOD_BLOCKS.get(modId);
|
||||
}
|
||||
List<Block> modBlocks = Lists.newArrayList();
|
||||
MOD_BLOCKS.put(modId, modBlocks);
|
||||
return modBlocks;
|
||||
}
|
||||
|
||||
public static void register() {
|
||||
REGISTRIES.forEach(BaseRegistry::registerInternal);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue