Mod blocks in registry, version change
This commit is contained in:
parent
473029c31f
commit
c61856cdba
3 changed files with 21 additions and 8 deletions
|
@ -11,7 +11,7 @@ loader_version= 0.12.4
|
||||||
fabric_version = 0.41.3+1.17
|
fabric_version = 0.41.3+1.17
|
||||||
|
|
||||||
# Mod Properties
|
# Mod Properties
|
||||||
mod_version = 0.4.4
|
mod_version = 0.5.0
|
||||||
maven_group = ru.bclib
|
maven_group = ru.bclib
|
||||||
archives_base_name = bclib
|
archives_base_name = bclib
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ import net.fabricmc.fabric.api.item.v1.FabricItemSettings;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.world.item.CreativeModeTab;
|
import net.minecraft.world.item.CreativeModeTab;
|
||||||
import net.minecraft.world.item.Item;
|
import net.minecraft.world.item.Item;
|
||||||
|
import net.minecraft.world.level.block.Block;
|
||||||
import ru.bclib.config.PathConfig;
|
import ru.bclib.config.PathConfig;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -13,7 +14,8 @@ import java.util.Map;
|
||||||
|
|
||||||
public abstract class BaseRegistry<T> {
|
public abstract class BaseRegistry<T> {
|
||||||
private static final List<BaseRegistry<?>> REGISTRIES = Lists.newArrayList();
|
private static final List<BaseRegistry<?>> REGISTRIES = Lists.newArrayList();
|
||||||
private static final Map<String, List<Item>> MOD_BLOCKS = Maps.newHashMap();
|
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();
|
private static final Map<String, List<Item>> MOD_ITEMS = Maps.newHashMap();
|
||||||
|
|
||||||
protected final CreativeModeTab creativeTab;
|
protected final CreativeModeTab creativeTab;
|
||||||
|
@ -37,19 +39,19 @@ public abstract class BaseRegistry<T> {
|
||||||
private void registerInternal() {}
|
private void registerInternal() {}
|
||||||
|
|
||||||
public static Map<String, List<Item>> getRegisteredBlocks() {
|
public static Map<String, List<Item>> getRegisteredBlocks() {
|
||||||
return MOD_BLOCKS;
|
return MOD_BLOCK_ITEMS;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Map<String, List<Item>> getRegisteredItems() {
|
public static Map<String, List<Item>> getRegisteredItems() {
|
||||||
return MOD_ITEMS;
|
return MOD_ITEMS;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<Item> getModBlocks(String modId) {
|
public static List<Item> getModBlockItems(String modId) {
|
||||||
if (MOD_BLOCKS.containsKey(modId)) {
|
if (MOD_BLOCK_ITEMS.containsKey(modId)) {
|
||||||
return MOD_BLOCKS.get(modId);
|
return MOD_BLOCK_ITEMS.get(modId);
|
||||||
}
|
}
|
||||||
List<Item> modBlocks = Lists.newArrayList();
|
List<Item> modBlocks = Lists.newArrayList();
|
||||||
MOD_BLOCKS.put(modId, modBlocks);
|
MOD_BLOCK_ITEMS.put(modId, modBlocks);
|
||||||
return modBlocks;
|
return modBlocks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,6 +64,15 @@ public abstract class BaseRegistry<T> {
|
||||||
return 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() {
|
public static void register() {
|
||||||
REGISTRIES.forEach(BaseRegistry::registerInternal);
|
REGISTRIES.forEach(BaseRegistry::registerInternal);
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,6 +38,7 @@ public class BlockRegistry extends BaseRegistry<Block> {
|
||||||
}
|
}
|
||||||
|
|
||||||
block = Registry.register(Registry.BLOCK, id, block);
|
block = Registry.register(Registry.BLOCK, id, block);
|
||||||
|
getModBlocks(id.getNamespace()).add(block);
|
||||||
|
|
||||||
if (block instanceof BaseLeavesBlock){
|
if (block instanceof BaseLeavesBlock){
|
||||||
TagAPI.addTags(block, TagAPI.BLOCK_LEAVES);
|
TagAPI.addTags(block, TagAPI.BLOCK_LEAVES);
|
||||||
|
@ -58,6 +59,7 @@ public class BlockRegistry extends BaseRegistry<Block> {
|
||||||
if (!config.getBooleanRoot(id.getNamespace(), true)) {
|
if (!config.getBooleanRoot(id.getNamespace(), true)) {
|
||||||
return block;
|
return block;
|
||||||
}
|
}
|
||||||
|
getModBlocks(id.getNamespace()).add(block);
|
||||||
return Registry.register(Registry.BLOCK, id, block);
|
return Registry.register(Registry.BLOCK, id, block);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,7 +72,7 @@ public class BlockRegistry extends BaseRegistry<Block> {
|
||||||
public void registerItem(ResourceLocation id, Item item) {
|
public void registerItem(ResourceLocation id, Item item) {
|
||||||
if (item != null && item != Items.AIR) {
|
if (item != null && item != Items.AIR) {
|
||||||
Registry.register(Registry.ITEM, id, item);
|
Registry.register(Registry.ITEM, id, item);
|
||||||
getModBlocks(id.getNamespace()).add(item);
|
getModBlockItems(id.getNamespace()).add(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue