[Change] Moved and refactored Tag-API

This commit is contained in:
Frank 2022-06-21 18:19:10 +02:00
parent 25fa53541f
commit 184f3a6448
56 changed files with 1220 additions and 358 deletions

View file

@ -10,7 +10,6 @@ import org.betterx.bclib.api.v2.levelgen.features.blockpredicates.Types;
import org.betterx.bclib.api.v2.levelgen.features.placement.PlacementModifiers;
import org.betterx.bclib.api.v2.levelgen.structures.TemplatePiece;
import org.betterx.bclib.api.v2.levelgen.surface.rules.Conditions;
import org.betterx.bclib.api.v2.tag.TagAPI;
import org.betterx.bclib.commands.CommandRegistry;
import org.betterx.bclib.config.Configs;
import org.betterx.bclib.recipes.AnvilRecipe;
@ -19,6 +18,7 @@ import org.betterx.bclib.registry.BaseBlockEntities;
import org.betterx.bclib.registry.BaseRegistry;
import org.betterx.bclib.util.Logger;
import org.betterx.worlds.together.WorldsTogether;
import org.betterx.worlds.together.tag.TagManager;
import org.betterx.worlds.together.world.WorldConfig;
import net.minecraft.resources.ResourceLocation;
@ -43,7 +43,7 @@ public class BCLib implements ModInitializer {
BaseBlockEntities.register();
BCLibEndBiomeSource.register();
BCLibNetherBiomeSource.register();
TagAPI.init();
TagManager.ensureStaticallyLoaded();
CraftingRecipes.init();
WorldConfig.registerModCache(MOD_ID);
DataExchangeAPI.registerMod(MOD_ID);

View file

@ -2,8 +2,6 @@ package org.betterx.bclib.api.v2;
import org.betterx.bclib.BCLib;
import org.betterx.bclib.api.v2.levelgen.biomes.InternalBiomeAPI;
import org.betterx.bclib.api.v2.tag.NamedMineableTags;
import org.betterx.bclib.api.v2.tag.TagAPI;
import org.betterx.bclib.blocks.BaseBarrelBlock;
import org.betterx.bclib.blocks.BaseChestBlock;
import org.betterx.bclib.blocks.BaseFurnaceBlock;
@ -17,6 +15,8 @@ import org.betterx.bclib.interfaces.RenderLayerProvider;
import org.betterx.bclib.interfaces.TagProvider;
import org.betterx.bclib.interfaces.tools.*;
import org.betterx.bclib.registry.BaseBlockEntities;
import org.betterx.worlds.together.tag.MineableTags;
import org.betterx.worlds.together.tag.TagManager;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.core.Registry;
@ -97,7 +97,7 @@ public class PostInitAPI {
} catch (NullPointerException ex) {
BCLib.LOGGER.error(item + " probably tried to access blockTags.", ex);
}
itemTags.forEach(tag -> TagAPI.addItemTag(tag, item));
itemTags.forEach(tag -> TagManager.ITEMS.add(tag, item));
itemTags.clear();
}
}
@ -117,31 +117,31 @@ public class PostInitAPI {
}
if (!(block instanceof PreventMineableAdd)) {
if (block instanceof AddMineableShears) {
TagAPI.addBlockTags(block, NamedMineableTags.SHEARS);
TagManager.BLOCKS.add(block, MineableTags.SHEARS);
}
if (block instanceof AddMineableAxe) {
TagAPI.addBlockTags(block, NamedMineableTags.AXE);
TagManager.BLOCKS.add(block, MineableTags.AXE);
}
if (block instanceof AddMineablePickaxe) {
TagAPI.addBlockTags(block, NamedMineableTags.PICKAXE);
TagManager.BLOCKS.add(block, MineableTags.PICKAXE);
}
if (block instanceof AddMineableShovel) {
TagAPI.addBlockTags(block, NamedMineableTags.SHOVEL);
TagManager.BLOCKS.add(block, MineableTags.SHOVEL);
}
if (block instanceof AddMineableHoe) {
TagAPI.addBlockTags(block, NamedMineableTags.HOE);
TagManager.BLOCKS.add(block, MineableTags.HOE);
}
if (block instanceof AddMineableSword) {
TagAPI.addBlockTags(block, NamedMineableTags.SWORD);
TagManager.BLOCKS.add(block, MineableTags.SWORD);
}
if (block instanceof AddMineableHammer) {
TagAPI.addBlockTags(block, NamedMineableTags.HAMMER);
TagManager.BLOCKS.add(block, MineableTags.HAMMER);
}
}
if (block instanceof TagProvider) {
((TagProvider) block).addTags(blockTags, itemTags);
blockTags.forEach(tag -> TagAPI.addBlockTag(tag, block));
itemTags.forEach(tag -> TagAPI.addItemTag(tag, block));
blockTags.forEach(tag -> TagManager.BLOCKS.add(tag, block));
itemTags.forEach(tag -> TagManager.ITEMS.add(tag, block.asItem()));
blockTags.clear();
itemTags.clear();
}

View file

@ -2,8 +2,8 @@ package org.betterx.bclib.api.v2.levelgen.biomes;
import org.betterx.bclib.BCLib;
import org.betterx.bclib.api.v2.levelgen.surface.SurfaceRuleUtil;
import org.betterx.bclib.api.v2.tag.TagAPI;
import org.betterx.bclib.util.WeightedList;
import org.betterx.worlds.together.tag.TagManager;
import net.minecraft.data.BuiltinRegistries;
import net.minecraft.resources.ResourceKey;
@ -201,7 +201,7 @@ public class BCLBiome extends BCLBiomeSettings {
*/
void afterRegistration() {
ResourceKey<Biome> key = BuiltinRegistries.BIOME.getResourceKey(getBiome()).orElseThrow();
this.biomeTags.forEach(tagKey -> TagAPI.addBiomeTag(tagKey, biome));
this.biomeTags.forEach(tagKey -> TagManager.BIOMES.add(tagKey, biome));
if (this.surfaceInit != null) {
surfaceInit.accept(key);

View file

@ -2,12 +2,12 @@ package org.betterx.bclib.api.v2.levelgen.biomes;
import org.betterx.bclib.BCLib;
import org.betterx.bclib.api.v2.levelgen.features.BCLFeature;
import org.betterx.bclib.api.v2.tag.CommonBiomeTags;
import org.betterx.bclib.api.v2.tag.TagAPI;
import org.betterx.bclib.interfaces.SurfaceMaterialProvider;
import org.betterx.bclib.mixin.common.BiomeGenerationSettingsAccessor;
import org.betterx.bclib.mixin.common.MobSpawnSettingsAccessor;
import org.betterx.bclib.util.CollectionsUtil;
import org.betterx.worlds.together.tag.CommonBiomeTags;
import org.betterx.worlds.together.tag.TagManager;
import net.minecraft.client.Minecraft;
import net.minecraft.core.BlockPos;
@ -150,10 +150,10 @@ public class BiomeAPI {
BiomeType.BIOME_TYPE_MAP.put(bclbiome.getID(), dim);
if (dim != null && dim.is(BiomeType.NETHER)) {
TagAPI.addBiomeTag(BiomeTags.IS_NETHER, bclbiome.getBiome());
TagAPI.addBiomeTag(CommonBiomeTags.IN_NETHER, bclbiome.getBiome());
TagManager.BIOMES.add(BiomeTags.IS_NETHER, bclbiome.getBiome());
TagManager.BIOMES.add(CommonBiomeTags.IN_NETHER, bclbiome.getBiome());
} else if (dim != null && dim.is(BiomeType.END)) {
TagAPI.addBiomeTag(BiomeTags.IS_END, bclbiome.getBiome());
TagManager.BIOMES.add(BiomeTags.IS_END, bclbiome.getBiome());
}
bclbiome.afterRegistration();

View file

@ -1,7 +1,7 @@
package org.betterx.bclib.api.v2.levelgen.features;
import org.betterx.bclib.api.v2.levelgen.features.placement.*;
import org.betterx.bclib.api.v2.tag.CommonBlockTags;
import org.betterx.worlds.together.tag.CommonBlockTags;
import net.minecraft.core.Direction;
import net.minecraft.core.Vec3i;

View file

@ -1,6 +1,6 @@
package org.betterx.bclib.api.v2.levelgen.structures;
import org.betterx.bclib.api.v2.tag.TagAPI;
import org.betterx.worlds.together.tag.TagManager;
import com.mojang.serialization.Codec;
import net.minecraft.resources.ResourceLocation;
@ -81,7 +81,7 @@ public class BCLStructureBuilder<S extends Structure> {
}
public BCLStructureBuilder<S> biomeTag(String modID, String path) {
this.biomeTag = TagAPI.makeStructureTag(modID, path);
this.biomeTag = TagManager.BIOMES.makeStructureTag(modID, path);
return this;
}

View file

@ -3,6 +3,14 @@ package org.betterx.bclib.api.v2.tag;
import net.minecraft.tags.TagKey;
import net.minecraft.world.level.biome.Biome;
/**
* @deprecated Replaced by {@link org.betterx.worlds.together.tag.CommonBiomeTags}
*/
@Deprecated(forRemoval = true)
public class CommonBiomeTags {
public static final TagKey<Biome> IN_NETHER = TagAPI.makeCommonBiomeTag("in_nether");
/**
* @deprecated Replaced by {@link org.betterx.worlds.together.tag.CommonBiomeTags#IN_NETHER}
**/
@Deprecated(forRemoval = true)
public static final TagKey<Biome> IN_NETHER = org.betterx.worlds.together.tag.CommonBiomeTags.IN_NETHER;
}

View file

@ -1,100 +1,131 @@
package org.betterx.bclib.api.v2.tag;
import net.minecraft.tags.BlockTags;
import net.minecraft.tags.TagKey;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
/**
* @deprecated Replaced by {@link org.betterx.worlds.together.tag.CommonBlockTags}
*/
@Deprecated(forRemoval = true)
public class CommonBlockTags {
public static final TagKey<Block> BARREL = TagAPI.makeCommonBlockTag("barrel");
public static final TagKey<Block> BOOKSHELVES = TagAPI.makeCommonBlockTag("bookshelves");
public static final TagKey<Block> CHEST = TagAPI.makeCommonBlockTag("chest");
public static final TagKey<Block> END_STONES = TagAPI.makeCommonBlockTag("end_stones");
public static final TagKey<Block> GEN_END_STONES = END_STONES;
public static final TagKey<Block> IMMOBILE = TagAPI.makeCommonBlockTag("immobile");
public static final TagKey<Block> LEAVES = TagAPI.makeCommonBlockTag("leaves");
public static final TagKey<Block> NETHERRACK = TagAPI.makeCommonBlockTag("netherrack");
public static final TagKey<Block> MYCELIUM = TagAPI.makeCommonBlockTag("mycelium");
public static final TagKey<Block> NETHER_MYCELIUM = TagAPI.makeCommonBlockTag("nether_mycelium");
public static final TagKey<Block> NETHER_PORTAL_FRAME = TagAPI.makeCommonBlockTag("nether_pframe");
public static final TagKey<Block> NETHER_STONES = TagAPI.makeCommonBlockTag("nether_stones");
public static final TagKey<Block> NETHER_ORES = TagAPI.makeCommonBlockTag("nether_ores");
public static final TagKey<Block> END_ORES = TagAPI.makeCommonBlockTag("end_ores");
public static final TagKey<Block> SAPLINGS = TagAPI.makeCommonBlockTag("saplings");
public static final TagKey<Block> SOUL_GROUND = TagAPI.makeCommonBlockTag("soul_ground");
public static final TagKey<Block> WOODEN_BARREL = TagAPI.makeCommonBlockTag("wooden_barrels");
public static final TagKey<Block> WOODEN_CHEST = TagAPI.makeCommonBlockTag("wooden_chests");
public static final TagKey<Block> WORKBENCHES = TagAPI.makeCommonBlockTag("workbench");
public static final TagKey<Block> DRAGON_IMMUNE = TagAPI.makeCommonBlockTag("dragon_immune");
public static final TagKey<Block> MINABLE_WITH_HAMMER = TagAPI.makeCommonBlockTag("mineable/hammer");
public static final TagKey<Block> IS_OBSIDIAN = TagAPI.makeCommonBlockTag("is_obsidian");
public static final TagKey<Block> TERRAIN = TagAPI.makeCommonBlockTag("terrain");
public static final TagKey<Block> NETHER_TERRAIN = TagAPI.makeCommonBlockTag("nether_terrain");
static {
TagAPI.BLOCKS.addOtherTags(DRAGON_IMMUNE, BlockTags.DRAGON_IMMUNE);
TagAPI.BLOCKS.add(END_STONES, Blocks.END_STONE);
TagAPI.BLOCKS.addOtherTags(NETHER_STONES, BlockTags.BASE_STONE_NETHER);
TagAPI.BLOCKS.add(
NETHERRACK,
Blocks.NETHERRACK,
Blocks.NETHER_QUARTZ_ORE,
Blocks.NETHER_GOLD_ORE,
Blocks.CRIMSON_NYLIUM,
Blocks.WARPED_NYLIUM
);
TagAPI.BLOCKS.add(NETHER_ORES, Blocks.NETHER_QUARTZ_ORE, Blocks.NETHER_GOLD_ORE);
TagAPI.BLOCKS.add(SOUL_GROUND, Blocks.SOUL_SAND, Blocks.SOUL_SOIL);
TagAPI.BLOCKS.add(IS_OBSIDIAN, Blocks.OBSIDIAN, Blocks.CRYING_OBSIDIAN);
TagAPI.BLOCKS.add(MYCELIUM, Blocks.MYCELIUM);
TagAPI.BLOCKS.addOtherTags(MYCELIUM, NETHER_MYCELIUM);
TagAPI.BLOCKS.add(
TERRAIN,
Blocks.MAGMA_BLOCK,
Blocks.GRAVEL,
Blocks.SAND,
Blocks.RED_SAND,
Blocks.GLOWSTONE,
Blocks.BONE_BLOCK,
Blocks.SCULK
);
TagAPI.BLOCKS.addOtherTags(
TERRAIN,
NETHER_TERRAIN,
BlockTags.DRIPSTONE_REPLACEABLE,
BlockTags.BASE_STONE_OVERWORLD,
BlockTags.NYLIUM,
MYCELIUM,
END_STONES
);
TagAPI.BLOCKS.add(
NETHER_TERRAIN,
Blocks.MAGMA_BLOCK,
Blocks.GRAVEL,
Blocks.RED_SAND,
Blocks.GLOWSTONE,
Blocks.BONE_BLOCK,
Blocks.SCULK
);
TagAPI.BLOCKS.addOtherTags(
NETHER_TERRAIN,
NETHERRACK,
BlockTags.NYLIUM,
NETHER_STONES,
NETHER_ORES,
SOUL_GROUND,
NETHER_MYCELIUM
);
}
/**
* @deprecated Replaced by {@link org.betterx.worlds.together.tag.CommonBlockTags#BARREL}
**/
@Deprecated(forRemoval = true)
public static final TagKey<Block> BARREL = org.betterx.worlds.together.tag.CommonBlockTags.BARREL;
/**
* @deprecated Replaced by {@link org.betterx.worlds.together.tag.CommonBlockTags#BOOKSHELVES}
**/
@Deprecated(forRemoval = true)
public static final TagKey<Block> BOOKSHELVES = org.betterx.worlds.together.tag.CommonBlockTags.BOOKSHELVES;
/**
* @deprecated Replaced by {@link org.betterx.worlds.together.tag.CommonBlockTags#CHEST}
**/
@Deprecated(forRemoval = true)
public static final TagKey<Block> CHEST = org.betterx.worlds.together.tag.CommonBlockTags.CHEST;
/**
* @deprecated Replaced by {@link org.betterx.worlds.together.tag.CommonBlockTags#END_STONES}
**/
@Deprecated(forRemoval = true)
public static final TagKey<Block> END_STONES = org.betterx.worlds.together.tag.CommonBlockTags.END_STONES;
/**
* @deprecated Replaced by {@link org.betterx.worlds.together.tag.CommonBlockTags#GEN_END_STONES}
**/
@Deprecated(forRemoval = true)
public static final TagKey<Block> GEN_END_STONES = org.betterx.worlds.together.tag.CommonBlockTags.GEN_END_STONES;
/**
* @deprecated Replaced by {@link org.betterx.worlds.together.tag.CommonBlockTags#IMMOBILE}
**/
@Deprecated(forRemoval = true)
public static final TagKey<Block> IMMOBILE = org.betterx.worlds.together.tag.CommonBlockTags.IMMOBILE;
/**
* @deprecated Replaced by {@link org.betterx.worlds.together.tag.CommonBlockTags#LEAVES}
**/
@Deprecated(forRemoval = true)
public static final TagKey<Block> LEAVES = org.betterx.worlds.together.tag.CommonBlockTags.LEAVES;
/**
* @deprecated Replaced by {@link org.betterx.worlds.together.tag.CommonBlockTags#NETHERRACK}
**/
@Deprecated(forRemoval = true)
public static final TagKey<Block> NETHERRACK = org.betterx.worlds.together.tag.CommonBlockTags.NETHERRACK;
/**
* @deprecated Replaced by {@link org.betterx.worlds.together.tag.CommonBlockTags#MYCELIUM}
**/
@Deprecated(forRemoval = true)
public static final TagKey<Block> MYCELIUM = org.betterx.worlds.together.tag.CommonBlockTags.MYCELIUM;
/**
* @deprecated Replaced by {@link org.betterx.worlds.together.tag.CommonBlockTags#NETHER_MYCELIUM}
**/
@Deprecated(forRemoval = true)
public static final TagKey<Block> NETHER_MYCELIUM = org.betterx.worlds.together.tag.CommonBlockTags.NETHER_MYCELIUM;
/**
* @deprecated Replaced by {@link org.betterx.worlds.together.tag.CommonBlockTags#NETHER_PORTAL_FRAME}
**/
@Deprecated(forRemoval = true)
public static final TagKey<Block> NETHER_PORTAL_FRAME = org.betterx.worlds.together.tag.CommonBlockTags.NETHER_PORTAL_FRAME;
/**
* @deprecated Replaced by {@link org.betterx.worlds.together.tag.CommonBlockTags#NETHER_STONES}
**/
@Deprecated(forRemoval = true)
public static final TagKey<Block> NETHER_STONES = org.betterx.worlds.together.tag.CommonBlockTags.NETHER_STONES;
/**
* @deprecated Replaced by {@link org.betterx.worlds.together.tag.CommonBlockTags#NETHER_ORES}
**/
@Deprecated(forRemoval = true)
public static final TagKey<Block> NETHER_ORES = org.betterx.worlds.together.tag.CommonBlockTags.NETHER_ORES;
/**
* @deprecated Replaced by {@link org.betterx.worlds.together.tag.CommonBlockTags#END_ORES}
**/
@Deprecated(forRemoval = true)
public static final TagKey<Block> END_ORES = org.betterx.worlds.together.tag.CommonBlockTags.END_ORES;
/**
* @deprecated Replaced by {@link org.betterx.worlds.together.tag.CommonBlockTags#SAPLINGS}
**/
@Deprecated(forRemoval = true)
public static final TagKey<Block> SAPLINGS = org.betterx.worlds.together.tag.CommonBlockTags.SAPLINGS;
/**
* @deprecated Replaced by {@link org.betterx.worlds.together.tag.CommonBlockTags#SOUL_GROUND}
**/
@Deprecated(forRemoval = true)
public static final TagKey<Block> SOUL_GROUND = org.betterx.worlds.together.tag.CommonBlockTags.SOUL_GROUND;
/**
* @deprecated Replaced by {@link org.betterx.worlds.together.tag.CommonBlockTags#WOODEN_BARREL}
**/
@Deprecated(forRemoval = true)
public static final TagKey<Block> WOODEN_BARREL = org.betterx.worlds.together.tag.CommonBlockTags.WOODEN_BARREL;
/**
* @deprecated Replaced by {@link org.betterx.worlds.together.tag.CommonBlockTags#WOODEN_CHEST}
**/
@Deprecated(forRemoval = true)
public static final TagKey<Block> WOODEN_CHEST = org.betterx.worlds.together.tag.CommonBlockTags.WOODEN_CHEST;
/**
* @deprecated Replaced by {@link org.betterx.worlds.together.tag.CommonBlockTags#WORKBENCHES}
**/
@Deprecated(forRemoval = true)
public static final TagKey<Block> WORKBENCHES = org.betterx.worlds.together.tag.CommonBlockTags.WORKBENCHES;
/**
* @deprecated Replaced by {@link org.betterx.worlds.together.tag.CommonBlockTags#DRAGON_IMMUNE}
**/
@Deprecated(forRemoval = true)
public static final TagKey<Block> DRAGON_IMMUNE = org.betterx.worlds.together.tag.CommonBlockTags.DRAGON_IMMUNE;
/**
* @deprecated Replaced by {@link org.betterx.worlds.together.tag.CommonBlockTags#MINABLE_WITH_HAMMER}
**/
@Deprecated(forRemoval = true)
public static final TagKey<Block> MINABLE_WITH_HAMMER = org.betterx.worlds.together.tag.CommonBlockTags.MINABLE_WITH_HAMMER;
/**
* @deprecated Replaced by {@link org.betterx.worlds.together.tag.CommonBlockTags#IS_OBSIDIAN}
**/
@Deprecated(forRemoval = true)
public static final TagKey<Block> IS_OBSIDIAN = org.betterx.worlds.together.tag.CommonBlockTags.IS_OBSIDIAN;
/**
* @deprecated Replaced by {@link org.betterx.worlds.together.tag.CommonBlockTags#TERRAIN}
**/
@Deprecated(forRemoval = true)
public static final TagKey<Block> TERRAIN = org.betterx.worlds.together.tag.CommonBlockTags.TERRAIN;
/**
* @deprecated Replaced by {@link org.betterx.worlds.together.tag.CommonBlockTags#NETHER_TERRAIN}
**/
@Deprecated(forRemoval = true)
public static final TagKey<Block> NETHER_TERRAIN = org.betterx.worlds.together.tag.CommonBlockTags.NETHER_TERRAIN;
}

View file

@ -2,23 +2,72 @@ package org.betterx.bclib.api.v2.tag;
import net.minecraft.tags.TagKey;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.Blocks;
/**
* @deprecated Replaced by {@link org.betterx.worlds.together.tag.CommonItemTags}
*/
@Deprecated(forRemoval = true)
public class CommonItemTags {
public final static TagKey<Item> HAMMERS = TagAPI.makeCommonItemTag("hammers");
public static final TagKey<Item> BARREL = TagAPI.makeCommonItemTag("barrel");
public static final TagKey<Item> CHEST = TagAPI.makeCommonItemTag("chest");
public static final TagKey<Item> SHEARS = TagAPI.makeCommonItemTag("shears");
public static final TagKey<Item> FURNACES = TagAPI.makeCommonItemTag("furnaces");
public static final TagKey<Item> IRON_INGOTS = TagAPI.makeCommonItemTag("iron_ingots");
public static final TagKey<Item> LEAVES = TagAPI.makeCommonItemTag("leaves");
public static final TagKey<Item> SAPLINGS = TagAPI.makeCommonItemTag("saplings");
public static final TagKey<Item> SOUL_GROUND = TagAPI.makeCommonItemTag("soul_ground");
public static final TagKey<Item> WOODEN_BARREL = TagAPI.makeCommonItemTag("wooden_barrels");
public static final TagKey<Item> WOODEN_CHEST = TagAPI.makeCommonItemTag("wooden_chests");
public static final TagKey<Item> WORKBENCHES = TagAPI.makeCommonItemTag("workbench");
static {
TagAPI.ITEMS.add(SOUL_GROUND, Blocks.SOUL_SAND.asItem(), Blocks.SOUL_SOIL.asItem());
}
/**
* @deprecated Replaced by {@link org.betterx.worlds.together.tag.CommonItemTags#HAMMERS}
**/
@Deprecated(forRemoval = true)
public final static TagKey<Item> HAMMERS = org.betterx.worlds.together.tag.CommonItemTags.HAMMERS;
/**
* @deprecated Replaced by {@link org.betterx.worlds.together.tag.CommonItemTags#BARREL}
**/
@Deprecated(forRemoval = true)
public static final TagKey<Item> BARREL = org.betterx.worlds.together.tag.CommonItemTags.BARREL;
/**
* @deprecated Replaced by {@link org.betterx.worlds.together.tag.CommonItemTags#CHEST}
**/
@Deprecated(forRemoval = true)
public static final TagKey<Item> CHEST = org.betterx.worlds.together.tag.CommonItemTags.CHEST;
/**
* @deprecated Replaced by {@link org.betterx.worlds.together.tag.CommonItemTags#SHEARS}
**/
@Deprecated(forRemoval = true)
public static final TagKey<Item> SHEARS = org.betterx.worlds.together.tag.CommonItemTags.SHEARS;
/**
* @deprecated Replaced by {@link org.betterx.worlds.together.tag.CommonItemTags#FURNACES}
**/
@Deprecated(forRemoval = true)
public static final TagKey<Item> FURNACES = org.betterx.worlds.together.tag.CommonItemTags.FURNACES;
/**
* @deprecated Replaced by {@link org.betterx.worlds.together.tag.CommonItemTags#IRON_INGOTS}
**/
@Deprecated(forRemoval = true)
public static final TagKey<Item> IRON_INGOTS = org.betterx.worlds.together.tag.CommonItemTags.IRON_INGOTS;
/**
* @deprecated Replaced by {@link org.betterx.worlds.together.tag.CommonItemTags#LEAVES}
**/
@Deprecated(forRemoval = true)
public static final TagKey<Item> LEAVES = org.betterx.worlds.together.tag.CommonItemTags.LEAVES;
/**
* @deprecated Replaced by {@link org.betterx.worlds.together.tag.CommonItemTags#SAPLINGS}
**/
@Deprecated(forRemoval = true)
public static final TagKey<Item> SAPLINGS = org.betterx.worlds.together.tag.CommonItemTags.SAPLINGS;
/**
* @deprecated Replaced by {@link org.betterx.worlds.together.tag.CommonItemTags#SOUL_GROUND}
**/
@Deprecated(forRemoval = true)
public static final TagKey<Item> SOUL_GROUND = org.betterx.worlds.together.tag.CommonItemTags.SOUL_GROUND;
/**
* @deprecated Replaced by {@link org.betterx.worlds.together.tag.CommonItemTags#WOODEN_BARREL}
**/
@Deprecated(forRemoval = true)
public static final TagKey<Item> WOODEN_BARREL = org.betterx.worlds.together.tag.CommonItemTags.WOODEN_BARREL;
/**
* @deprecated Replaced by {@link org.betterx.worlds.together.tag.CommonItemTags#WOODEN_CHEST}
**/
@Deprecated(forRemoval = true)
public static final TagKey<Item> WOODEN_CHEST = org.betterx.worlds.together.tag.CommonItemTags.WOODEN_CHEST;
/**
* @deprecated Replaced by {@link org.betterx.worlds.together.tag.CommonItemTags#WORKBENCHES}
**/
@Deprecated(forRemoval = true)
public static final TagKey<Item> WORKBENCHES = org.betterx.worlds.together.tag.CommonItemTags.WORKBENCHES;
}

View file

@ -3,9 +3,11 @@ package org.betterx.bclib.api.v2.tag;
import net.minecraft.tags.BlockTags;
import net.minecraft.tags.TagKey;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
/**
* @deprecated Replaced by {@link BlockTags}
*/
@Deprecated(forRemoval = true)
public class NamedBlockTags {
public static final TagKey<Block> ANVIL = BlockTags.ANVIL;
public static final TagKey<Block> BUTTONS = BlockTags.BUTTONS;
@ -16,34 +18,109 @@ public class NamedBlockTags {
public static final TagKey<Block> LEAVES = BlockTags.LEAVES;
public static final TagKey<Block> LOGS = BlockTags.LOGS;
public static final TagKey<Block> LOGS_THAT_BURN = BlockTags.LOGS_THAT_BURN;
/**
* @deprecated replaced by {@link net.minecraft.tags.BlockTags#NYLIUM}
**/
@Deprecated(forRemoval = true)
public static final TagKey<Block> NYLIUM = BlockTags.NYLIUM;
/**
* @deprecated replaced by {@link net.minecraft.tags.BlockTags#PLANKS}
**/
@Deprecated(forRemoval = true)
public static final TagKey<Block> PLANKS = BlockTags.PLANKS;
/**
* @deprecated replaced by {@link net.minecraft.tags.BlockTags#PRESSURE_PLATES}
**/
@Deprecated(forRemoval = true)
public static final TagKey<Block> PRESSURE_PLATES = BlockTags.PRESSURE_PLATES;
/**
* @deprecated replaced by {@link net.minecraft.tags.BlockTags#SAPLINGS}
**/
@Deprecated(forRemoval = true)
public static final TagKey<Block> SAPLINGS = BlockTags.SAPLINGS;
/**
* @deprecated replaced by {@link net.minecraft.tags.BlockTags#SIGNS}
**/
@Deprecated(forRemoval = true)
public static final TagKey<Block> SIGNS = BlockTags.SIGNS;
/**
* @deprecated replaced by {@link net.minecraft.tags.BlockTags#SLABS}
**/
@Deprecated(forRemoval = true)
public static final TagKey<Block> SLABS = BlockTags.SLABS;
/**
* @deprecated replaced by {@link net.minecraft.tags.BlockTags#STAIRS}
**/
@Deprecated(forRemoval = true)
public static final TagKey<Block> STAIRS = BlockTags.STAIRS;
/**
* @deprecated replaced by {@link net.minecraft.tags.BlockTags#STONE_PRESSURE_PLATES}
**/
@Deprecated(forRemoval = true)
public static final TagKey<Block> STONE_PRESSURE_PLATES = BlockTags.STONE_PRESSURE_PLATES;
/**
* @deprecated replaced by {@link net.minecraft.tags.BlockTags#TRAPDOORS}
**/
@Deprecated(forRemoval = true)
public static final TagKey<Block> TRAPDOORS = BlockTags.TRAPDOORS;
/**
* @deprecated replaced by {@link net.minecraft.tags.BlockTags#WALLS}
**/
@Deprecated(forRemoval = true)
public static final TagKey<Block> WALLS = BlockTags.WALLS;
/**
* @deprecated replaced by {@link net.minecraft.tags.BlockTags#WOODEN_BUTTONS}
**/
@Deprecated(forRemoval = true)
public static final TagKey<Block> WOODEN_BUTTONS = BlockTags.WOODEN_BUTTONS;
/**
* @deprecated replaced by {@link net.minecraft.tags.BlockTags#WOODEN_DOORS}
**/
@Deprecated(forRemoval = true)
public static final TagKey<Block> WOODEN_DOORS = BlockTags.WOODEN_DOORS;
/**
* @deprecated replaced by {@link net.minecraft.tags.BlockTags#WOODEN_FENCES}
**/
@Deprecated(forRemoval = true)
public static final TagKey<Block> WOODEN_FENCES = BlockTags.WOODEN_FENCES;
/**
* @deprecated replaced by {@link net.minecraft.tags.BlockTags#WOODEN_PRESSURE_PLATES}
**/
@Deprecated(forRemoval = true)
public static final TagKey<Block> WOODEN_PRESSURE_PLATES = BlockTags.WOODEN_PRESSURE_PLATES;
/**
* @deprecated replaced by {@link net.minecraft.tags.BlockTags#WOODEN_SLABS}
**/
@Deprecated(forRemoval = true)
public static final TagKey<Block> WOODEN_SLABS = BlockTags.WOODEN_SLABS;
/**
* @deprecated replaced by {@link net.minecraft.tags.BlockTags#WOODEN_STAIRS}
**/
@Deprecated(forRemoval = true)
public static final TagKey<Block> WOODEN_STAIRS = BlockTags.WOODEN_STAIRS;
/**
* @deprecated replaced by {@link net.minecraft.tags.BlockTags#WOODEN_TRAPDOORS}
**/
@Deprecated(forRemoval = true)
public static final TagKey<Block> WOODEN_TRAPDOORS = BlockTags.WOODEN_TRAPDOORS;
/**
* @deprecated replaced by {@link net.minecraft.tags.BlockTags#SOUL_FIRE_BASE_BLOCKS}
**/
@Deprecated(forRemoval = true)
public static final TagKey<Block> SOUL_FIRE_BASE_BLOCKS = BlockTags.SOUL_FIRE_BASE_BLOCKS;
/**
* @deprecated replaced by {@link net.minecraft.tags.BlockTags#SOUL_SPEED_BLOCKS}
**/
@Deprecated(forRemoval = true)
public static final TagKey<Block> SOUL_SPEED_BLOCKS = BlockTags.SOUL_SPEED_BLOCKS;
/**
* @deprecated replaced by {@link net.minecraft.tags.BlockTags#BEACON_BASE_BLOCKS}
**/
@Deprecated(forRemoval = true)
public static final TagKey<Block> BEACON_BASE_BLOCKS = BlockTags.BEACON_BASE_BLOCKS;
/**
* @deprecated replaced by {@link net.minecraft.tags.BlockTags#STONE_BRICKS}
**/
@Deprecated(forRemoval = true)
public static final TagKey<Block> STONE_BRICKS = BlockTags.STONE_BRICKS;
static {
TagAPI.BLOCKS.add(BlockTags.NETHER_CARVER_REPLACEABLES, Blocks.RED_SAND, Blocks.MAGMA_BLOCK, Blocks.SCULK);
TagAPI.BLOCKS.addOtherTags(
BlockTags.NETHER_CARVER_REPLACEABLES,
CommonBlockTags.NETHER_STONES,
CommonBlockTags.NETHERRACK
);
}
}

View file

@ -5,6 +5,10 @@ import net.minecraft.tags.TagKey;
import net.minecraft.world.item.Item;
/**
* @deprecated Replaced by {@link ItemTags}
*/
@Deprecated(forRemoval = true)
public class NamedItemTags {
public static final TagKey<Item> BUTTONS = ItemTags.BUTTONS;
public static final TagKey<Item> DOORS = ItemTags.DOORS;

View file

@ -1,16 +1,46 @@
package org.betterx.bclib.api.v2.tag;
import net.minecraft.tags.BlockTags;
import net.minecraft.tags.TagKey;
import net.minecraft.world.level.block.Block;
/**
* @deprecated Replaced by {@link org.betterx.worlds.together.tag.MineableTags}
*/
@Deprecated(forRemoval = true)
public class NamedMineableTags {
public static final TagKey<Block> AXE = BlockTags.MINEABLE_WITH_AXE;
public static final TagKey<Block> HOE = BlockTags.MINEABLE_WITH_HOE;
public static final TagKey<Block> PICKAXE = BlockTags.MINEABLE_WITH_PICKAXE;
public static final TagKey<Block> SHEARS = TagAPI.makeBlockTag("fabric", "mineable/shears");
public static final TagKey<Block> SHOVEL = BlockTags.MINEABLE_WITH_SHOVEL;
public static final TagKey<Block> SWORD = TagAPI.makeBlockTag("fabric", "mineable/sword");
public static final TagKey<Block> HAMMER = TagAPI.makeCommonBlockTag("mineable/hammer");
/**
* @deprecated use {@link org.betterx.worlds.together.tag.MineableTags#AXE} instead
**/
@Deprecated(forRemoval = true)
public static final TagKey<Block> AXE = org.betterx.worlds.together.tag.MineableTags.AXE;
/**
* @deprecated use {@link org.betterx.worlds.together.tag.MineableTags#HOE} instead
**/
@Deprecated(forRemoval = true)
public static final TagKey<Block> HOE = org.betterx.worlds.together.tag.MineableTags.HOE;
/**
* @deprecated use {@link org.betterx.worlds.together.tag.MineableTags#PICKAXE} instead
**/
@Deprecated(forRemoval = true)
public static final TagKey<Block> PICKAXE = org.betterx.worlds.together.tag.MineableTags.PICKAXE;
/**
* @deprecated use {@link org.betterx.worlds.together.tag.MineableTags#SHEARS} instead
**/
@Deprecated(forRemoval = true)
public static final TagKey<Block> SHEARS = org.betterx.worlds.together.tag.MineableTags.SHEARS;
/**
* @deprecated use {@link org.betterx.worlds.together.tag.MineableTags#SHOVEL} instead
**/
@Deprecated(forRemoval = true)
public static final TagKey<Block> SHOVEL = org.betterx.worlds.together.tag.MineableTags.SHOVEL;
/**
* @deprecated use {@link org.betterx.worlds.together.tag.MineableTags#SWORD} instead
**/
@Deprecated(forRemoval = true)
public static final TagKey<Block> SWORD = org.betterx.worlds.together.tag.MineableTags.SWORD;
/**
* @deprecated use {@link org.betterx.worlds.together.tag.MineableTags#HAMMER} instead
**/
@Deprecated(forRemoval = true)
public static final TagKey<Block> HAMMER = org.betterx.worlds.together.tag.MineableTags.HAMMER;
}

View file

@ -1,14 +1,45 @@
package org.betterx.bclib.api.v2.tag;
import org.betterx.worlds.together.tag.ToolTags;
import net.minecraft.tags.TagKey;
import net.minecraft.world.item.Item;
/**
* @deprecated Replaced by {@link ToolTags}
*/
@Deprecated(forRemoval = true)
public class NamedToolTags {
public static final TagKey<Item> FABRIC_AXES = TagAPI.makeItemTag("fabric", "axes");
public static final TagKey<Item> FABRIC_HOES = TagAPI.makeItemTag("fabric", "hoes");
public static final TagKey<Item> FABRIC_PICKAXES = TagAPI.makeItemTag("fabric", "pickaxes");
public static final TagKey<Item> FABRIC_SHEARS = TagAPI.makeItemTag("fabric", "shears");
public static final TagKey<Item> FABRIC_SHOVELS = TagAPI.makeItemTag("fabric", "shovels");
public static final TagKey<Item> FABRIC_SWORDS = TagAPI.makeItemTag("fabric", "swords");
/**
* @deprecated use {@link ToolTags#FABRIC_AXES} instead
**/
@Deprecated(forRemoval = true)
public static final TagKey<Item> FABRIC_AXES = ToolTags.FABRIC_AXES;
/**
* @deprecated use {@link ToolTags#FABRIC_HOES} instead
**/
@Deprecated(forRemoval = true)
public static final TagKey<Item> FABRIC_HOES = ToolTags.FABRIC_HOES;
/**
* @deprecated use {@link ToolTags#FABRIC_PICKAXES} instead
**/
@Deprecated(forRemoval = true)
public static final TagKey<Item> FABRIC_PICKAXES = ToolTags.FABRIC_PICKAXES;
/**
* @deprecated use {@link ToolTags#FABRIC_SHEARS} instead
**/
@Deprecated(forRemoval = true)
public static final TagKey<Item> FABRIC_SHEARS = ToolTags.FABRIC_SHEARS;
/**
* @deprecated use {@link ToolTags#FABRIC_SHOVELS} instead
**/
@Deprecated(forRemoval = true)
public static final TagKey<Item> FABRIC_SHOVELS = ToolTags.FABRIC_SHOVELS;
/**
* @deprecated use {@link ToolTags#FABRIC_SWORDS} instead
**/
@Deprecated(forRemoval = true)
public static final TagKey<Item> FABRIC_SWORDS = ToolTags.FABRIC_SWORDS;
}

View file

@ -1,13 +1,15 @@
package org.betterx.bclib.api.v2.tag;
import org.betterx.bclib.api.v2.levelgen.biomes.BiomeAPI;
import org.betterx.bclib.mixin.common.DiggerItemAccessor;
import org.betterx.worlds.together.mixin.common.DiggerItemAccessor;
import org.betterx.worlds.together.tag.CommonBlockTags;
import org.betterx.worlds.together.tag.TagManager;
import org.betterx.worlds.together.tag.TagRegistry;
import net.minecraft.core.DefaultedRegistry;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.packs.resources.ResourceManager;
import net.minecraft.tags.TagKey;
import net.minecraft.tags.TagLoader;
import net.minecraft.world.item.Item;
@ -24,26 +26,55 @@ import java.util.List;
import java.util.Map;
import java.util.function.Function;
/**
* @deprecated Replaced by {@link TagManager}
*/
@Deprecated(forRemoval = true)
public class TagAPI {
private static final Map<String, TagType<?>> TYPES = Maps.newHashMap();
/**
* @deprecated Replaced by {@link TagManager#BLOCKS}
*/
@Deprecated(forRemoval = true)
public static TagType.RegistryBacked<Block> BLOCKS = registerType(Registry.BLOCK);
/**
* @deprecated Replaced by {@link TagManager#ITEMS}
*/
@Deprecated(forRemoval = true)
public static TagType.RegistryBacked<Item> ITEMS = registerType(Registry.ITEM);
/**
* @deprecated Replaced by {@link TagManager#BIOMES}
*/
@Deprecated(forRemoval = true)
public static TagType.Simple<Biome> BIOMES = registerType(
Registry.BIOME_REGISTRY,
"tags/worldgen/biome",
b -> BiomeAPI.getBiomeID(b)
);
/**
* @deprecated Replaced by {@link TagManager#registerType(DefaultedRegistry)}
*/
@Deprecated(forRemoval = true)
public static <T> TagType.RegistryBacked<T> registerType(DefaultedRegistry<T> registry) {
TagType<T> type = new TagType.RegistryBacked<>(registry);
return (TagType.RegistryBacked<T>) TYPES.computeIfAbsent(type.directory, (dir) -> type);
}
/**
* @deprecated Replaced by {@link TagManager#registerType(Registry, String)}
*/
@Deprecated(forRemoval = true)
public static <T> TagType.Simple<T> registerType(Registry<T> registry, String directory) {
return registerType(registry.key(), directory, (o) -> registry.getKey(o));
}
/**
* @deprecated Replaced by {@link TagManager#registerType(ResourceKey, String, Function)}
*/
@Deprecated(forRemoval = true)
public static <T> TagType.Simple<T> registerType(
ResourceKey<? extends Registry<T>> registry,
String directory,
@ -59,97 +90,92 @@ public class TagAPI {
);
}
/**
* @deprecated Replaced by {@link TagManager#registerType(ResourceKey, String)}
*/
@Deprecated(forRemoval = true)
public static <T> TagType.UnTyped<T> registerType(ResourceKey<? extends Registry<T>> registry, String directory) {
return (TagType.UnTyped<T>) TYPES.computeIfAbsent(directory, (dir) -> new TagType.UnTyped<>(registry, dir));
}
/**
* Get or create {@link Block} {@link TagKey} with mod namespace.
*
* @param modID - {@link String} mod namespace (mod id);
* @param name - {@link String} tag name.
* @return {@link Block} {@link TagKey}.
* @deprecated Replaced by {@link TagRegistry#makeTag(String, String)} on {@link TagManager#BIOMES}
*/
@Deprecated(forRemoval = true)
public static TagKey<Biome> makeBiomeTag(String modID, String name) {
return BIOMES.makeTag(new ResourceLocation(modID, name));
return TagManager.BIOMES.makeTag(new ResourceLocation(modID, name));
}
/**
* @deprecated Replaced by {@link TagRegistry.Biomes#makeStructureTag(String, String)} on {@link TagManager#BIOMES}
*/
@Deprecated(forRemoval = true)
public static TagKey<Biome> makeStructureTag(String modID, String name) {
return TagAPI.makeBiomeTag(modID, "has_structure/" + name);
return TagManager.BIOMES.makeStructureTag(modID, name);
}
/**
* Get or create {@link Block} {@link TagKey} with mod namespace.
*
* @param modID - {@link String} mod namespace (mod id);
* @param name - {@link String} tag name.
* @return {@link Block} {@link TagKey}.
* @deprecated Replaced by {@link TagRegistry#makeTag(String, String)} on {@link TagManager#BLOCKS}
*/
@Deprecated(forRemoval = true)
public static TagKey<Block> makeBlockTag(String modID, String name) {
return BLOCKS.makeTag(new ResourceLocation(modID, name));
return TagManager.BLOCKS.makeTag(new ResourceLocation(modID, name));
}
/**
* Get or create {@link Block} {@link TagKey} with mod namespace.
*
* @param id - {@link String} id for the tag;
* @return {@link Block} {@link TagKey}.
* @deprecated Replaced by {@link TagRegistry#makeTag(ResourceLocation)} on {@link TagManager#BLOCKS}
*/
@Deprecated(forRemoval = true)
public static TagKey<Block> makeBlockTag(ResourceLocation id) {
return BLOCKS.makeTag(id);
return TagManager.BLOCKS.makeTag(id);
}
/**
* Get or create {@link Item} {@link TagKey} with mod namespace.
*
* @param modID - {@link String} mod namespace (mod id);
* @param name - {@link String} tag name.
* @return {@link Item} {@link TagKey}.
* @deprecated Replaced by {@link TagRegistry#makeTag(String, String)} on {@link TagManager#ITEMS}
*/
@Deprecated(forRemoval = true)
public static TagKey<Item> makeItemTag(String modID, String name) {
return ITEMS.makeTag(new ResourceLocation(modID, name));
return TagManager.ITEMS.makeTag(new ResourceLocation(modID, name));
}
/**
* Get or create {@link Item} {@link TagKey} with mod namespace.
*
* @param id - {@link String} id for the tag;
* @return {@link Item} {@link TagKey}.
* @deprecated Replaced by {@link TagRegistry#makeTag(ResourceLocation)} on {@link TagManager#ITEMS}
*/
@Deprecated(forRemoval = true)
public static TagKey<Item> makeItemTag(ResourceLocation id) {
return ITEMS.makeTag(id);
return TagManager.ITEMS.makeTag(id);
}
/**
* Get or create {@link Block} {@link TagKey}.
*
* @param name - {@link String} tag name.
* @return {@link Block} {@link TagKey}.
* @see <a href="https://fabricmc.net/wiki/tutorial:tags">Fabric Wiki (Tags)</a>
* @deprecated Replaced by {@link TagRegistry#makeCommonTag(String)} on {@link TagManager#BLOCKS}
*/
@Deprecated(forRemoval = true)
public static TagKey<Block> makeCommonBlockTag(String name) {
return BLOCKS.makeCommonTag(name);
return TagManager.BLOCKS.makeCommonTag(name);
}
/**
* Get or create {@link Item} {@link TagKey}.
*
* @param name - {@link String} tag name.
* @return {@link Item} {@link TagKey}.
* @see <a href="https://fabricmc.net/wiki/tutorial:tags">Fabric Wiki (Tags)</a>
* @deprecated Replaced by {@link TagRegistry#makeCommonTag(String)} on {@link TagManager#ITEMS}
*/
@Deprecated(forRemoval = true)
public static TagKey<Item> makeCommonItemTag(String name) {
return ITEMS.makeCommonTag(name);
return TagManager.ITEMS.makeCommonTag(name);
}
/**
* @deprecated Replaced by {@link TagRegistry#makeCommonTag(String)} on {@link TagManager#BIOMES}
*/
@Deprecated(forRemoval = true)
public static TagKey<Biome> makeCommonBiomeTag(String name) {
return BIOMES.makeCommonTag(name);
return TagManager.BIOMES.makeCommonTag(name);
}
/**
* Initializes basic tags. Should be called only in BCLib main class.
*/
@Deprecated(forRemoval = true)
public static void init() {
addBlockTag(CommonBlockTags.BOOKSHELVES, Blocks.BOOKSHELF);
addBlockTag(CommonBlockTags.CHEST, Blocks.CHEST);
@ -159,98 +185,87 @@ public class TagAPI {
}
/**
* Adds multiple Tags to one Biome.
* Please use {@link TagManager}.BIOMES.add(biome, tagIDs) instead
*
* @param tagIDs array of {@link TagKey<Biome>} tag IDs.
* @param biome The {@link Biome} to add tag.
* @deprecated
*/
@Deprecated(forRemoval = true)
@SafeVarargs
public static void addBiomeTags(Biome biome, TagKey<Biome>... tagIDs) {
BIOMES.add(biome, tagIDs);
TagManager.BIOMES.add(biome, tagIDs);
}
/**
* Adds one Tag to multiple Biomes.
* Please use {@link TagManager}.BIOMES.add(tagID, biomes) instead
*
* @param tagID {@link TagKey<Biome>} tag ID.
* @param biomes array of {@link Biome} to add into tag.
* @deprecated
*/
@Deprecated(forRemoval = true)
public static void addBiomeTag(TagKey<Biome> tagID, Biome... biomes) {
BIOMES.add(tagID, biomes);
TagManager.BIOMES.add(tagID, biomes);
}
/**
* Adds multiple Tags to one Block.
* Please use {@link TagManager}.BLOCKS.add(block, tagIDs) instead
*
* @param tagIDs array of {@link TagKey<Block>} tag IDs.
* @param block The {@link Block} to add tag.
* @deprecated
*/
@Deprecated(forRemoval = true)
@SafeVarargs
public static void addBlockTags(Block block, TagKey<Block>... tagIDs) {
BLOCKS.add(block, tagIDs);
TagManager.BLOCKS.add(block, tagIDs);
}
/**
* Adds one Tag to multiple Blocks.
* Please use {@link TagManager}.BIOMES.add(tagID, blocks) instead
*
* @param tagID {@link TagKey<Block>} tag ID.
* @param blocks array of {@link Block} to add into tag.
* @deprecated
*/
@Deprecated(forRemoval = true)
public static void addBlockTag(TagKey<Block> tagID, Block... blocks) {
BLOCKS.add(tagID, blocks);
TagManager.BLOCKS.add(tagID, blocks);
}
/**
* Adds multiple Tags to one Item.
* Please use {@link TagManager}.ITEMS.add(item, tagIDs) instead
*
* @param tagIDs array of {@link TagKey<Item>} tag IDs.
* @param item The {@link Item} to add tag.
* @deprecated
*/
@Deprecated(forRemoval = true)
@SafeVarargs
public static void addItemTags(ItemLike item, TagKey<Item>... tagIDs) {
ITEMS.add(item.asItem(), tagIDs);
TagManager.ITEMS.add(item.asItem(), tagIDs);
}
/**
* Adds one Tag to multiple Items.
*
* @param tagID {@link TagKey<Item>} tag ID.
* @param items array of {@link ItemLike} to add into tag.
* @deprecated
*/
@Deprecated(forRemoval = true)
public static void addItemTag(TagKey<Item> tagID, ItemLike... items) {
for (ItemLike i : items) {
ITEMS.add(i.asItem(), tagID);
TagManager.ITEMS.add(i.asItem(), tagID);
}
}
/**
* Adds one Tag to multiple Items.
* Please use {@link TagManager}.ITEMS.add(tagID, items) instead
*
* @param tagID {@link TagKey<Item>} tag ID.
* @param items array of {@link ItemLike} to add into tag.
* @deprecated
*/
@Deprecated(forRemoval = true)
public static void addItemTag(TagKey<Item> tagID, Item... items) {
ITEMS.add(tagID, items);
TagManager.ITEMS.add(tagID, items);
}
/**
* Automatically called in {@link net.minecraft.tags.TagLoader#loadAndBuild(ResourceManager)}.
* <p>
* In most cases there is no need to call this Method manually.
*
* @param directory The name of the Tag-directory. Should be either <i>"tags/blocks"</i> or
* <i>"tags/items"</i>.
* @param tagsMap The map that will hold the registered Tags
* @return The {@code tagsMap} Parameter.
*/
@Deprecated(forRemoval = true)
public static <T> Map<ResourceLocation, List<TagLoader.EntryWithSource>> apply(
String directory,
Map<ResourceLocation, List<TagLoader.EntryWithSource>> tagsMap
) {
TagType<?> type = TYPES.get(directory);
if (type != null) {
type.apply(tagsMap);
@ -259,6 +274,13 @@ public class TagAPI {
}
/**
* @param stack
* @param tag
* @return
* @deprecated call {@link TagManager#isToolWithMineableTag(ItemStack, TagKey)} instead
*/
@Deprecated(forRemoval = true)
public static boolean isToolWithMineableTag(ItemStack stack, TagKey<Block> tag) {
if (stack.getItem() instanceof DiggerItemAccessor dig) {
return dig.bclib_getBlockTag().equals(tag);

View file

@ -2,6 +2,7 @@ package org.betterx.bclib.api.v2.tag;
import org.betterx.bclib.BCLib;
import org.betterx.bclib.api.v2.levelgen.biomes.InternalBiomeAPI;
import org.betterx.worlds.together.tag.TagRegistry;
import net.minecraft.core.DefaultedRegistry;
import net.minecraft.core.Registry;
@ -24,9 +25,17 @@ import java.util.Set;
import java.util.function.BiConsumer;
import java.util.function.Function;
/**
* @deprecated Replaced by {@link TagRegistry}
*/
@Deprecated(forRemoval = true)
public class TagType<T> {
boolean isFrozen = false;
/**
* @deprecated Replaced by {@link TagRegistry.RegistryBacked}
*/
@Deprecated(forRemoval = true)
public static class RegistryBacked<T> extends Simple<T> {
private final DefaultedRegistry<T> registry;
@ -56,6 +65,10 @@ public class TagType<T> {
}
}
/**
* @deprecated Replaced by {@link TagRegistry.Simple}
*/
@Deprecated(forRemoval = true)
public static class Simple<T> extends TagType<T> {
Simple(
ResourceKey<? extends Registry<T>> registry,
@ -84,6 +97,10 @@ public class TagType<T> {
}
}
/**
* @deprecated Replaced by {@link TagRegistry.UnTyped}
*/
@Deprecated(forRemoval = true)
public static class UnTyped<T> extends TagType<T> {
UnTyped(
ResourceKey<? extends Registry<T>> registry,

View file

@ -1,6 +1,6 @@
package org.betterx.bclib.api.v3.levelgen.features;
import org.betterx.bclib.api.v2.tag.CommonBlockTags;
import org.betterx.worlds.together.tag.CommonBlockTags;
import net.minecraft.tags.BlockTags;
import net.minecraft.world.level.levelgen.blockpredicates.BlockPredicate;

View file

@ -2,7 +2,7 @@ package org.betterx.bclib.api.v3.levelgen.features;
import org.betterx.bclib.api.v2.levelgen.features.config.PlaceFacingBlockConfig;
import org.betterx.bclib.api.v2.levelgen.features.placement.*;
import org.betterx.bclib.api.v2.tag.CommonBlockTags;
import org.betterx.worlds.together.tag.CommonBlockTags;
import net.minecraft.core.Direction;
import net.minecraft.core.Holder;

View file

@ -1,7 +1,5 @@
package org.betterx.bclib.blocks;
import org.betterx.bclib.api.v2.tag.NamedBlockTags;
import org.betterx.bclib.api.v2.tag.NamedItemTags;
import org.betterx.bclib.client.models.BasePatterns;
import org.betterx.bclib.client.models.ModelsHelper;
import org.betterx.bclib.client.models.PatternsHelper;
@ -15,6 +13,8 @@ import net.minecraft.client.resources.model.BlockModelRotation;
import net.minecraft.client.resources.model.UnbakedModel;
import net.minecraft.core.Direction;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.BlockTags;
import net.minecraft.tags.ItemTags;
import net.minecraft.tags.TagKey;
import net.minecraft.util.StringRepresentable;
import net.minecraft.world.item.Item;
@ -153,8 +153,8 @@ public class BaseDoorBlock extends DoorBlock implements RenderLayerProvider, Blo
@Override
public void addTags(List<TagKey<Block>> blockTags, List<TagKey<Item>> itemTags) {
blockTags.add(NamedBlockTags.DOORS);
itemTags.add(NamedItemTags.DOORS);
blockTags.add(BlockTags.DOORS);
itemTags.add(ItemTags.DOORS);
}
protected enum DoorType implements StringRepresentable {

View file

@ -1,7 +1,5 @@
package org.betterx.bclib.blocks;
import org.betterx.bclib.api.v2.tag.NamedBlockTags;
import org.betterx.bclib.api.v2.tag.NamedItemTags;
import org.betterx.bclib.client.render.BCLRenderLayer;
import org.betterx.bclib.interfaces.BlockModelProvider;
import org.betterx.bclib.interfaces.RenderLayerProvider;
@ -13,6 +11,8 @@ import org.betterx.bclib.util.MHelper;
import net.minecraft.client.renderer.block.model.BlockModel;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.BlockTags;
import net.minecraft.tags.ItemTags;
import net.minecraft.tags.TagKey;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
@ -117,7 +117,7 @@ public class BaseLeavesBlock extends LeavesBlock implements BlockModelProvider,
@Override
public void addTags(List<TagKey<Block>> blockTags, List<TagKey<Item>> itemTags) {
blockTags.add(NamedBlockTags.LEAVES);
itemTags.add(NamedItemTags.LEAVES);
blockTags.add(BlockTags.LEAVES);
itemTags.add(ItemTags.LEAVES);
}
}

View file

@ -1,7 +1,7 @@
package org.betterx.bclib.blocks;
import org.betterx.bclib.api.v2.tag.NamedMineableTags;
import org.betterx.bclib.api.v2.tag.TagAPI;
import org.betterx.worlds.together.tag.MineableTags;
import org.betterx.worlds.together.tag.TagManager;
import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerPlayer;
@ -37,7 +37,7 @@ public class BaseStripableLogBlock extends BaseRotatedPillarBlock {
InteractionHand hand,
BlockHitResult hit
) {
if (TagAPI.isToolWithMineableTag(player.getMainHandItem(), NamedMineableTags.AXE)) {
if (TagManager.isToolWithMineableTag(player.getMainHandItem(), MineableTags.AXE)) {
world.playSound(player, pos, SoundEvents.AXE_STRIP, SoundSource.BLOCKS, 1.0F, 1.0F);
if (!world.isClientSide) {
world.setBlock(

View file

@ -1,11 +1,11 @@
package org.betterx.bclib.blocks;
import org.betterx.bclib.api.v2.tag.NamedMineableTags;
import org.betterx.bclib.api.v2.tag.TagAPI;
import org.betterx.bclib.client.models.BasePatterns;
import org.betterx.bclib.client.models.ModelsHelper;
import org.betterx.bclib.client.models.PatternsHelper;
import org.betterx.bclib.client.sound.BlockSounds;
import org.betterx.worlds.together.tag.MineableTags;
import org.betterx.worlds.together.tag.TagManager;
import net.minecraft.client.renderer.block.model.BlockModel;
import net.minecraft.client.resources.model.UnbakedModel;
@ -80,7 +80,7 @@ public class BaseTerrainBlock extends BaseBlock {
InteractionHand hand,
BlockHitResult hit
) {
if (pathBlock != null && TagAPI.isToolWithMineableTag(player.getMainHandItem(), NamedMineableTags.SHOVEL)) {
if (pathBlock != null && TagManager.isToolWithMineableTag(player.getMainHandItem(), MineableTags.SHOVEL)) {
world.playSound(player, pos, SoundEvents.SHOVEL_FLATTEN, SoundSource.BLOCKS, 1.0F, 1.0F);
if (!world.isClientSide) {
world.setBlockAndUpdate(pos, pathBlock.defaultBlockState());

View file

@ -1,13 +1,13 @@
package org.betterx.bclib.blocks;
import org.betterx.bclib.api.v2.tag.NamedBlockTags;
import org.betterx.bclib.api.v2.tag.NamedItemTags;
import org.betterx.bclib.client.render.BCLRenderLayer;
import org.betterx.bclib.interfaces.RenderLayerProvider;
import org.betterx.bclib.interfaces.TagProvider;
import org.betterx.bclib.interfaces.tools.AddMineableHoe;
import org.betterx.bclib.interfaces.tools.AddMineableShears;
import net.minecraft.tags.BlockTags;
import net.minecraft.tags.ItemTags;
import net.minecraft.tags.TagKey;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.Block;
@ -61,7 +61,7 @@ public class SimpleLeavesBlock extends BaseBlockNotFull implements RenderLayerPr
@Override
public void addTags(List<TagKey<Block>> blockTags, List<TagKey<Item>> itemTags) {
blockTags.add(NamedBlockTags.LEAVES);
itemTags.add(NamedItemTags.LEAVES);
blockTags.add(BlockTags.LEAVES);
itemTags.add(ItemTags.LEAVES);
}
}

View file

@ -1,7 +1,7 @@
package org.betterx.bclib.blocks;
import org.betterx.bclib.api.v2.tag.NamedMineableTags;
import org.betterx.bclib.api.v2.tag.TagAPI;
import org.betterx.worlds.together.tag.MineableTags;
import org.betterx.worlds.together.tag.TagManager;
import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerPlayer;
@ -36,7 +36,7 @@ public class StripableBarkBlock extends BaseBarkBlock {
InteractionHand hand,
BlockHitResult hit
) {
if (TagAPI.isToolWithMineableTag(player.getMainHandItem(), NamedMineableTags.AXE)) {
if (TagManager.isToolWithMineableTag(player.getMainHandItem(), MineableTags.AXE)) {
world.playSound(player, pos, SoundEvents.AXE_STRIP, SoundSource.BLOCKS, 1.0F, 1.0F);
if (!world.isClientSide) {
world.setBlock(

View file

@ -1,7 +1,7 @@
package org.betterx.bclib.commands;
import org.betterx.bclib.api.v2.tag.CommonBlockTags;
import org.betterx.bclib.util.BlocksHelper;
import org.betterx.worlds.together.tag.CommonBlockTags;
import com.mojang.brigadier.Command;
import com.mojang.brigadier.CommandDispatcher;

View file

@ -1,12 +1,12 @@
package org.betterx.bclib.complexmaterials;
import org.betterx.bclib.api.v2.tag.TagAPI;
import org.betterx.bclib.complexmaterials.entry.BlockEntry;
import org.betterx.bclib.complexmaterials.entry.ItemEntry;
import org.betterx.bclib.complexmaterials.entry.RecipeEntry;
import org.betterx.bclib.config.PathConfig;
import org.betterx.bclib.registry.BlockRegistry;
import org.betterx.bclib.registry.ItemRegistry;
import org.betterx.worlds.together.tag.TagManager;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.TagKey;
@ -112,7 +112,7 @@ public abstract class ComplexMaterial {
}
/**
* Adds custom block tag for this {@link ComplexMaterial}, tag can be created with {@link TagAPI} or you can use one of already created tags.
* Adds custom block tag for this {@link ComplexMaterial}, tag can be created with {@link TagManager} or you can use one of already created tags.
*
* @param tag {@link TagKey} for {@link Block}
*/
@ -122,7 +122,7 @@ public abstract class ComplexMaterial {
}
/**
* Adds custom item tag for this {@link ComplexMaterial}, tag can be created with {@link TagAPI} or you can use one of already created tags.
* Adds custom item tag for this {@link ComplexMaterial}, tag can be created with {@link TagManager} or you can use one of already created tags.
*
* @param tag {@link TagKey} for {@link Item}
*/

View file

@ -1,13 +1,17 @@
package org.betterx.bclib.complexmaterials;
import org.betterx.bclib.BCLib;
import org.betterx.bclib.api.v2.tag.*;
import org.betterx.bclib.blocks.*;
import org.betterx.bclib.complexmaterials.entry.BlockEntry;
import org.betterx.bclib.complexmaterials.entry.RecipeEntry;
import org.betterx.bclib.recipes.GridRecipe;
import org.betterx.worlds.together.tag.CommonBlockTags;
import org.betterx.worlds.together.tag.CommonItemTags;
import org.betterx.worlds.together.tag.TagManager;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.BlockTags;
import net.minecraft.tags.ItemTags;
import net.minecraft.tags.TagKey;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.Items;
@ -73,8 +77,8 @@ public class WoodenComplexMaterial extends ComplexMaterial {
@Override
protected void initTags() {
addBlockTag(TagAPI.makeBlockTag(getModID(), getBaseName() + "_logs"));
addItemTag(TagAPI.makeItemTag(getModID(), getBaseName() + "_logs"));
addBlockTag(TagManager.BLOCKS.makeTag(getModID(), getBaseName() + "_logs"));
addItemTag(TagManager.ITEMS.makeTag(getModID(), getBaseName() + "_logs"));
}
@Override
@ -90,13 +94,13 @@ public class WoodenComplexMaterial extends ComplexMaterial {
addBlockEntry(
new BlockEntry(BLOCK_STRIPPED_LOG, (complexMaterial, settings) -> new BaseRotatedPillarBlock(settings))
.setBlockTags(NamedBlockTags.LOGS, NamedBlockTags.LOGS_THAT_BURN, tagBlockLog)
.setItemTags(NamedItemTags.LOGS, NamedItemTags.LOGS_THAT_BURN, tagItemLog)
.setBlockTags(BlockTags.LOGS, BlockTags.LOGS_THAT_BURN, tagBlockLog)
.setItemTags(ItemTags.LOGS, ItemTags.LOGS_THAT_BURN, tagItemLog)
);
addBlockEntry(
new BlockEntry(BLOCK_STRIPPED_BARK, (complexMaterial, settings) -> new BaseBarkBlock(settings))
.setBlockTags(NamedBlockTags.LOGS, NamedBlockTags.LOGS_THAT_BURN, tagBlockLog)
.setItemTags(NamedItemTags.LOGS, NamedItemTags.LOGS_THAT_BURN, tagItemLog)
.setBlockTags(BlockTags.LOGS, BlockTags.LOGS_THAT_BURN, tagBlockLog)
.setItemTags(ItemTags.LOGS, ItemTags.LOGS_THAT_BURN, tagItemLog)
);
addBlockEntry(
@ -107,8 +111,8 @@ public class WoodenComplexMaterial extends ComplexMaterial {
getBlock(BLOCK_STRIPPED_LOG)
)
)
.setBlockTags(NamedBlockTags.LOGS, NamedBlockTags.LOGS_THAT_BURN, tagBlockLog)
.setItemTags(NamedItemTags.LOGS, NamedItemTags.LOGS_THAT_BURN, tagItemLog)
.setBlockTags(BlockTags.LOGS, BlockTags.LOGS_THAT_BURN, tagBlockLog)
.setItemTags(ItemTags.LOGS, ItemTags.LOGS_THAT_BURN, tagItemLog)
);
addBlockEntry(
new BlockEntry(
@ -118,80 +122,80 @@ public class WoodenComplexMaterial extends ComplexMaterial {
getBlock(BLOCK_STRIPPED_BARK)
)
)
.setBlockTags(NamedBlockTags.LOGS, NamedBlockTags.LOGS_THAT_BURN, tagBlockLog)
.setItemTags(NamedItemTags.LOGS, NamedItemTags.LOGS_THAT_BURN, tagItemLog)
.setBlockTags(BlockTags.LOGS, BlockTags.LOGS_THAT_BURN, tagBlockLog)
.setItemTags(ItemTags.LOGS, ItemTags.LOGS_THAT_BURN, tagItemLog)
);
addBlockEntry(new BlockEntry(BLOCK_PLANKS, (complexMaterial, settings) -> new BaseBlock(settings))
.setBlockTags(NamedBlockTags.PLANKS)
.setItemTags(NamedItemTags.PLANKS));
.setBlockTags(BlockTags.PLANKS)
.setItemTags(ItemTags.PLANKS));
addBlockEntry(new BlockEntry(
BLOCK_STAIRS,
(complexMaterial, settings) -> new BaseStairsBlock(getBlock(BLOCK_PLANKS), false)
)
.setBlockTags(NamedBlockTags.WOODEN_STAIRS, NamedBlockTags.STAIRS)
.setItemTags(NamedItemTags.WOODEN_STAIRS, NamedItemTags.STAIRS));
.setBlockTags(BlockTags.WOODEN_STAIRS, BlockTags.STAIRS)
.setItemTags(ItemTags.WOODEN_STAIRS, ItemTags.STAIRS));
addBlockEntry(new BlockEntry(
BLOCK_SLAB,
(complexMaterial, settings) -> new BaseSlabBlock(getBlock(BLOCK_PLANKS), false)
)
.setBlockTags(NamedBlockTags.WOODEN_SLABS, NamedBlockTags.SLABS)
.setItemTags(NamedItemTags.WOODEN_SLABS, NamedItemTags.SLABS));
.setBlockTags(BlockTags.WOODEN_SLABS, BlockTags.SLABS)
.setItemTags(ItemTags.WOODEN_SLABS, ItemTags.SLABS));
addBlockEntry(new BlockEntry(
BLOCK_FENCE,
(complexMaterial, settings) -> new BaseFenceBlock(getBlock(BLOCK_PLANKS))
)
.setBlockTags(NamedBlockTags.FENCES, NamedBlockTags.WOODEN_FENCES)
.setItemTags(NamedItemTags.FENCES, NamedItemTags.WOODEN_FENCES));
.setBlockTags(BlockTags.FENCES, BlockTags.WOODEN_FENCES)
.setItemTags(ItemTags.FENCES, ItemTags.WOODEN_FENCES));
addBlockEntry(new BlockEntry(
BLOCK_GATE,
(complexMaterial, settings) -> new BaseGateBlock(getBlock(BLOCK_PLANKS))
)
.setBlockTags(NamedBlockTags.FENCE_GATES));
.setBlockTags(BlockTags.FENCE_GATES));
addBlockEntry(new BlockEntry(
BLOCK_BUTTON,
(complexMaterial, settings) -> new BaseWoodenButtonBlock(getBlock(BLOCK_PLANKS))
)
.setBlockTags(NamedBlockTags.BUTTONS, NamedBlockTags.WOODEN_BUTTONS)
.setItemTags(NamedItemTags.BUTTONS, NamedItemTags.WOODEN_BUTTONS));
.setBlockTags(BlockTags.BUTTONS, BlockTags.WOODEN_BUTTONS)
.setItemTags(ItemTags.BUTTONS, ItemTags.WOODEN_BUTTONS));
addBlockEntry(new BlockEntry(
BLOCK_PRESSURE_PLATE,
(complexMaterial, settings) -> new WoodenPressurePlateBlock(getBlock(BLOCK_PLANKS))
)
.setBlockTags(NamedBlockTags.PRESSURE_PLATES, NamedBlockTags.WOODEN_PRESSURE_PLATES)
.setItemTags(NamedItemTags.WOODEN_PRESSURE_PLATES));
.setBlockTags(BlockTags.PRESSURE_PLATES, BlockTags.WOODEN_PRESSURE_PLATES)
.setItemTags(ItemTags.WOODEN_PRESSURE_PLATES));
addBlockEntry(new BlockEntry(
BLOCK_TRAPDOOR,
(complexMaterial, settings) -> new BaseTrapdoorBlock(getBlock(BLOCK_PLANKS))
)
.setBlockTags(NamedBlockTags.TRAPDOORS, NamedBlockTags.WOODEN_TRAPDOORS)
.setItemTags(NamedItemTags.TRAPDOORS, NamedItemTags.WOODEN_TRAPDOORS));
.setBlockTags(BlockTags.TRAPDOORS, BlockTags.WOODEN_TRAPDOORS)
.setItemTags(ItemTags.TRAPDOORS, ItemTags.WOODEN_TRAPDOORS));
addBlockEntry(new BlockEntry(
BLOCK_DOOR,
(complexMaterial, settings) -> new BaseDoorBlock(getBlock(BLOCK_PLANKS))
)
.setBlockTags(NamedBlockTags.DOORS, NamedBlockTags.WOODEN_DOORS)
.setItemTags(NamedItemTags.DOORS, NamedItemTags.WOODEN_DOORS));
.setBlockTags(BlockTags.DOORS, BlockTags.WOODEN_DOORS)
.setItemTags(ItemTags.DOORS, ItemTags.WOODEN_DOORS));
addBlockEntry(new BlockEntry(
BLOCK_LADDER,
(complexMaterial, settings) -> new BaseLadderBlock(getBlock(BLOCK_PLANKS))
)
.setBlockTags(NamedBlockTags.CLIMBABLE));
.setBlockTags(BlockTags.CLIMBABLE));
addBlockEntry(new BlockEntry(
BLOCK_SIGN,
(complexMaterial, settings) -> new BaseSignBlock(getBlock(BLOCK_PLANKS))
)
.setBlockTags(NamedBlockTags.SIGNS)
.setItemTags(NamedItemTags.SIGNS));
.setBlockTags(BlockTags.SIGNS)
.setItemTags(ItemTags.SIGNS));
}
final protected void initStorage(FabricBlockSettings blockSettings, FabricItemSettings itemSettings) {

View file

@ -1,8 +1,8 @@
package org.betterx.bclib.complexmaterials.entry;
import org.betterx.bclib.api.v2.tag.TagAPI;
import org.betterx.bclib.complexmaterials.ComplexMaterial;
import org.betterx.bclib.registry.BlockRegistry;
import org.betterx.worlds.together.tag.TagManager;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.TagKey;
@ -50,13 +50,13 @@ public class BlockEntry extends ComplexMaterialEntry {
if (hasItem) {
registry.register(location, block);
if (itemTags != null) {
TagAPI.addItemTags(block, itemTags);
TagManager.ITEMS.add(block.asItem(), itemTags);
}
} else {
registry.registerBlockOnly(location, block);
}
if (blockTags != null) {
TagAPI.addBlockTags(block, blockTags);
TagManager.BLOCKS.add(block, blockTags);
}
return block;
}

View file

@ -1,8 +1,8 @@
package org.betterx.bclib.complexmaterials.entry;
import org.betterx.bclib.api.v2.tag.TagAPI;
import org.betterx.bclib.complexmaterials.ComplexMaterial;
import org.betterx.bclib.registry.ItemRegistry;
import org.betterx.worlds.together.tag.TagManager;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.TagKey;
@ -32,7 +32,7 @@ public class ItemEntry extends ComplexMaterialEntry {
Item item = initFunction.apply(material, itemSettings);
registry.register(location, item);
if (itemTags != null) {
TagAPI.addItemTags(item, itemTags);
TagManager.ITEMS.add(item, itemTags);
}
return item;
}

View file

@ -2,7 +2,7 @@ package org.betterx.bclib.integration;
import org.betterx.bclib.BCLib;
import org.betterx.bclib.api.v2.levelgen.features.BCLFeature;
import org.betterx.bclib.api.v2.tag.TagAPI;
import org.betterx.worlds.together.tag.TagManager;
import net.minecraft.core.Holder;
import net.minecraft.core.Registry;
@ -211,11 +211,11 @@ public abstract class ModIntegration {
public TagKey<Item> getItemTag(String name) {
ResourceLocation id = getID(name);
return TagAPI.makeItemTag(id);
return TagManager.ITEMS.makeTag(id);
}
public TagKey<Block> getBlockTag(String name) {
ResourceLocation id = getID(name);
return TagAPI.makeBlockTag(id);
return TagManager.BLOCKS.makeTag(id);
}
}

View file

@ -1,8 +1,8 @@
package org.betterx.bclib.items.tool;
import org.betterx.bclib.api.v2.tag.CommonItemTags;
import org.betterx.bclib.api.v2.tag.TagAPI;
import org.betterx.worlds.together.tag.CommonItemTags;
import org.betterx.worlds.together.tag.TagManager;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
@ -17,7 +17,7 @@ public class BaseShearsItem extends ShearsItem {
}
public static boolean isShear(ItemStack tool) {
return tool.is(Items.SHEARS) | tool.is(CommonItemTags.SHEARS) || TagAPI.isToolWithMineableTag(
return tool.is(Items.SHEARS) | tool.is(CommonItemTags.SHEARS) || TagManager.isToolWithMineableTag(
tool,
FabricMineableTags.SHEARS_MINEABLE
);

View file

@ -1,6 +1,6 @@
package org.betterx.bclib.mixin.common;
import org.betterx.bclib.api.v2.tag.CommonBlockTags;
import org.betterx.worlds.together.tag.CommonBlockTags;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.inventory.ContainerLevelAccess;

View file

@ -1,7 +1,7 @@
package org.betterx.bclib.mixin.common;
import org.betterx.bclib.api.v2.tag.CommonBlockTags;
import org.betterx.bclib.util.MethodReplace;
import org.betterx.worlds.together.tag.CommonBlockTags;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.Level;

View file

@ -1,6 +1,6 @@
package org.betterx.bclib.mixin.common;
import org.betterx.bclib.api.v2.tag.CommonBlockTags;
import org.betterx.worlds.together.tag.CommonBlockTags;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;

View file

@ -1,6 +1,6 @@
package org.betterx.bclib.mixin.common;
import org.betterx.bclib.api.v2.tag.CommonBlockTags;
import org.betterx.worlds.together.tag.CommonBlockTags;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.BlockGetter;

View file

@ -1,6 +1,6 @@
package org.betterx.bclib.mixin.common.shears;
import org.betterx.bclib.api.v2.tag.CommonItemTags;
import org.betterx.worlds.together.tag.CommonItemTags;
import net.minecraft.advancements.critereon.ItemPredicate;
import net.minecraft.world.item.Item;

View file

@ -1,6 +1,6 @@
package org.betterx.bclib.presets;
import org.betterx.bclib.api.v2.tag.TagType;
import org.betterx.worlds.together.tag.TagRegistry;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
@ -15,7 +15,7 @@ public class FlatLevelPresets {
* @deprecated Use {@link org.betterx.worlds.together.flatLevel.FlatLevelPresets#FLAT_LEVEL_PRESETS} instead
*/
@Deprecated(forRemoval = true)
public static TagType.Simple<FlatLevelGeneratorPreset> FLAT_LEVEL_PRESETS = org.betterx.worlds.together.flatLevel.FlatLevelPresets.FLAT_LEVEL_PRESETS;
public static TagRegistry.Simple<FlatLevelGeneratorPreset> FLAT_LEVEL_PRESETS = org.betterx.worlds.together.flatLevel.FlatLevelPresets.FLAT_LEVEL_PRESETS;
/**

View file

@ -1,11 +1,11 @@
package org.betterx.bclib.recipes;
import org.betterx.bclib.BCLib;
import org.betterx.bclib.api.v2.tag.CommonItemTags;
import org.betterx.bclib.config.PathConfig;
import org.betterx.bclib.interfaces.UnknownReceipBookCategory;
import org.betterx.bclib.util.ItemUtil;
import org.betterx.bclib.util.RecipeHelper;
import org.betterx.worlds.together.tag.CommonItemTags;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import net.minecraft.core.NonNullList;

View file

@ -1,8 +1,8 @@
package org.betterx.bclib.recipes;
import org.betterx.bclib.BCLib;
import org.betterx.bclib.api.v2.tag.CommonItemTags;
import org.betterx.bclib.config.Configs;
import org.betterx.worlds.together.tag.CommonItemTags;
import net.minecraft.tags.ItemTags;
import net.minecraft.world.item.Items;

View file

@ -1,14 +1,19 @@
package org.betterx.bclib.registry;
import org.betterx.bclib.api.v2.tag.*;
import org.betterx.bclib.blocks.BaseLeavesBlock;
import org.betterx.bclib.blocks.BaseOreBlock;
import org.betterx.bclib.blocks.FeatureSaplingBlock;
import org.betterx.bclib.config.PathConfig;
import org.betterx.bclib.interfaces.CustomItemProvider;
import org.betterx.worlds.together.tag.CommonBlockTags;
import org.betterx.worlds.together.tag.CommonItemTags;
import org.betterx.worlds.together.tag.MineableTags;
import org.betterx.worlds.together.tag.TagManager;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.BlockTags;
import net.minecraft.tags.ItemTags;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.Item;
@ -45,22 +50,22 @@ public class BlockRegistry extends BaseRegistry<Block> {
getModBlocks(id.getNamespace()).add(block);
if (block instanceof BaseLeavesBlock) {
TagAPI.addBlockTags(
TagManager.BLOCKS.add(
block,
NamedBlockTags.LEAVES,
BlockTags.LEAVES,
CommonBlockTags.LEAVES,
NamedMineableTags.HOE,
NamedMineableTags.SHEARS
MineableTags.HOE,
MineableTags.SHEARS
);
if (item != null) {
TagAPI.addItemTags(item, CommonItemTags.LEAVES, NamedItemTags.LEAVES);
TagManager.ITEMS.add(item, CommonItemTags.LEAVES, ItemTags.LEAVES);
}
} else if (block instanceof BaseOreBlock) {
TagAPI.addBlockTags(block, NamedMineableTags.PICKAXE);
TagManager.BLOCKS.add(block, MineableTags.PICKAXE);
} else if (block instanceof FeatureSaplingBlock) {
TagAPI.addBlockTags(block, CommonBlockTags.SAPLINGS, NamedBlockTags.SAPLINGS);
TagManager.BLOCKS.add(block, CommonBlockTags.SAPLINGS, BlockTags.SAPLINGS);
if (item != null) {
TagAPI.addItemTags(item, CommonItemTags.SAPLINGS, NamedItemTags.SAPLINGS);
TagManager.ITEMS.add(item, CommonItemTags.SAPLINGS, ItemTags.SAPLINGS);
}
}

View file

@ -1,8 +1,5 @@
package org.betterx.bclib.registry;
import org.betterx.bclib.api.v2.tag.CommonItemTags;
import org.betterx.bclib.api.v2.tag.NamedToolTags;
import org.betterx.bclib.api.v2.tag.TagAPI;
import org.betterx.bclib.config.PathConfig;
import org.betterx.bclib.items.BaseDiscItem;
import org.betterx.bclib.items.BaseDrinkItem;
@ -12,6 +9,9 @@ import org.betterx.bclib.items.tool.BaseAxeItem;
import org.betterx.bclib.items.tool.BaseHoeItem;
import org.betterx.bclib.items.tool.BasePickaxeItem;
import org.betterx.bclib.items.tool.BaseShearsItem;
import org.betterx.worlds.together.tag.CommonItemTags;
import org.betterx.worlds.together.tag.TagManager;
import org.betterx.worlds.together.tag.ToolTags;
import net.minecraft.core.BlockSource;
import net.minecraft.core.Direction;
@ -66,17 +66,17 @@ public class ItemRegistry extends BaseRegistry<Item> {
registerItem(itemId, item);
if (item instanceof ShovelItem) {
TagAPI.addItemTag(NamedToolTags.FABRIC_SHOVELS, item);
TagManager.ITEMS.add(ToolTags.FABRIC_SHOVELS, item);
} else if (item instanceof SwordItem) {
TagAPI.addItemTag(NamedToolTags.FABRIC_SWORDS, item);
TagManager.ITEMS.add(ToolTags.FABRIC_SWORDS, item);
} else if (item instanceof BasePickaxeItem) {
TagAPI.addItemTag(NamedToolTags.FABRIC_PICKAXES, item);
TagManager.ITEMS.add(ToolTags.FABRIC_PICKAXES, item);
} else if (item instanceof BaseAxeItem) {
TagAPI.addItemTag(NamedToolTags.FABRIC_AXES, item);
TagManager.ITEMS.add(ToolTags.FABRIC_AXES, item);
} else if (item instanceof BaseHoeItem) {
TagAPI.addItemTag(NamedToolTags.FABRIC_HOES, item);
TagManager.ITEMS.add(ToolTags.FABRIC_HOES, item);
} else if (item instanceof BaseShearsItem) {
TagAPI.addItemTags(item, NamedToolTags.FABRIC_SHEARS, CommonItemTags.SHEARS);
TagManager.ITEMS.add(item, ToolTags.FABRIC_SHEARS, CommonItemTags.SHEARS);
DispenserBlock.registerBehavior(item.asItem(), new ShearsDispenseItemBehavior());
}

View file

@ -1,6 +1,6 @@
package org.betterx.bclib.util;
import org.betterx.bclib.api.v2.tag.CommonBlockTags;
import org.betterx.worlds.together.tag.CommonBlockTags;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;

View file

@ -1,8 +1,8 @@
package org.betterx.bclib.world.structures;
import org.betterx.bclib.api.v2.levelgen.structures.BCLStructureBuilder;
import org.betterx.bclib.api.v2.tag.TagAPI;
import org.betterx.bclib.util.MHelper;
import org.betterx.worlds.together.tag.TagManager;
import com.mojang.serialization.Codec;
import net.minecraft.resources.ResourceLocation;
@ -69,7 +69,7 @@ public class BCLStructure<S extends Structure> extends org.betterx.bclib.api.v2.
separation,
adaptNoise,
Structure.simpleCodec(structureBuilder),
TagAPI.makeStructureTag(id.getNamespace(), id.getPath())
TagManager.BIOMES.makeStructureTag(id.getNamespace(), id.getPath())
);
}

View file

@ -1,6 +1,7 @@
package org.betterx.worlds.together;
import org.betterx.bclib.util.Logger;
import org.betterx.worlds.together.tag.TagManager;
import org.betterx.worlds.together.world.WorldConfig;
import org.betterx.worlds.together.worldPreset.WorldPresets;
@ -21,8 +22,12 @@ public class WorldsTogether {
}
public static void onInitialize() {
TagManager.ensureStaticallyLoaded();
WorldConfig.registerModCache(WorldsTogether.MOD_ID);
WorldPresets.ensureStaticallyLoaded();
}
public static ResourceLocation makeID(String s) {

View file

@ -1,7 +1,7 @@
package org.betterx.worlds.together.flatLevel;
import org.betterx.bclib.api.v2.tag.TagAPI;
import org.betterx.bclib.api.v2.tag.TagType;
import org.betterx.worlds.together.tag.TagManager;
import org.betterx.worlds.together.tag.TagRegistry;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceKey;
@ -10,8 +10,8 @@ import net.minecraft.tags.FlatLevelGeneratorPresetTags;
import net.minecraft.world.level.levelgen.flat.FlatLevelGeneratorPreset;
public class FlatLevelPresets {
public static TagType.Simple<FlatLevelGeneratorPreset> FLAT_LEVEL_PRESETS =
TagAPI.registerType(
public static TagRegistry.Simple<FlatLevelGeneratorPreset> FLAT_LEVEL_PRESETS =
TagManager.registerType(
Registry.FLAT_LEVEL_GENERATOR_PRESET_REGISTRY,
"tags/worldgen/flat_level_generator_preset",
(b) -> null

View file

@ -1,4 +1,4 @@
package org.betterx.bclib.mixin.common;
package org.betterx.worlds.together.mixin.common;
import net.minecraft.tags.TagKey;
import net.minecraft.world.item.DiggerItem;

View file

@ -1,6 +1,6 @@
package org.betterx.bclib.mixin.common;
package org.betterx.worlds.together.mixin.common;
import org.betterx.bclib.api.v2.tag.TagAPI;
import org.betterx.worlds.together.tag.TagManager;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.TagLoader;
@ -22,6 +22,6 @@ public class TagLoaderMixin {
@ModifyArg(method = "loadAndBuild", at = @At(value = "INVOKE", target = "Lnet/minecraft/tags/TagLoader;build(Ljava/util/Map;)Ljava/util/Map;"))
public Map<ResourceLocation, List<TagLoader.EntryWithSource>> be_modifyTags(Map<ResourceLocation, List<TagLoader.EntryWithSource>> tagsMap) {
return TagAPI.apply(directory, tagsMap);
return TagManager.apply(directory, tagsMap);
}
}

View file

@ -0,0 +1,11 @@
package org.betterx.worlds.together.tag;
import net.minecraft.tags.TagKey;
import net.minecraft.world.level.biome.Biome;
public class CommonBiomeTags {
public static final TagKey<Biome> IN_NETHER = TagManager.BIOMES.makeCommonTag("in_nether");
static void prepareTags() {
}
}

View file

@ -0,0 +1,110 @@
package org.betterx.worlds.together.tag;
import net.minecraft.tags.BlockTags;
import net.minecraft.tags.TagKey;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
public class CommonBlockTags {
public static final TagKey<Block> BARREL = TagManager.BLOCKS.makeCommonTag("barrel");
public static final TagKey<Block> BOOKSHELVES = TagManager.BLOCKS.makeCommonTag("bookshelves");
public static final TagKey<Block> CHEST = TagManager.BLOCKS.makeCommonTag("chest");
public static final TagKey<Block> END_STONES = TagManager.BLOCKS.makeCommonTag("end_stones");
public static final TagKey<Block> GEN_END_STONES = END_STONES;
public static final TagKey<Block> IMMOBILE = TagManager.BLOCKS.makeCommonTag("immobile");
public static final TagKey<Block> LEAVES = TagManager.BLOCKS.makeCommonTag("leaves");
public static final TagKey<Block> NETHERRACK = TagManager.BLOCKS.makeCommonTag("netherrack");
public static final TagKey<Block> MYCELIUM = TagManager.BLOCKS.makeCommonTag("mycelium");
public static final TagKey<Block> NETHER_MYCELIUM = TagManager.BLOCKS.makeCommonTag("nether_mycelium");
public static final TagKey<Block> NETHER_PORTAL_FRAME = TagManager.BLOCKS.makeCommonTag("nether_pframe");
public static final TagKey<Block> NETHER_STONES = TagManager.BLOCKS.makeCommonTag("nether_stones");
public static final TagKey<Block> NETHER_ORES = TagManager.BLOCKS.makeCommonTag("nether_ores");
public static final TagKey<Block> END_ORES = TagManager.BLOCKS.makeCommonTag("end_ores");
public static final TagKey<Block> SAPLINGS = TagManager.BLOCKS.makeCommonTag("saplings");
public static final TagKey<Block> SOUL_GROUND = TagManager.BLOCKS.makeCommonTag("soul_ground");
public static final TagKey<Block> WOODEN_BARREL = TagManager.BLOCKS.makeCommonTag("wooden_barrels");
public static final TagKey<Block> WOODEN_CHEST = TagManager.BLOCKS.makeCommonTag("wooden_chests");
public static final TagKey<Block> WORKBENCHES = TagManager.BLOCKS.makeCommonTag("workbench");
public static final TagKey<Block> DRAGON_IMMUNE = TagManager.BLOCKS.makeCommonTag("dragon_immune");
public static final TagKey<Block> MINABLE_WITH_HAMMER = TagManager.BLOCKS.makeCommonTag("mineable/hammer");
public static final TagKey<Block> IS_OBSIDIAN = TagManager.BLOCKS.makeCommonTag("is_obsidian");
public static final TagKey<Block> TERRAIN = TagManager.BLOCKS.makeCommonTag("terrain");
public static final TagKey<Block> NETHER_TERRAIN = TagManager.BLOCKS.makeCommonTag("nether_terrain");
static void prepareTags() {
TagManager.BLOCKS.addOtherTags(DRAGON_IMMUNE, BlockTags.DRAGON_IMMUNE);
TagManager.BLOCKS.add(END_STONES, Blocks.END_STONE);
TagManager.BLOCKS.addOtherTags(NETHER_STONES, BlockTags.BASE_STONE_NETHER);
TagManager.BLOCKS.add(
NETHERRACK,
Blocks.NETHERRACK,
Blocks.NETHER_QUARTZ_ORE,
Blocks.NETHER_GOLD_ORE,
Blocks.CRIMSON_NYLIUM,
Blocks.WARPED_NYLIUM
);
TagManager.BLOCKS.add(NETHER_ORES, Blocks.NETHER_QUARTZ_ORE, Blocks.NETHER_GOLD_ORE);
TagManager.BLOCKS.add(SOUL_GROUND, Blocks.SOUL_SAND, Blocks.SOUL_SOIL);
TagManager.BLOCKS.add(IS_OBSIDIAN, Blocks.OBSIDIAN, Blocks.CRYING_OBSIDIAN);
TagManager.BLOCKS.add(MYCELIUM, Blocks.MYCELIUM);
TagManager.BLOCKS.addOtherTags(MYCELIUM, NETHER_MYCELIUM);
TagManager.BLOCKS.add(
TERRAIN,
Blocks.MAGMA_BLOCK,
Blocks.GRAVEL,
Blocks.SAND,
Blocks.RED_SAND,
Blocks.GLOWSTONE,
Blocks.BONE_BLOCK,
Blocks.SCULK
);
TagManager.BLOCKS.addOtherTags(
TERRAIN,
NETHER_TERRAIN,
BlockTags.DRIPSTONE_REPLACEABLE,
BlockTags.BASE_STONE_OVERWORLD,
BlockTags.NYLIUM,
MYCELIUM,
END_STONES
);
TagManager.BLOCKS.add(
NETHER_TERRAIN,
Blocks.MAGMA_BLOCK,
Blocks.GRAVEL,
Blocks.RED_SAND,
Blocks.GLOWSTONE,
Blocks.BONE_BLOCK,
Blocks.SCULK
);
TagManager.BLOCKS.addOtherTags(
NETHER_TERRAIN,
NETHERRACK,
BlockTags.NYLIUM,
NETHER_STONES,
NETHER_ORES,
SOUL_GROUND,
NETHER_MYCELIUM
);
TagManager.BLOCKS.add(CommonBlockTags.BOOKSHELVES, Blocks.BOOKSHELF);
TagManager.BLOCKS.add(CommonBlockTags.CHEST, Blocks.CHEST);
TagManager.BLOCKS.add(BlockTags.NETHER_CARVER_REPLACEABLES, Blocks.RED_SAND, Blocks.MAGMA_BLOCK, Blocks.SCULK);
TagManager.BLOCKS.addOtherTags(
BlockTags.NETHER_CARVER_REPLACEABLES,
CommonBlockTags.NETHER_STONES,
CommonBlockTags.NETHERRACK
);
}
}

View file

@ -0,0 +1,29 @@
package org.betterx.worlds.together.tag;
import net.minecraft.tags.TagKey;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.block.Blocks;
public class CommonItemTags {
public final static TagKey<Item> HAMMERS = TagManager.ITEMS.makeCommonTag("hammers");
public static final TagKey<Item> BARREL = TagManager.ITEMS.makeCommonTag("barrel");
public static final TagKey<Item> CHEST = TagManager.ITEMS.makeCommonTag("chest");
public static final TagKey<Item> SHEARS = TagManager.ITEMS.makeCommonTag("shears");
public static final TagKey<Item> FURNACES = TagManager.ITEMS.makeCommonTag("furnaces");
public static final TagKey<Item> IRON_INGOTS = TagManager.ITEMS.makeCommonTag("iron_ingots");
public static final TagKey<Item> LEAVES = TagManager.ITEMS.makeCommonTag("leaves");
public static final TagKey<Item> SAPLINGS = TagManager.ITEMS.makeCommonTag("saplings");
public static final TagKey<Item> SOUL_GROUND = TagManager.ITEMS.makeCommonTag("soul_ground");
public static final TagKey<Item> WOODEN_BARREL = TagManager.ITEMS.makeCommonTag("wooden_barrels");
public static final TagKey<Item> WOODEN_CHEST = TagManager.ITEMS.makeCommonTag("wooden_chests");
public static final TagKey<Item> WORKBENCHES = TagManager.ITEMS.makeCommonTag("workbench");
static void prepareTags() {
TagManager.ITEMS.add(SOUL_GROUND, Blocks.SOUL_SAND.asItem(), Blocks.SOUL_SOIL.asItem());
TagManager.ITEMS.add(CommonItemTags.CHEST, Items.CHEST);
TagManager.ITEMS.add(CommonItemTags.IRON_INGOTS, Items.IRON_INGOT);
TagManager.ITEMS.add(CommonItemTags.FURNACES, Blocks.FURNACE.asItem());
}
}

View file

@ -0,0 +1,21 @@
package org.betterx.worlds.together.tag;
import net.minecraft.tags.BlockTags;
import net.minecraft.tags.TagKey;
import net.minecraft.world.level.block.Block;
import net.fabricmc.fabric.api.mininglevel.v1.FabricMineableTags;
public class MineableTags {
public static final TagKey<Block> AXE = BlockTags.MINEABLE_WITH_AXE;
public static final TagKey<Block> HOE = BlockTags.MINEABLE_WITH_HOE;
public static final TagKey<Block> PICKAXE = BlockTags.MINEABLE_WITH_PICKAXE;
public static final TagKey<Block> SHEARS = FabricMineableTags.SHEARS_MINEABLE;
public static final TagKey<Block> SHOVEL = BlockTags.MINEABLE_WITH_SHOVEL;
public static final TagKey<Block> SWORD = FabricMineableTags.SWORD_MINEABLE;
public static final TagKey<Block> HAMMER = TagManager.BLOCKS.makeCommonTag("mineable/hammer");
static void prepareTags() {
}
}

View file

@ -0,0 +1,121 @@
package org.betterx.worlds.together.tag;
import org.betterx.bclib.api.v2.levelgen.biomes.BiomeAPI;
import org.betterx.bclib.api.v2.tag.TagAPI;
import org.betterx.worlds.together.mixin.common.DiggerItemAccessor;
import net.minecraft.core.DefaultedRegistry;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.packs.resources.ResourceManager;
import net.minecraft.tags.TagKey;
import net.minecraft.tags.TagLoader;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.Block;
import com.google.common.collect.Maps;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import org.jetbrains.annotations.ApiStatus;
public class TagManager {
private static final Map<String, TagRegistry<?>> TYPES = Maps.newHashMap();
public static TagRegistry.RegistryBacked<Block> BLOCKS = registerType(Registry.BLOCK);
public static TagRegistry.RegistryBacked<Item> ITEMS = registerType(Registry.ITEM);
public static TagRegistry.Biomes BIOMES = registerBiome();
public static <T> TagRegistry.RegistryBacked<T> registerType(DefaultedRegistry<T> registry) {
TagRegistry<T> type = new TagRegistry.RegistryBacked<>(registry);
return (TagRegistry.RegistryBacked<T>) TYPES.computeIfAbsent(type.directory, (dir) -> type);
}
public static <T> TagRegistry.Simple<T> registerType(Registry<T> registry, String directory) {
return registerType(registry.key(), directory, (o) -> registry.getKey(o));
}
public static <T> TagRegistry.Simple<T> registerType(
ResourceKey<? extends Registry<T>> registry,
String directory,
Function<T, ResourceLocation> locationProvider
) {
return (TagRegistry.Simple<T>) TYPES.computeIfAbsent(
directory,
(dir) -> new TagRegistry.Simple<>(
registry,
dir,
locationProvider
)
);
}
static TagRegistry.Biomes registerBiome() {
return (TagRegistry.Biomes) TYPES.computeIfAbsent(
"tags/worldgen/biome",
(dir) -> new TagRegistry.Biomes(
dir,
b -> BiomeAPI.getBiomeID(b)
)
);
}
public static <T> TagRegistry.UnTyped<T> registerType(
ResourceKey<? extends Registry<T>> registry,
String directory
) {
return (TagRegistry.UnTyped<T>) TYPES.computeIfAbsent(
directory,
(dir) -> new TagRegistry.UnTyped<>(registry, dir)
);
}
/**
* Initializes basic tags. Should be called only in BCLib main class.
*/
@ApiStatus.Internal
public static void ensureStaticallyLoaded() {
CommonItemTags.prepareTags();
CommonBlockTags.prepareTags();
CommonBiomeTags.prepareTags();
MineableTags.prepareTags();
ToolTags.prepareTags();
}
/**
* Automatically called in {@link net.minecraft.tags.TagLoader#loadAndBuild(ResourceManager)}.
* <p>
* In most cases there is no need to call this Method manually.
*
* @param directory The name of the Tag-directory. Should be either <i>"tags/blocks"</i> or
* <i>"tags/items"</i>.
* @param tagsMap The map that will hold the registered Tags
* @return The {@code tagsMap} Parameter.
*/
@ApiStatus.Internal
public static <T> Map<ResourceLocation, List<TagLoader.EntryWithSource>> apply(
String directory,
Map<ResourceLocation, List<TagLoader.EntryWithSource>> tagsMap
) {
tagsMap = TagAPI.apply(directory, tagsMap);
TagRegistry<?> type = TYPES.get(directory);
if (type != null) {
type.apply(tagsMap);
}
return tagsMap;
}
public static boolean isToolWithMineableTag(ItemStack stack, TagKey<Block> tag) {
if (stack.getItem() instanceof DiggerItemAccessor dig) {
return dig.bclib_getBlockTag().equals(tag);
}
return false;
}
}

View file

@ -0,0 +1,270 @@
package org.betterx.worlds.together.tag;
import org.betterx.bclib.BCLib;
import org.betterx.bclib.api.v2.levelgen.biomes.InternalBiomeAPI;
import net.minecraft.core.DefaultedRegistry;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.TagEntry;
import net.minecraft.tags.TagKey;
import net.minecraft.tags.TagLoader;
import net.minecraft.tags.TagManager;
import net.minecraft.world.level.biome.Biome;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.function.BiConsumer;
import java.util.function.Function;
import org.jetbrains.annotations.ApiStatus;
public class TagRegistry<T> {
boolean isFrozen = false;
public static class RegistryBacked<T> extends Simple<T> {
private final DefaultedRegistry<T> registry;
RegistryBacked(DefaultedRegistry<T> registry) {
super(
registry.key(),
TagManager.getTagDir(registry.key()),
(T element) -> {
ResourceLocation id = registry.getKey(element);
if (id != registry.getDefaultKey()) {
return id;
}
return null;
}
);
this.registry = registry;
}
@Override
public TagKey<T> makeTag(ResourceLocation id) {
initializeTag(id);
return registry
.getTagNames()
.filter(tagKey -> tagKey.location().equals(id))
.findAny()
.orElse(TagKey.create(registry.key(), id));
}
}
public static class Simple<T> extends TagRegistry<T> {
Simple(
ResourceKey<? extends Registry<T>> registry,
String directory,
Function<T, ResourceLocation> locationProvider
) {
super(registry, directory, locationProvider);
}
public void add(TagKey<T> tagID, T... elements) {
super.add(tagID, elements);
}
public void add(T element, TagKey<T>... tagIDs) {
super.add(element, tagIDs);
}
@Deprecated(forRemoval = true)
public void add(ResourceLocation tagID, T... elements) {
super.add(tagID, elements);
}
@Deprecated(forRemoval = true)
public void add(T element, ResourceLocation... tagIDs) {
super.add(element, tagIDs);
}
}
public static class Biomes extends Simple<Biome> {
@ApiStatus.Internal
public Biomes(String directory, Function<Biome, ResourceLocation> locationProvider) {
super(Registry.BIOME_REGISTRY, directory, locationProvider);
}
public TagKey<Biome> makeStructureTag(String modID, String name) {
return makeTag(modID, "has_structure/" + name);
}
public void apply(Map<ResourceLocation, List<TagLoader.EntryWithSource>> tagsMap) {
InternalBiomeAPI._runBiomeTagAdders();
super.apply(tagsMap);
}
}
public static class UnTyped<T> extends TagRegistry<T> {
UnTyped(
ResourceKey<? extends Registry<T>> registry,
String directory
) {
super(registry, directory, (t) -> {
throw new RuntimeException("Using Untyped TagType with Type-Dependant access. ");
});
}
}
public final String directory;
private final Map<ResourceLocation, Set<TagEntry>> tags = Maps.newConcurrentMap();
public final ResourceKey<? extends Registry<T>> registryKey;
private final Function<T, ResourceLocation> locationProvider;
private TagRegistry(
ResourceKey<? extends Registry<T>> registry,
String directory,
Function<T, ResourceLocation> locationProvider
) {
this.registryKey = registry;
this.directory = directory;
this.locationProvider = locationProvider;
}
protected void initializeTag(ResourceLocation tagID) {
getSetForTag(tagID);
}
public Set<TagEntry> getSetForTag(ResourceLocation tagID) {
return tags.computeIfAbsent(tagID, k -> Sets.newHashSet());
}
public Set<TagEntry> getSetForTag(TagKey<T> tag) {
if (tag == null) {
return new HashSet<>();
}
return getSetForTag(tag.location());
}
/**
* Get or create a {@link TagKey}.
*
* @param modId - {@link String} mod namespace (mod id);
* @param name - {@link String} tag name.
* @return the corresponding TagKey {@link TagKey<T>}.
*/
public TagKey<T> makeTag(String modId, String name) {
return makeTag(new ResourceLocation(modId, name));
}
/**
* Get or create a {@link TagKey}.
*
* @param id - {@link ResourceLocation} of the tag;
* @return the corresponding TagKey {@link TagKey<T>}.
*/
public TagKey<T> makeTag(ResourceLocation id) {
return creatTagKey(id);
}
protected TagKey<T> creatTagKey(ResourceLocation id) {
initializeTag(id);
return TagKey.create(registryKey, id);
}
/**
* Get or create a common {@link TagKey} (namespace is 'c').
*
* @param name - The name of the Tag;
* @return the corresponding TagKey {@link TagKey<T>}.
* @see <a href="https://fabricmc.net/wiki/tutorial:tags">Fabric Wiki (Tags)</a>
*/
public TagKey<T> makeCommonTag(String name) {
return creatTagKey(new ResourceLocation("c", name));
}
public void addUntyped(TagKey<T> tagID, ResourceLocation... elements) {
if (isFrozen) BCLib.LOGGER.warning("Adding Tag " + tagID + " after the API was frozen.");
Set<TagEntry> set = getSetForTag(tagID);
for (ResourceLocation id : elements) {
if (id != null) {
set.add(TagEntry.element(id));
}
}
}
public void addUntyped(ResourceLocation element, TagKey<T>... tagIDs) {
for (TagKey<T> tagID : tagIDs) {
addUntyped(tagID, element);
}
}
public void addOtherTags(TagKey<T> tagID, TagKey<T>... tags) {
if (isFrozen) BCLib.LOGGER.warning("Adding Tag " + tagID + " after the API was frozen.");
Set<TagEntry> set = getSetForTag(tagID);
for (TagKey<T> tag : tags) {
ResourceLocation id = tag.location();
if (id != null) {
set.add(TagEntry.tag(id));
}
}
}
/**
* Adds one Tag to multiple Elements.
*
* @param tagID {@link TagKey< Biome >} tag ID.
* @param elements array of Elements to add into tag.
*/
protected void add(TagKey<T> tagID, T... elements) {
if (isFrozen) BCLib.LOGGER.warning("Adding Tag " + tagID + " after the API was frozen.");
Set<TagEntry> set = getSetForTag(tagID);
for (T element : elements) {
ResourceLocation id = locationProvider.apply(element);
if (id != null) {
set.add(TagEntry.element(id));
}
}
}
protected void add(T element, TagKey<T>... tagIDs) {
for (TagKey<T> tagID : tagIDs) {
add(tagID, element);
}
}
@Deprecated(forRemoval = true)
protected void add(ResourceLocation tagID, T... elements) {
if (isFrozen) BCLib.LOGGER.warning("Adding Tag " + tagID + " after the API was frozen.");
Set<TagEntry> set = getSetForTag(tagID);
for (T element : elements) {
ResourceLocation id = locationProvider.apply(element);
if (id != null) {
set.add(TagEntry.element(id));
}
}
}
@Deprecated(forRemoval = true)
protected void add(T element, ResourceLocation... tagIDs) {
for (ResourceLocation tagID : tagIDs) {
add(tagID, element);
}
}
public void forEach(BiConsumer<ResourceLocation, Set<TagEntry>> consumer) {
tags.forEach(consumer);
}
public void apply(Map<ResourceLocation, List<TagLoader.EntryWithSource>> tagsMap) {
//this.isFrozen = true;
this.forEach((id, ids) -> apply(id, tagsMap.computeIfAbsent(id, key -> Lists.newArrayList()), ids));
}
private static List<TagLoader.EntryWithSource> apply(
ResourceLocation id,
List<TagLoader.EntryWithSource> builder,
Set<TagEntry> ids
) {
ids.forEach(value -> builder.add(new TagLoader.EntryWithSource(value, BCLib.MOD_ID)));
return builder;
}
}

View file

@ -0,0 +1,17 @@
package org.betterx.worlds.together.tag;
import net.minecraft.tags.TagKey;
import net.minecraft.world.item.Item;
public class ToolTags {
public static final TagKey<Item> FABRIC_AXES = TagManager.ITEMS.makeTag("fabric", "axes");
public static final TagKey<Item> FABRIC_HOES = TagManager.ITEMS.makeTag("fabric", "hoes");
public static final TagKey<Item> FABRIC_PICKAXES = TagManager.ITEMS.makeTag("fabric", "pickaxes");
public static final TagKey<Item> FABRIC_SHEARS = TagManager.ITEMS.makeTag("fabric", "shears");
public static final TagKey<Item> FABRIC_SHOVELS = TagManager.ITEMS.makeTag("fabric", "shovels");
public static final TagKey<Item> FABRIC_SWORDS = TagManager.ITEMS.makeTag("fabric", "swords");
static void prepareTags() {
}
}

View file

@ -1,9 +1,9 @@
package org.betterx.worlds.together.worldPreset;
import org.betterx.bclib.api.v2.tag.TagAPI;
import org.betterx.bclib.api.v2.tag.TagType;
import org.betterx.bclib.registry.PresetsRegistry;
import org.betterx.worlds.together.WorldsTogether;
import org.betterx.worlds.together.tag.TagManager;
import org.betterx.worlds.together.tag.TagRegistry;
import org.betterx.worlds.together.world.WorldGenUtil;
import org.betterx.worlds.together.worldPreset.client.WorldPresetsClient;
import org.betterx.worlds.together.worldPreset.settings.VanillaWorldPresetSettings;
@ -26,8 +26,8 @@ import java.util.Optional;
public class WorldPresets {
public static final TagType.Simple<WorldPreset> WORLD_PRESETS =
TagAPI.registerType(BuiltinRegistries.WORLD_PRESET, "tags/worldgen/world_preset");
public static final TagRegistry.Simple<WorldPreset> WORLD_PRESETS =
TagManager.registerType(BuiltinRegistries.WORLD_PRESET, "tags/worldgen/world_preset");
private static Map<ResourceKey<WorldPreset>, PresetBuilder> BUILDERS = Maps.newHashMap();
private static final Map<ResourceKey<WorldPreset>, WorldPresetSettings> SETTINGS = Maps.newHashMap();
public static Optional<ResourceKey<WorldPreset>> DEFAULT = Optional.of(net.minecraft.world.level.levelgen.presets.WorldPresets.NORMAL);

View file

@ -17,7 +17,6 @@
"ComposterBlockAccessor",
"CraftingMenuMixin",
"DedicatedServerPropertiesMixin",
"DiggerItemAccessor",
"DiggerItemMixin",
"EnchantingTableBlockMixin",
"ItemStackMixin",
@ -38,7 +37,6 @@
"ShovelItemAccessor",
"StructuresAccessor",
"SurfaceRulesContextAccessor",
"TagLoaderMixin",
"TheEndBiomeDataMixin",
"WorldGenRegionMixin",
"elytra.LivingEntityMixin",

View file

@ -4,9 +4,11 @@
"package": "org.betterx.worlds.together.mixin.common",
"compatibilityLevel": "JAVA_17",
"mixins": [
"DiggerItemAccessor",
"MainMixin",
"PrimaryLevelDataMixin",
"RegistryOpsAccessor",
"TagLoaderMixin",
"WorldGenPropertiesMixin",
"WorldPresetAccessor",
"WorldPresetMixin",