Simplified TagAPI due to changes in 1.18.2
This commit is contained in:
parent
b84a5a1b5d
commit
cb9459f176
28 changed files with 197 additions and 342 deletions
|
@ -6,13 +6,14 @@ import net.fabricmc.api.Environment;
|
|||
import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.tags.TagKey;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import ru.bclib.BCLib;
|
||||
import ru.bclib.api.biomes.BiomeAPI;
|
||||
import ru.bclib.api.tag.NamedMineableTags;
|
||||
import ru.bclib.api.tag.TagAPI;
|
||||
import ru.bclib.api.tag.TagAPI.TagLocation;
|
||||
|
||||
import ru.bclib.blocks.BaseBarrelBlock;
|
||||
import ru.bclib.blocks.BaseChestBlock;
|
||||
import ru.bclib.blocks.BaseFurnaceBlock;
|
||||
|
@ -39,8 +40,8 @@ import java.util.function.Consumer;
|
|||
|
||||
public class PostInitAPI {
|
||||
private static List<Consumer<Boolean>> postInitFunctions = Lists.newArrayList();
|
||||
private static List<TagLocation<Block>> blockTags = Lists.newArrayList();
|
||||
private static List<TagLocation<Item>> itemTags = Lists.newArrayList();
|
||||
private static List<TagKey<Block>> blockTags = Lists.newArrayList();
|
||||
private static List<TagKey<Item>> itemTags = Lists.newArrayList();
|
||||
|
||||
/**
|
||||
* Register a new function which will be called after all mods are initiated. Will be called on both client and server.
|
||||
|
|
|
@ -21,5 +21,7 @@ public class CommonBlockTags {
|
|||
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");
|
||||
}
|
||||
|
|
|
@ -1,37 +1,39 @@
|
|||
package ru.bclib.api.tag;
|
||||
|
||||
import net.minecraft.tags.BlockTags;
|
||||
import net.minecraft.tags.TagKey;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import ru.bclib.api.tag.TagAPI.TagLocation;
|
||||
|
||||
|
||||
public class NamedBlockTags {
|
||||
public static final TagLocation<Block> ANVIL = new TagLocation<>("anvil");
|
||||
public static final TagLocation<Block> BUTTONS = new TagLocation<>("buttons");
|
||||
public static final TagLocation<Block> CLIMBABLE = new TagLocation<>("climbable");
|
||||
public static final TagLocation<Block> DOORS = new TagLocation<>("doors");
|
||||
public static final TagLocation<Block> FENCES = new TagLocation<>("fences");
|
||||
public static final TagLocation<Block> FENCE_GATES = new TagLocation<>("fence_gates");
|
||||
public static final TagLocation<Block> LEAVES = new TagLocation<>("leaves");
|
||||
public static final TagLocation<Block> LOGS = new TagLocation<>("logs");
|
||||
public static final TagLocation<Block> LOGS_THAT_BURN = new TagLocation<>("logs_that_burn");
|
||||
public static final TagLocation<Block> NYLIUM = new TagLocation<>("nylium");
|
||||
public static final TagLocation<Block> PLANKS = new TagLocation<>("planks");
|
||||
public static final TagLocation<Block> PRESSURE_PLATES = new TagLocation<>("pressure_plates");
|
||||
public static final TagLocation<Block> SAPLINGS = new TagLocation<>("saplings");
|
||||
public static final TagLocation<Block> SIGNS = new TagLocation<>("signs");
|
||||
public static final TagLocation<Block> SLABS = new TagLocation<>("slabs");
|
||||
public static final TagLocation<Block> STAIRS = new TagLocation<>("stairs");
|
||||
public static final TagLocation<Block> STONE_PRESSURE_PLATES = new TagLocation<>("stone_pressure_plates");
|
||||
public static final TagLocation<Block> TRAPDOORS = new TagLocation<>("trapdoors");
|
||||
public static final TagLocation<Block> WALLS = new TagLocation<>("walls");
|
||||
public static final TagLocation<Block> WOODEN_BUTTONS = new TagLocation<>("wooden_buttons");
|
||||
public static final TagLocation<Block> WOODEN_DOORS = new TagLocation<>("wooden_doors");
|
||||
public static final TagLocation<Block> WOODEN_FENCES = new TagLocation<>("wooden_fences");
|
||||
public static final TagLocation<Block> WOODEN_PRESSURE_PLATES = new TagLocation<>("wooden_pressure_plates");
|
||||
public static final TagLocation<Block> WOODEN_SLABS = new TagLocation<>("wooden_slabs");
|
||||
public static final TagLocation<Block> WOODEN_STAIRS = new TagLocation<>("wooden_stairs");
|
||||
public static final TagLocation<Block> WOODEN_TRAPDOORS = new TagLocation<>("wooden_trapdoors");
|
||||
public static final TagLocation<Block> SOUL_FIRE_BASE_BLOCKS = new TagLocation<>("soul_fire_base_blocks");
|
||||
public static final TagLocation<Block> SOUL_SPEED_BLOCKS = new TagLocation<>("soul_speed_blocks");
|
||||
public static final TagLocation<Block> BEACON_BASE_BLOCKS = new TagLocation<>("beacon_base_blocks");
|
||||
public static final TagLocation<Block> STONE_BRICKS = new TagLocation("stone_bricks");
|
||||
public static final TagKey<Block> ANVIL = BlockTags.ANVIL;
|
||||
public static final TagKey<Block> BUTTONS = BlockTags.BUTTONS;
|
||||
public static final TagKey<Block> CLIMBABLE = BlockTags.CLIMBABLE;
|
||||
public static final TagKey<Block> DOORS = BlockTags.DOORS;
|
||||
public static final TagKey<Block> FENCES = BlockTags.FENCES;
|
||||
public static final TagKey<Block> FENCE_GATES = BlockTags.FENCE_GATES;
|
||||
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;
|
||||
public static final TagKey<Block> NYLIUM = BlockTags.NYLIUM;
|
||||
public static final TagKey<Block> PLANKS = BlockTags.PLANKS;
|
||||
public static final TagKey<Block> PRESSURE_PLATES = BlockTags.PRESSURE_PLATES;
|
||||
public static final TagKey<Block> SAPLINGS = BlockTags.SAPLINGS;
|
||||
public static final TagKey<Block> SIGNS = BlockTags.SIGNS;
|
||||
public static final TagKey<Block> SLABS = BlockTags.SLABS;
|
||||
public static final TagKey<Block> STAIRS = BlockTags.STAIRS;
|
||||
public static final TagKey<Block> STONE_PRESSURE_PLATES = BlockTags.STONE_PRESSURE_PLATES;
|
||||
public static final TagKey<Block> TRAPDOORS = BlockTags.TRAPDOORS;
|
||||
public static final TagKey<Block> WALLS = BlockTags.WALLS;
|
||||
public static final TagKey<Block> WOODEN_BUTTONS = BlockTags.WOODEN_BUTTONS;
|
||||
public static final TagKey<Block> WOODEN_DOORS = BlockTags.WOODEN_DOORS;
|
||||
public static final TagKey<Block> WOODEN_FENCES = BlockTags.WOODEN_FENCES;
|
||||
public static final TagKey<Block> WOODEN_PRESSURE_PLATES = BlockTags.WOODEN_PRESSURE_PLATES;
|
||||
public static final TagKey<Block> WOODEN_SLABS = BlockTags.WOODEN_SLABS;
|
||||
public static final TagKey<Block> WOODEN_STAIRS = BlockTags.WOODEN_STAIRS;
|
||||
public static final TagKey<Block> WOODEN_TRAPDOORS = BlockTags.WOODEN_TRAPDOORS;
|
||||
public static final TagKey<Block> SOUL_FIRE_BASE_BLOCKS = BlockTags.SOUL_FIRE_BASE_BLOCKS;
|
||||
public static final TagKey<Block> SOUL_SPEED_BLOCKS = BlockTags.SOUL_SPEED_BLOCKS;
|
||||
public static final TagKey<Block> BEACON_BASE_BLOCKS = BlockTags.BEACON_BASE_BLOCKS;
|
||||
public static final TagKey<Block> STONE_BRICKS = BlockTags.STONE_BRICKS;
|
||||
}
|
||||
|
|
|
@ -1,24 +0,0 @@
|
|||
package ru.bclib.api.tag;
|
||||
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import ru.bclib.api.tag.TagAPI.TagLocation;
|
||||
|
||||
public class NamedCommonBlockTags {
|
||||
public static final TagLocation<Block> BARREL = new TagLocation<>("c", "barrel");
|
||||
public static final TagLocation<Block> BOOKSHELVES = new TagLocation<>("c", "bookshelves");
|
||||
public static final TagLocation<Block> CHEST = new TagLocation<>("c", "chest");
|
||||
public static final TagLocation<Block> END_STONES = new TagLocation<>("c", "end_stones");
|
||||
public static final TagLocation<Block> GEN_END_STONES = END_STONES;
|
||||
public static final TagLocation<Block> IMMOBILE = new TagLocation<>("c", "immobile");
|
||||
public static final TagLocation<Block> LEAVES = new TagLocation<>("c", "leaves");
|
||||
public static final TagLocation<Block> NETHERRACK = new TagLocation<>("c", "netherrack");
|
||||
public static final TagLocation<Block> NETHER_MYCELIUM = new TagLocation<>("c", "nether_mycelium");
|
||||
public static final TagLocation<Block> NETHER_PORTAL_FRAME = new TagLocation<>("c", "nether_pframe");
|
||||
public static final TagLocation<Block> NETHER_STONES = new TagLocation<>("c", "nether_stones");
|
||||
public static final TagLocation<Block> SAPLINGS = new TagLocation<>("c", "saplings");
|
||||
public static final TagLocation<Block> SOUL_GROUND = new TagLocation<>("c", "soul_ground");
|
||||
public static final TagLocation<Block> WOODEN_BARREL = new TagLocation<>("c", "wooden_barrels");
|
||||
public static final TagLocation<Block> WOODEN_CHEST = new TagLocation<>("c", "wooden_chests");
|
||||
public static final TagLocation<Block> WORKBENCHES = new TagLocation<>("c", "workbench");
|
||||
public static final TagLocation<Block> DRAGON_IMMUNE = new TagLocation<>("c", "dragon_immune");
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
package ru.bclib.api.tag;
|
||||
|
||||
import net.minecraft.world.item.Item;
|
||||
import ru.bclib.api.tag.TagAPI.TagLocation;
|
||||
|
||||
public class NamedCommonItemTags {
|
||||
// Common Item Tags
|
||||
public static final TagLocation<Item> BARREL = new TagLocation<>("c", "barrel");
|
||||
public static final TagLocation<Item> CHEST = new TagLocation<>("c", "chest");
|
||||
public static final TagLocation<Item> FURNACES = new TagLocation<>("c", "furnaces");
|
||||
public static final TagLocation<Item> HAMMERS = new TagLocation<>("c", "hammers");
|
||||
public static final TagLocation<Item> IRON_INGOTS = new TagLocation<>("c", "iron_ingots");
|
||||
public static final TagLocation<Item> LEAVES = new TagLocation<>("c", "leaves");
|
||||
public static final TagLocation<Item> SAPLINGS = new TagLocation<>("c", "saplings");
|
||||
public static final TagLocation<Item> SHEARS = new TagLocation<>("c", "shears");
|
||||
public static final TagLocation<Item> SOUL_GROUND = new TagLocation<>("c", "soul_ground");
|
||||
public static final TagLocation<Item> WOODEN_BARREL = new TagLocation<>("c", "wooden_barrels");
|
||||
public static final TagLocation<Item> WOODEN_CHEST = new TagLocation<>("c", "wooden_chests");
|
||||
public static final TagLocation<Item> WORKBENCHES = new TagLocation<>("c", "workbench");
|
||||
}
|
|
@ -1,34 +1,32 @@
|
|||
package ru.bclib.api.tag;
|
||||
|
||||
import net.minecraft.tags.ItemTags;
|
||||
import net.minecraft.tags.TagKey;
|
||||
import net.minecraft.world.item.Item;
|
||||
import ru.bclib.api.tag.TagAPI.TagLocation;
|
||||
|
||||
|
||||
public class NamedItemTags {
|
||||
public static final TagLocation<Item> BUTTONS = new TagLocation<>("buttons");
|
||||
public static final TagLocation<Item> DOORS = new TagLocation<>("doors");
|
||||
public static final TagLocation<Item> FENCES = new TagLocation<>("fences");
|
||||
public static final TagLocation<Item> FENCE_GATES = new TagLocation<>("fence_gates");
|
||||
public static final TagLocation<Item> LEAVES = new TagLocation<>("leaves");
|
||||
public static final TagLocation<Item> LOGS = new TagLocation<>("logs");
|
||||
public static final TagLocation<Item> LOGS_THAT_BURN = new TagLocation<>("logs_that_burn");
|
||||
public static final TagLocation<Item> PLANKS = new TagLocation<>("planks");
|
||||
public static final TagLocation<Item> PRESSURE_PLATES = new TagLocation<>("pressure_plates");
|
||||
public static final TagLocation<Item> SAPLINGS = new TagLocation<>("saplings");
|
||||
public static final TagLocation<Item> SHEARS = new TagLocation<>("shears");
|
||||
public static final TagLocation<Item> SIGNS = new TagLocation<>("signs");
|
||||
public static final TagLocation<Item> SLABS = new TagLocation<>("slabs");
|
||||
public static final TagLocation<Item> STAIRS = new TagLocation<>("stairs");
|
||||
public static final TagLocation<Item> STONE_PRESSURE_PLATES = new TagLocation<>("stone_pressure_plates");
|
||||
public static final TagLocation<Item> TRAPDOORS = new TagLocation<>("trapdoors");
|
||||
public static final TagLocation<Item> WOODEN_BUTTONS = new TagLocation<>("wooden_buttons");
|
||||
public static final TagLocation<Item> WOODEN_DOORS = new TagLocation<>("wooden_doors");
|
||||
public static final TagLocation<Item> WOODEN_FENCES = new TagLocation<>("wooden_fences");
|
||||
public static final TagLocation<Item> WOODEN_PRESSURE_PLATES = new TagLocation<>("wooden_pressure_plates");
|
||||
public static final TagLocation<Item> WOODEN_SLABS = new TagLocation<>("wooden_slabs");
|
||||
public static final TagLocation<Item> WOODEN_STAIRS = new TagLocation<>("wooden_stairs");
|
||||
public static final TagLocation<Item> WOODEN_TRAPDOORS = new TagLocation<>("wooden_trapdoors");
|
||||
public static final TagLocation<Item> BEACON_PAYMENT_ITEMS = new TagLocation<>("beacon_payment_items");
|
||||
public static final TagLocation<Item> STONE_BRICKS = new TagLocation<>("stone_bricks");
|
||||
public static final TagLocation<Item> STONE_CRAFTING_MATERIALS = new TagLocation<>("stone_crafting_materials");
|
||||
public static final TagLocation<Item> STONE_TOOL_MATERIALS = new TagLocation<>("stone_tool_materials");
|
||||
public static final TagKey<Item> BUTTONS = ItemTags.BUTTONS;
|
||||
public static final TagKey<Item> DOORS = ItemTags.DOORS;
|
||||
public static final TagKey<Item> FENCES = ItemTags.FENCES;
|
||||
public static final TagKey<Item> LEAVES = ItemTags.LEAVES;
|
||||
public static final TagKey<Item> LOGS = ItemTags.LOGS;
|
||||
public static final TagKey<Item> LOGS_THAT_BURN = ItemTags.LOGS_THAT_BURN;
|
||||
public static final TagKey<Item> PLANKS = ItemTags.PLANKS;
|
||||
public static final TagKey<Item> SAPLINGS = ItemTags.SAPLINGS;
|
||||
public static final TagKey<Item> SIGNS = ItemTags.SIGNS;
|
||||
public static final TagKey<Item> SLABS = ItemTags.SLABS;
|
||||
public static final TagKey<Item> STAIRS = ItemTags.STAIRS;
|
||||
public static final TagKey<Item> TRAPDOORS = ItemTags.TRAPDOORS;
|
||||
public static final TagKey<Item> WOODEN_BUTTONS = ItemTags.WOODEN_BUTTONS;
|
||||
public static final TagKey<Item> WOODEN_DOORS = ItemTags.WOODEN_DOORS;
|
||||
public static final TagKey<Item> WOODEN_FENCES = ItemTags.WOODEN_FENCES;
|
||||
public static final TagKey<Item> WOODEN_PRESSURE_PLATES = ItemTags.WOODEN_PRESSURE_PLATES;
|
||||
public static final TagKey<Item> WOODEN_SLABS = ItemTags.WOODEN_SLABS;
|
||||
public static final TagKey<Item> WOODEN_STAIRS = ItemTags.WOODEN_STAIRS;
|
||||
public static final TagKey<Item> WOODEN_TRAPDOORS = ItemTags.WOODEN_TRAPDOORS;
|
||||
public static final TagKey<Item> BEACON_PAYMENT_ITEMS = ItemTags.BEACON_PAYMENT_ITEMS;
|
||||
public static final TagKey<Item> STONE_BRICKS = ItemTags.STONE_BRICKS;
|
||||
public static final TagKey<Item> STONE_CRAFTING_MATERIALS = ItemTags.STONE_CRAFTING_MATERIALS;
|
||||
public static final TagKey<Item> STONE_TOOL_MATERIALS = ItemTags.STONE_TOOL_MATERIALS;
|
||||
}
|
||||
|
|
|
@ -1,14 +1,16 @@
|
|||
package ru.bclib.api.tag;
|
||||
|
||||
import net.minecraft.tags.BlockTags;
|
||||
import net.minecraft.tags.TagKey;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import ru.bclib.api.tag.TagAPI.TagLocation;
|
||||
|
||||
|
||||
public class NamedMineableTags {
|
||||
public static final TagLocation<Block> AXE = new TagLocation<>("mineable/axe");
|
||||
public static final TagLocation<Block> HOE = new TagLocation<>("mineable/hoe");
|
||||
public static final TagLocation<Block> PICKAXE = new TagLocation<>("mineable/pickaxe");
|
||||
public static final TagLocation<Block> SHEARS = new TagLocation<>("fabric", "mineable/shears");
|
||||
public static final TagLocation<Block> SHOVEL = new TagLocation<>("mineable/shovel");
|
||||
public static final TagLocation<Block> SWORD = new TagLocation<>("fabric", "mineable/sword");
|
||||
public static final TagLocation<Block> HAMMER = new TagLocation<>("c", "mineable/hammer");
|
||||
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");
|
||||
}
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
package ru.bclib.api.tag;
|
||||
|
||||
import net.minecraft.tags.TagKey;
|
||||
import net.minecraft.world.item.Item;
|
||||
import ru.bclib.api.tag.TagAPI.TagLocation;
|
||||
|
||||
|
||||
public class NamedToolTags {
|
||||
public static final TagLocation<Item> FABRIC_AXES = new TagLocation<>("fabric", "axes");
|
||||
public static final TagLocation<Item> FABRIC_HOES = new TagLocation<>("fabric", "hoes");
|
||||
public static final TagLocation<Item> FABRIC_PICKAXES = new TagLocation<>("fabric", "pickaxes");
|
||||
public static final TagLocation<Item> FABRIC_SHEARS = new TagLocation<>("fabric", "shears");
|
||||
public static final TagLocation<Item> FABRIC_SHOVELS = new TagLocation<>("fabric", "shovels");
|
||||
public static final TagLocation<Item> FABRIC_SWORDS = new TagLocation<>("fabric", "swords");
|
||||
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");
|
||||
}
|
||||
|
|
|
@ -45,25 +45,6 @@ public class TagAPI {
|
|||
return (TagType.UnTyped<T>)TYPES.computeIfAbsent(directory, (dir)->new TagType.UnTyped<>(registry, dir));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Get or create {@link TagKey}.
|
||||
*
|
||||
* @param registry - {@link Registry<T>} tag collection;
|
||||
* @param id - {@link ResourceLocation} tag id.
|
||||
* @return {@link TagKey}.
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public static <T> TagKey<T> makeTag(Registry<T> registry, TagLocation<T> id) {
|
||||
return registry
|
||||
.getTagNames()
|
||||
.filter(tagKey -> tagKey.location().equals(id))
|
||||
.findAny()
|
||||
.orElse(TagKey.create(registry.key(), id));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get or create {@link Block} {@link TagKey} with mod namespace.
|
||||
*
|
||||
|
@ -157,26 +138,15 @@ public class TagAPI {
|
|||
|
||||
/**
|
||||
* Adds multiple Tags to one Biome.
|
||||
* @param tagIDs array of {@link TagLocation<Biome>} tag IDs.
|
||||
* @param tagIDs array of {@link TagKey<Biome>} tag IDs.
|
||||
* @param biome The {@link Biome} to add tag.
|
||||
*/
|
||||
@SafeVarargs
|
||||
@Deprecated(forRemoval = true)
|
||||
public static void addBiomeTags(Biome biome, TagLocation<Biome>... tagIDs) {
|
||||
public static void addBiomeTags(Biome biome, TagKey<Biome>... tagIDs) {
|
||||
BIOMES.add(biome, tagIDs);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds one Tag to multiple Biomes.
|
||||
* @param tagID {@link TagLocation<Biome>} tag ID.
|
||||
* @param biomes array of {@link Biome} to add into tag.
|
||||
*/
|
||||
|
||||
@Deprecated(forRemoval = true)
|
||||
public static void addBiomeTag(TagLocation<Biome> tagID, Biome... biomes) {
|
||||
BIOMES.add(tagID, biomes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds one Tag to multiple Biomes.
|
||||
* @param tagID {@link TagKey<Biome>} tag ID.
|
||||
|
@ -189,24 +159,15 @@ public class TagAPI {
|
|||
|
||||
/**
|
||||
* Adds multiple Tags to one Block.
|
||||
* @param tagIDs array of {@link TagLocation<Block>} tag IDs.
|
||||
* @param tagIDs array of {@link TagKey<Block>} tag IDs.
|
||||
* @param block The {@link Block} to add tag.
|
||||
*/
|
||||
@SafeVarargs
|
||||
@Deprecated(forRemoval = true)
|
||||
public static void addBlockTags(Block block, TagLocation<Block>... tagIDs) {
|
||||
public static void addBlockTags(Block block, TagKey<Block>... tagIDs) {
|
||||
BLOCKS.add(block, tagIDs);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds one Tag to multiple Blocks.
|
||||
* @param tagID {@link TagLocation<Block>} tag ID.
|
||||
* @param blocks array of {@link Block} to add into tag.
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public static void addBlockTag(TagLocation<Block> tagID, Block... blocks) {
|
||||
BLOCKS.add(tagID, blocks);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Adds one Tag to multiple Blocks.
|
||||
|
@ -219,36 +180,14 @@ public class TagAPI {
|
|||
|
||||
/**
|
||||
* Adds multiple Tags to one Item.
|
||||
* @param tagIDs array of {@link TagLocation<Item>} tag IDs.
|
||||
* @param tagIDs array of {@link TagKey<Item>} tag IDs.
|
||||
* @param item The {@link Item} to add tag.
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
@SafeVarargs
|
||||
public static void addItemTags(ItemLike item, TagLocation<Item>... tagIDs) {
|
||||
public static void addItemTags(ItemLike item, TagKey<Item>... tagIDs) {
|
||||
ITEMS.add(item.asItem(), tagIDs);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds one Tag to multiple Items.
|
||||
* @param tagID {@link TagLocation<Item>} tag ID.
|
||||
* @param items array of {@link ItemLike} to add into tag.
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public static void addItemTag(TagLocation<Item> tagID, Item... items) {
|
||||
ITEMS.add(tagID, items);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds one Tag to multiple Items.
|
||||
* @param tagID {@link TagLocation<Item>} tag ID.
|
||||
* @param items array of {@link ItemLike} to add into tag.
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public static void addItemTag(TagLocation<Item> tagID, ItemLike... items) {
|
||||
for(ItemLike i : items) {
|
||||
ITEMS.add(i.asItem(), tagID);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds one Tag to multiple Items.
|
||||
|
@ -317,40 +256,9 @@ public class TagAPI {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Extends (without changing) {@link ResourceLocation}. This Type was introduced to allow type-safe definition af
|
||||
* Tags using their ResourceLocation.
|
||||
* @param <T> The Type of the underlying {@link Tag}
|
||||
*/
|
||||
public static class TagLocation<T> extends ResourceLocation {
|
||||
public TagLocation(String string) {
|
||||
super(string);
|
||||
}
|
||||
|
||||
public TagLocation(String string, String string2) {
|
||||
super(string, string2);
|
||||
}
|
||||
|
||||
public TagLocation(ResourceLocation location) {
|
||||
super(location.getNamespace(), location.getPath());
|
||||
}
|
||||
|
||||
public static<R> TagLocation<R> of(TagKey<R> tag){
|
||||
return new TagLocation<R>(tag.location());
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isToolWithMineableTag(ItemStack stack, TagKey<Block> tag){
|
||||
return isToolWithUntypedMineableTag(stack, tag.location());
|
||||
}
|
||||
|
||||
public static boolean isToolWithMineableTag(ItemStack stack, TagLocation<Block> tag){
|
||||
return isToolWithUntypedMineableTag(stack, tag);
|
||||
}
|
||||
|
||||
private static boolean isToolWithUntypedMineableTag(ItemStack stack, ResourceLocation tag){
|
||||
if (stack.getItem() instanceof DiggerItemAccessor dig){
|
||||
return dig.bclib_getBlockTag().location().equals(tag);
|
||||
return dig.bclib_getBlockTag().equals(tag);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ 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.TagKey;
|
||||
import net.minecraft.util.StringRepresentable;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
@ -21,7 +22,7 @@ import net.minecraft.world.level.storage.loot.LootContext;
|
|||
import org.jetbrains.annotations.Nullable;
|
||||
import ru.bclib.api.tag.NamedBlockTags;
|
||||
import ru.bclib.api.tag.NamedItemTags;
|
||||
import ru.bclib.api.tag.TagAPI.TagLocation;
|
||||
|
||||
import ru.bclib.client.models.BasePatterns;
|
||||
import ru.bclib.client.models.ModelsHelper;
|
||||
import ru.bclib.client.models.PatternsHelper;
|
||||
|
@ -151,7 +152,7 @@ public class BaseDoorBlock extends DoorBlock implements RenderLayerProvider, Blo
|
|||
}
|
||||
|
||||
@Override
|
||||
public void addTags(List<TagLocation<Block>> blockTags, List<TagLocation<Item>> itemTags) {
|
||||
public void addTags(List<TagKey<Block>> blockTags, List<TagKey<Item>> itemTags) {
|
||||
blockTags.add(NamedBlockTags.DOORS);
|
||||
itemTags.add(NamedItemTags.DOORS);
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import com.google.common.collect.Lists;
|
|||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.tags.TagKey;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.enchantment.EnchantmentHelper;
|
||||
|
@ -18,7 +19,7 @@ import net.minecraft.world.level.storage.loot.LootContext;
|
|||
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
|
||||
import ru.bclib.api.tag.NamedBlockTags;
|
||||
import ru.bclib.api.tag.NamedItemTags;
|
||||
import ru.bclib.api.tag.TagAPI.TagLocation;
|
||||
|
||||
import ru.bclib.client.render.BCLRenderLayer;
|
||||
import ru.bclib.interfaces.BlockModelProvider;
|
||||
import ru.bclib.interfaces.RenderLayerProvider;
|
||||
|
@ -100,7 +101,7 @@ public class BaseLeavesBlock extends LeavesBlock implements BlockModelProvider,
|
|||
}
|
||||
|
||||
@Override
|
||||
public void addTags(List<TagLocation<Block>> blockTags, List<TagLocation<Item>> itemTags) {
|
||||
public void addTags(List<TagKey<Block>> blockTags, List<TagKey<Item>> itemTags) {
|
||||
blockTags.add(NamedBlockTags.LEAVES);
|
||||
itemTags.add(NamedItemTags.LEAVES);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package ru.bclib.blocks;
|
||||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
|
||||
import net.minecraft.tags.TagKey;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.SoundType;
|
||||
|
@ -9,7 +11,7 @@ import net.minecraft.world.level.material.Material;
|
|||
import net.minecraft.world.level.material.MaterialColor;
|
||||
import ru.bclib.api.tag.NamedBlockTags;
|
||||
import ru.bclib.api.tag.NamedItemTags;
|
||||
import ru.bclib.api.tag.TagAPI.TagLocation;
|
||||
|
||||
import ru.bclib.client.render.BCLRenderLayer;
|
||||
import ru.bclib.interfaces.RenderLayerProvider;
|
||||
import ru.bclib.interfaces.TagProvider;
|
||||
|
@ -58,7 +60,7 @@ public class SimpleLeavesBlock extends BaseBlockNotFull implements RenderLayerPr
|
|||
}
|
||||
|
||||
@Override
|
||||
public void addTags(List<TagLocation<Block>> blockTags, List<TagLocation<Item>> itemTags) {
|
||||
public void addTags(List<TagKey<Block>> blockTags, List<TagKey<Item>> itemTags) {
|
||||
blockTags.add(NamedBlockTags.LEAVES);
|
||||
itemTags.add(NamedItemTags.LEAVES);
|
||||
}
|
||||
|
|
|
@ -4,18 +4,15 @@ import net.fabricmc.fabric.api.item.v1.FabricItemSettings;
|
|||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.fabricmc.fabric.api.registry.FlammableBlockRegistry;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.tags.TagKey;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.material.MaterialColor;
|
||||
import ru.bclib.BCLib;
|
||||
import ru.bclib.api.tag.NamedBlockTags;
|
||||
import ru.bclib.api.tag.NamedCommonBlockTags;
|
||||
import ru.bclib.api.tag.NamedCommonItemTags;
|
||||
import ru.bclib.api.tag.NamedItemTags;
|
||||
import ru.bclib.api.tag.TagAPI;
|
||||
import ru.bclib.api.tag.TagAPI.TagLocation;
|
||||
import ru.bclib.api.tag.*;
|
||||
|
||||
import ru.bclib.blocks.BaseBarkBlock;
|
||||
import ru.bclib.blocks.BaseBarrelBlock;
|
||||
import ru.bclib.blocks.BaseBlock;
|
||||
|
@ -100,8 +97,8 @@ public class WoodenComplexMaterial extends ComplexMaterial {
|
|||
}
|
||||
|
||||
final protected void initBase(FabricBlockSettings blockSettings, FabricItemSettings itemSettings) {
|
||||
TagLocation<Block> tagBlockLog = TagLocation.of(getBlockTag(TAG_LOGS));
|
||||
TagLocation<Item> tagItemLog = TagLocation.of(getItemTag(TAG_LOGS));
|
||||
TagKey<Block> tagBlockLog = getBlockTag(TAG_LOGS);
|
||||
TagKey<Item> tagItemLog = getItemTag(TAG_LOGS);
|
||||
|
||||
addBlockEntry(
|
||||
new BlockEntry(BLOCK_STRIPPED_LOG, (complexMaterial, settings) -> new BaseRotatedPillarBlock(settings))
|
||||
|
@ -169,21 +166,21 @@ public class WoodenComplexMaterial extends ComplexMaterial {
|
|||
|
||||
final protected void initStorage(FabricBlockSettings blockSettings, FabricItemSettings itemSettings) {
|
||||
addBlockEntry(new BlockEntry(BLOCK_CHEST, (complexMaterial, settings) -> new BaseChestBlock(getBlock(BLOCK_PLANKS)))
|
||||
.setBlockTags(NamedCommonBlockTags.CHEST, NamedCommonBlockTags.WOODEN_CHEST)
|
||||
.setItemTags(NamedCommonItemTags.CHEST, NamedCommonItemTags.WOODEN_CHEST));
|
||||
.setBlockTags(CommonBlockTags.CHEST, CommonBlockTags.WOODEN_CHEST)
|
||||
.setItemTags(CommonItemTags.CHEST, CommonItemTags.WOODEN_CHEST));
|
||||
|
||||
addBlockEntry(new BlockEntry(BLOCK_BARREL, (complexMaterial, settings) -> new BaseBarrelBlock(getBlock(BLOCK_PLANKS)))
|
||||
.setBlockTags(NamedCommonBlockTags.BARREL, NamedCommonBlockTags.WOODEN_BARREL)
|
||||
.setItemTags(NamedCommonItemTags.BARREL, NamedCommonItemTags.WOODEN_BARREL));
|
||||
.setBlockTags(CommonBlockTags.BARREL, CommonBlockTags.WOODEN_BARREL)
|
||||
.setItemTags(CommonItemTags.BARREL, CommonItemTags.WOODEN_BARREL));
|
||||
}
|
||||
|
||||
final protected void initDecorations(FabricBlockSettings blockSettings, FabricItemSettings itemSettings) {
|
||||
addBlockEntry(new BlockEntry(BLOCK_CRAFTING_TABLE, (complexMaterial, settings) -> new BaseCraftingTableBlock(getBlock(BLOCK_PLANKS)))
|
||||
.setBlockTags(NamedCommonBlockTags.WORKBENCHES)
|
||||
.setItemTags(NamedCommonItemTags.WORKBENCHES));
|
||||
.setBlockTags(CommonBlockTags.WORKBENCHES)
|
||||
.setItemTags(CommonItemTags.WORKBENCHES));
|
||||
|
||||
addBlockEntry(new BlockEntry(BLOCK_BOOKSHELF, (complexMaterial, settings) -> new BaseBookshelfBlock(getBlock(BLOCK_PLANKS)))
|
||||
.setBlockTags(NamedCommonBlockTags.BOOKSHELVES));
|
||||
.setBlockTags(CommonBlockTags.BOOKSHELVES));
|
||||
|
||||
addBlockEntry(new BlockEntry(BLOCK_COMPOSTER, (complexMaterial, settings) -> new BaseComposterBlock(getBlock(BLOCK_PLANKS))));
|
||||
}
|
||||
|
|
|
@ -2,10 +2,11 @@ package ru.bclib.complexmaterials.entry;
|
|||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.tags.TagKey;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import ru.bclib.api.tag.TagAPI;
|
||||
import ru.bclib.api.tag.TagAPI.TagLocation;
|
||||
|
||||
import ru.bclib.complexmaterials.ComplexMaterial;
|
||||
import ru.bclib.registry.BlockRegistry;
|
||||
|
||||
|
@ -15,8 +16,8 @@ public class BlockEntry extends ComplexMaterialEntry {
|
|||
final BiFunction<ComplexMaterial, FabricBlockSettings, Block> initFunction;
|
||||
final boolean hasItem;
|
||||
|
||||
TagLocation<Block>[] blockTags;
|
||||
TagLocation<Item>[] itemTags;
|
||||
TagKey<Block>[] blockTags;
|
||||
TagKey<Item>[] itemTags;
|
||||
|
||||
public BlockEntry(String suffix, BiFunction<ComplexMaterial, FabricBlockSettings, Block> initFunction) {
|
||||
this(suffix, true, initFunction);
|
||||
|
@ -28,12 +29,12 @@ public class BlockEntry extends ComplexMaterialEntry {
|
|||
this.hasItem = hasItem;
|
||||
}
|
||||
|
||||
public BlockEntry setBlockTags(TagLocation<Block>... blockTags) {
|
||||
public BlockEntry setBlockTags(TagKey<Block>... blockTags) {
|
||||
this.blockTags = blockTags;
|
||||
return this;
|
||||
}
|
||||
|
||||
public BlockEntry setItemTags(TagLocation<Item>... itemTags) {
|
||||
public BlockEntry setItemTags(TagKey<Item>... itemTags) {
|
||||
this.itemTags = itemTags;
|
||||
return this;
|
||||
}
|
||||
|
|
|
@ -2,9 +2,10 @@ package ru.bclib.complexmaterials.entry;
|
|||
|
||||
import net.fabricmc.fabric.api.item.v1.FabricItemSettings;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.tags.TagKey;
|
||||
import net.minecraft.world.item.Item;
|
||||
import ru.bclib.api.tag.TagAPI;
|
||||
import ru.bclib.api.tag.TagAPI.TagLocation;
|
||||
|
||||
import ru.bclib.complexmaterials.ComplexMaterial;
|
||||
import ru.bclib.registry.ItemRegistry;
|
||||
|
||||
|
@ -13,14 +14,14 @@ import java.util.function.BiFunction;
|
|||
public class ItemEntry extends ComplexMaterialEntry {
|
||||
final BiFunction<ComplexMaterial, FabricItemSettings, Item> initFunction;
|
||||
|
||||
TagLocation<Item>[] itemTags;
|
||||
TagKey<Item>[] itemTags;
|
||||
|
||||
public ItemEntry(String suffix, BiFunction<ComplexMaterial, FabricItemSettings, Item> initFunction) {
|
||||
super(suffix);
|
||||
this.initFunction = initFunction;
|
||||
}
|
||||
|
||||
public ItemEntry setItemTags(TagLocation<Item>[] itemTags) {
|
||||
public ItemEntry setItemTags(TagKey<Item>[] itemTags) {
|
||||
this.itemTags = itemTags;
|
||||
return this;
|
||||
}
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
package ru.bclib.interfaces;
|
||||
|
||||
import ru.bclib.world.biomes.BCLBiome;
|
||||
import ru.bclib.world.generator.BiomePicker;
|
||||
|
||||
public interface BiomeChunk {
|
||||
void setBiome(int x, int z, BiomePicker.Entry biome);
|
||||
BiomePicker.Entry getBiome(int x, int z);
|
||||
void setBiome(int x, int z, BiomePicker.ActualBiome biome);
|
||||
BiomePicker.ActualBiome getBiome(int x, int z);
|
||||
int getSide();
|
||||
}
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
package ru.bclib.interfaces;
|
||||
|
||||
import ru.bclib.world.biomes.BCLBiome;
|
||||
import ru.bclib.world.generator.BiomePicker;
|
||||
|
||||
public interface BiomeMap {
|
||||
void setChunkProcessor(TriConsumer<Integer, Integer, Integer> processor);
|
||||
BiomeChunk getChunk(int cx, int cz, boolean update);
|
||||
BiomePicker.Entry getBiome(double x, double y, double z);
|
||||
BiomePicker.ActualBiome getBiome(double x, double y, double z);
|
||||
void clearCache();
|
||||
}
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
package ru.bclib.interfaces;
|
||||
|
||||
import net.minecraft.tags.TagKey;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import ru.bclib.api.tag.TagAPI.TagLocation;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface TagProvider {
|
||||
void addTags(List<TagLocation<Block>> blockTags, List<TagLocation<Item>> itemTags);
|
||||
void addTags(List<TagKey<Block>> blockTags, List<TagKey<Item>> itemTags);
|
||||
}
|
||||
|
|
|
@ -8,12 +8,8 @@ import net.minecraft.world.item.CreativeModeTab;
|
|||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import ru.bclib.api.tag.NamedBlockTags;
|
||||
import ru.bclib.api.tag.NamedCommonBlockTags;
|
||||
import ru.bclib.api.tag.NamedCommonItemTags;
|
||||
import ru.bclib.api.tag.NamedItemTags;
|
||||
import ru.bclib.api.tag.NamedMineableTags;
|
||||
import ru.bclib.api.tag.TagAPI;
|
||||
|
||||
import ru.bclib.api.tag.*;
|
||||
import ru.bclib.blocks.BaseLeavesBlock;
|
||||
import ru.bclib.blocks.BaseOreBlock;
|
||||
import ru.bclib.blocks.FeatureSaplingBlock;
|
||||
|
@ -48,21 +44,21 @@ public class BlockRegistry extends BaseRegistry<Block> {
|
|||
|
||||
if (block instanceof BaseLeavesBlock){
|
||||
TagAPI.addBlockTags(
|
||||
block,
|
||||
NamedBlockTags.LEAVES,
|
||||
NamedCommonBlockTags.LEAVES,
|
||||
NamedMineableTags.HOE,
|
||||
NamedMineableTags.SHEARS
|
||||
block,
|
||||
NamedBlockTags.LEAVES,
|
||||
CommonBlockTags.LEAVES,
|
||||
NamedMineableTags.HOE,
|
||||
NamedMineableTags.SHEARS
|
||||
);
|
||||
if (item != null){
|
||||
TagAPI.addItemTags(item, NamedCommonItemTags.LEAVES, NamedItemTags.LEAVES);
|
||||
TagAPI.addItemTags(item, CommonItemTags.LEAVES, NamedItemTags.LEAVES);
|
||||
}
|
||||
} else if (block instanceof BaseOreBlock){
|
||||
TagAPI.addBlockTags(block, NamedMineableTags.PICKAXE);
|
||||
} else if (block instanceof FeatureSaplingBlock){
|
||||
TagAPI.addBlockTags(block, NamedCommonBlockTags.SAPLINGS, NamedBlockTags.SAPLINGS);
|
||||
TagAPI.addBlockTags(block, CommonBlockTags.SAPLINGS, NamedBlockTags.SAPLINGS);
|
||||
if (item != null){
|
||||
TagAPI.addItemTags(item, NamedCommonItemTags.SAPLINGS, NamedItemTags.SAPLINGS);
|
||||
TagAPI.addItemTags(item, CommonItemTags.SAPLINGS, NamedItemTags.SAPLINGS);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,8 @@ import net.minecraft.world.item.ShovelItem;
|
|||
import net.minecraft.world.item.SpawnEggItem;
|
||||
import net.minecraft.world.item.SwordItem;
|
||||
import net.minecraft.world.level.block.DispenserBlock;
|
||||
import ru.bclib.api.tag.NamedCommonItemTags;
|
||||
|
||||
import ru.bclib.api.tag.CommonItemTags;
|
||||
import ru.bclib.api.tag.NamedToolTags;
|
||||
import ru.bclib.api.tag.TagAPI;
|
||||
import ru.bclib.config.PathConfig;
|
||||
|
@ -86,7 +87,7 @@ public class ItemRegistry extends BaseRegistry<Item> {
|
|||
TagAPI.addItemTag(NamedToolTags.FABRIC_HOES, item);
|
||||
}
|
||||
else if (item instanceof BaseShearsItem) {
|
||||
TagAPI.addItemTags(item, NamedToolTags.FABRIC_SHEARS, NamedCommonItemTags.SHEARS);
|
||||
TagAPI.addItemTags(item, NamedToolTags.FABRIC_SHEARS, CommonItemTags.SHEARS);
|
||||
DispenserBlock.registerBehavior(item.asItem(), new ShearsDispenseItemBehavior());
|
||||
}
|
||||
|
||||
|
|
|
@ -227,16 +227,16 @@ public class BCLibEndBiomeSource extends BCLBiomeSource {
|
|||
}
|
||||
|
||||
if (height < -10F) {
|
||||
return mapVoid.getBiome(posX, biomeY << 2, posZ).actual;
|
||||
return mapVoid.getBiome(posX, biomeY << 2, posZ).biome;
|
||||
} else {
|
||||
return mapLand.getBiome(posX, biomeY << 2, posZ).actual;
|
||||
return mapLand.getBiome(posX, biomeY << 2, posZ).biome;
|
||||
}
|
||||
} else {
|
||||
pos.setLocation(biomeX, biomeZ);
|
||||
if (endLandFunction.apply(pos)) {
|
||||
return dist <= farEndBiomes ? centerBiome : mapLand.getBiome(posX, biomeY << 2, posZ).actual;
|
||||
return dist <= farEndBiomes ? centerBiome : mapLand.getBiome(posX, biomeY << 2, posZ).biome;
|
||||
} else {
|
||||
return dist <= farEndBiomes ? barrens : mapVoid.getBiome(posX, biomeY << 2, posZ).actual;
|
||||
return dist <= farEndBiomes ? barrens : mapVoid.getBiome(posX, biomeY << 2, posZ).biome;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,16 +5,11 @@ import net.minecraft.core.Registry;
|
|||
import net.minecraft.resources.RegistryOps;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.tags.BiomeTags;
|
||||
import net.minecraft.util.ExtraCodecs;
|
||||
import net.minecraft.world.level.biome.*;
|
||||
|
||||
import net.fabricmc.fabric.impl.biome.NetherBiomeData;
|
||||
|
||||
import com.mojang.datafixers.kinds.Applicative;
|
||||
import com.mojang.datafixers.util.Either;
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.MapCodec;
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||
import org.apache.commons.lang3.function.TriFunction;
|
||||
import ru.bclib.BCLib;
|
||||
|
@ -28,7 +23,6 @@ import ru.bclib.world.generator.map.hex.HexBiomeMap;
|
|||
import ru.bclib.world.generator.map.square.SquareBiomeMap;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class BCLibNetherBiomeSource extends BCLBiomeSource {
|
||||
private static boolean forceLegacyGenerator = false;
|
||||
|
@ -149,8 +143,8 @@ public class BCLibNetherBiomeSource extends BCLBiomeSource {
|
|||
if ((biomeX & 63) == 0 && (biomeZ & 63) == 0) {
|
||||
biomeMap.clearCache();
|
||||
}
|
||||
BiomePicker.Entry bb = biomeMap.getBiome(biomeX << 2, biomeY << 2, biomeZ << 2);
|
||||
return bb.actual;
|
||||
BiomePicker.ActualBiome bb = biomeMap.getBiome(biomeX << 2, biomeY << 2, biomeZ << 2);
|
||||
return bb.biome;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,39 +1,37 @@
|
|||
package ru.bclib.world.generator;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
import ru.bclib.util.WeighTree;
|
||||
import ru.bclib.util.WeightedList;
|
||||
import ru.bclib.world.biomes.BCLBiome;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import net.minecraft.util.RandomSource;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.level.levelgen.WorldgenRandom;
|
||||
|
||||
public class BiomePicker {
|
||||
public final Map<BCLBiome, Entry> all = new HashMap<>();
|
||||
public class Entry {
|
||||
public final Map<BCLBiome, ActualBiome> all = new HashMap<>();
|
||||
public class ActualBiome {
|
||||
public final BCLBiome bclBiome;
|
||||
public final Holder<Biome> actual;
|
||||
public final Holder<Biome> biome;
|
||||
public final ResourceKey<Biome> key;
|
||||
|
||||
private final WeightedList<Entry> subbiomes = new WeightedList<>();
|
||||
private final Entry edge;
|
||||
private final Entry parent;
|
||||
private final WeightedList<ActualBiome> subbiomes = new WeightedList<>();
|
||||
private final ActualBiome edge;
|
||||
private final ActualBiome parent;
|
||||
|
||||
private Entry(BCLBiome bclBiome){
|
||||
private ActualBiome(BCLBiome bclBiome){
|
||||
all.put(bclBiome, this);
|
||||
this.bclBiome = bclBiome;
|
||||
|
||||
this.key = biomeRegistry.getResourceKey(biomeRegistry.get(bclBiome.getID())).orElseThrow();
|
||||
this.actual = biomeRegistry.getOrCreateHolder(key);
|
||||
this.biome = biomeRegistry.getOrCreateHolder(key);
|
||||
|
||||
bclBiome.forEachSubBiome((b, w)->{
|
||||
subbiomes.add(create(b), w);
|
||||
|
@ -47,7 +45,7 @@ public class BiomePicker {
|
|||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
Entry entry = (Entry) o;
|
||||
ActualBiome entry = (ActualBiome) o;
|
||||
return bclBiome.equals(entry.bclBiome);
|
||||
}
|
||||
|
||||
|
@ -56,32 +54,32 @@ public class BiomePicker {
|
|||
return Objects.hash(bclBiome);
|
||||
}
|
||||
|
||||
public Entry getSubBiome(WorldgenRandom random) {
|
||||
public ActualBiome getSubBiome(WorldgenRandom random) {
|
||||
return subbiomes.get(random);
|
||||
}
|
||||
|
||||
public Entry getEdge(){
|
||||
public ActualBiome getEdge(){
|
||||
return edge;
|
||||
}
|
||||
|
||||
public Entry getParentBiome(){
|
||||
public ActualBiome getParentBiome(){
|
||||
return parent;
|
||||
}
|
||||
|
||||
public boolean isSame(Entry e){
|
||||
public boolean isSame(ActualBiome e){
|
||||
return bclBiome.isSame(e.bclBiome);
|
||||
}
|
||||
}
|
||||
|
||||
private Entry create(BCLBiome bclBiome){
|
||||
Entry e = all.get(bclBiome);
|
||||
private ActualBiome create(BCLBiome bclBiome){
|
||||
ActualBiome e = all.get(bclBiome);
|
||||
if (e!=null) return e;
|
||||
return new Entry(bclBiome);
|
||||
return new ActualBiome(bclBiome);
|
||||
}
|
||||
|
||||
private final List<Entry> biomes = Lists.newArrayList();
|
||||
private final List<ActualBiome> biomes = Lists.newArrayList();
|
||||
public final Registry<Biome> biomeRegistry;
|
||||
private WeighTree<Entry> tree;
|
||||
private WeighTree<ActualBiome> tree;
|
||||
|
||||
public BiomePicker(Registry<Biome> biomeRegistry){
|
||||
this.biomeRegistry = biomeRegistry;
|
||||
|
@ -91,7 +89,7 @@ public class BiomePicker {
|
|||
biomes.add(create(biome));
|
||||
}
|
||||
|
||||
public Entry getBiome(WorldgenRandom random) {
|
||||
public ActualBiome getBiome(WorldgenRandom random) {
|
||||
return biomes.isEmpty() ? null : tree.get(random);
|
||||
}
|
||||
|
||||
|
@ -99,7 +97,7 @@ public class BiomePicker {
|
|||
if (biomes.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
WeightedList<Entry> list = new WeightedList<>();
|
||||
WeightedList<ActualBiome> list = new WeightedList<>();
|
||||
biomes.forEach(biome -> {
|
||||
list.add(biome, biome.bclBiome.getGenChance());
|
||||
});
|
||||
|
|
|
@ -6,10 +6,9 @@ import ru.bclib.interfaces.BiomeChunk;
|
|||
import ru.bclib.interfaces.BiomeMap;
|
||||
import ru.bclib.interfaces.TriConsumer;
|
||||
import ru.bclib.noise.OpenSimplexNoise;
|
||||
import ru.bclib.world.biomes.BCLBiome;
|
||||
import ru.bclib.world.generator.BiomePicker;
|
||||
|
||||
import java.util.Random;import net.minecraft.util.RandomSource;
|
||||
import java.util.Random;
|
||||
|
||||
public class MapStack implements BiomeMap {
|
||||
private final OpenSimplexNoise noise;
|
||||
|
@ -52,7 +51,7 @@ public class MapStack implements BiomeMap {
|
|||
}
|
||||
|
||||
@Override
|
||||
public BiomePicker.Entry getBiome(double x, double y, double z) {
|
||||
public BiomePicker.ActualBiome getBiome(double x, double y, double z) {
|
||||
int mapIndex;
|
||||
|
||||
if (y < minValue) {
|
||||
|
@ -70,7 +69,7 @@ public class MapStack implements BiomeMap {
|
|||
}
|
||||
|
||||
private void onChunkCreation(int cx, int cz, int side) {
|
||||
BiomePicker.Entry[][] biomeMap = new BiomePicker.Entry[side][side];
|
||||
BiomePicker.ActualBiome[][] biomeMap = new BiomePicker.ActualBiome[side][side];
|
||||
BiomeChunk[] chunks = new BiomeChunk[maps.length];
|
||||
|
||||
boolean isNoEmpty = false;
|
||||
|
@ -79,7 +78,7 @@ public class MapStack implements BiomeMap {
|
|||
for (int x = 0; x < side; x++) {
|
||||
for (int z = 0; z < side; z++) {
|
||||
if (biomeMap[x][z] == null) {
|
||||
BiomePicker.Entry biome = chunks[i].getBiome(x, z);
|
||||
BiomePicker.ActualBiome biome = chunks[i].getBiome(x, z);
|
||||
if (biome.bclBiome.isVertical()) {
|
||||
biomeMap[x][z] = biome;
|
||||
isNoEmpty = true;
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
package ru.bclib.world.generator.map.hex;
|
||||
|
||||
import ru.bclib.interfaces.BiomeChunk;
|
||||
import ru.bclib.world.biomes.BCLBiome;
|
||||
import ru.bclib.world.generator.BiomePicker;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Random;import net.minecraft.util.RandomSource;
|
||||
|
||||
import net.minecraft.world.level.levelgen.WorldgenRandom;
|
||||
|
||||
public class HexBiomeChunk implements BiomeChunk {
|
||||
|
@ -21,12 +20,12 @@ public class HexBiomeChunk implements BiomeChunk {
|
|||
private static final byte SIDE_PRE_OFFSET = (byte) Math.round(Math.log(SIDE_PRE) / Math.log(2));
|
||||
private static final short[][] NEIGHBOURS;
|
||||
|
||||
private final BiomePicker.Entry[] biomes = new BiomePicker.Entry[SIZE];
|
||||
private final BiomePicker.ActualBiome[] biomes = new BiomePicker.ActualBiome[SIZE];
|
||||
|
||||
public HexBiomeChunk(WorldgenRandom random, BiomePicker picker) {
|
||||
BiomePicker.Entry[][] buffers = new BiomePicker.Entry[2][SIZE];
|
||||
BiomePicker.ActualBiome[][] buffers = new BiomePicker.ActualBiome[2][SIZE];
|
||||
|
||||
for (BiomePicker.Entry[] buffer: buffers) {
|
||||
for (BiomePicker.ActualBiome[] buffer: buffers) {
|
||||
Arrays.fill(buffer, null);
|
||||
}
|
||||
|
||||
|
@ -41,9 +40,9 @@ public class HexBiomeChunk implements BiomeChunk {
|
|||
boolean hasEmptyCells = true;
|
||||
byte bufferIndex = 0;
|
||||
while (hasEmptyCells) {
|
||||
BiomePicker.Entry[] inBuffer = buffers[bufferIndex];
|
||||
BiomePicker.ActualBiome[] inBuffer = buffers[bufferIndex];
|
||||
bufferIndex = (byte) ((bufferIndex + 1) & 1);
|
||||
BiomePicker.Entry[] outBuffer = buffers[bufferIndex];
|
||||
BiomePicker.ActualBiome[] outBuffer = buffers[bufferIndex];
|
||||
hasEmptyCells = false;
|
||||
|
||||
for (short index = SIDE; index < MAX_SIDE; index++) {
|
||||
|
@ -65,7 +64,7 @@ public class HexBiomeChunk implements BiomeChunk {
|
|||
}
|
||||
}
|
||||
|
||||
BiomePicker.Entry[] outBuffer = buffers[bufferIndex];
|
||||
BiomePicker.ActualBiome[] outBuffer = buffers[bufferIndex];
|
||||
byte preN = (byte) (SIDE_MASK - 2);
|
||||
for (byte index = 0; index < SIDE; index++) {
|
||||
outBuffer[getIndex(index, (byte) 0)] = outBuffer[getIndex(index, (byte) 2)];
|
||||
|
@ -86,7 +85,7 @@ public class HexBiomeChunk implements BiomeChunk {
|
|||
System.arraycopy(outBuffer, 0, this.biomes, 0, SIZE);
|
||||
}
|
||||
|
||||
private void circle(BiomePicker.Entry[] buffer, short center, BiomePicker.Entry biome, BiomePicker.Entry mask) {
|
||||
private void circle(BiomePicker.ActualBiome[] buffer, short center, BiomePicker.ActualBiome biome, BiomePicker.ActualBiome mask) {
|
||||
if (buffer[center] == mask) {
|
||||
buffer[center] = biome;
|
||||
}
|
||||
|
@ -108,12 +107,12 @@ public class HexBiomeChunk implements BiomeChunk {
|
|||
}
|
||||
|
||||
@Override
|
||||
public BiomePicker.Entry getBiome(int x, int z) {
|
||||
public BiomePicker.ActualBiome getBiome(int x, int z) {
|
||||
return biomes[getIndex(wrap(x), wrap(z))];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBiome(int x, int z, BiomePicker.Entry biome) {
|
||||
public void setBiome(int x, int z, BiomePicker.ActualBiome biome) {
|
||||
biomes[getIndex(wrap(x), wrap(z))] = biome;
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@ import ru.bclib.interfaces.BiomeMap;
|
|||
import ru.bclib.interfaces.TriConsumer;
|
||||
import ru.bclib.noise.OpenSimplexNoise;
|
||||
import ru.bclib.util.MHelper;
|
||||
import ru.bclib.world.biomes.BCLBiome;
|
||||
import ru.bclib.world.generator.BiomePicker;
|
||||
|
||||
import java.util.Map;
|
||||
|
@ -50,9 +49,9 @@ public class HexBiomeMap implements BiomeMap {
|
|||
}
|
||||
|
||||
@Override
|
||||
public BiomePicker.Entry getBiome(double x, double y, double z) {
|
||||
BiomePicker.Entry biome = getRawBiome(x, z);
|
||||
BiomePicker.Entry edge = biome.getEdge();
|
||||
public BiomePicker.ActualBiome getBiome(double x, double y, double z) {
|
||||
BiomePicker.ActualBiome biome = getRawBiome(x, z);
|
||||
BiomePicker.ActualBiome edge = biome.getEdge();
|
||||
int size = biome.bclBiome.getEdgeSize();
|
||||
|
||||
if (edge == null && biome.getParentBiome() != null) {
|
||||
|
@ -93,7 +92,7 @@ public class HexBiomeMap implements BiomeMap {
|
|||
this.processor = processor;
|
||||
}
|
||||
|
||||
private BiomePicker.Entry getRawBiome(double x, double z) {
|
||||
private BiomePicker.ActualBiome getRawBiome(double x, double z) {
|
||||
double px = x / scale * RAD_INNER;
|
||||
double pz = z / scale;
|
||||
double dx = rotateX(px, pz);
|
||||
|
@ -132,7 +131,7 @@ public class HexBiomeMap implements BiomeMap {
|
|||
return getChunkBiome(cellX, cellZ);
|
||||
}
|
||||
|
||||
private BiomePicker.Entry getChunkBiome(int x, int z) {
|
||||
private BiomePicker.ActualBiome getChunkBiome(int x, int z) {
|
||||
int cx = HexBiomeChunk.scaleCoordinate(x);
|
||||
int cz = HexBiomeChunk.scaleCoordinate(z);
|
||||
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
package ru.bclib.world.generator.map.square;
|
||||
|
||||
import ru.bclib.interfaces.BiomeChunk;
|
||||
import ru.bclib.world.biomes.BCLBiome;
|
||||
import ru.bclib.world.generator.BiomePicker;
|
||||
|
||||
import java.util.Random;import net.minecraft.util.RandomSource;
|
||||
import net.minecraft.world.level.levelgen.WorldgenRandom;
|
||||
|
||||
public class SquareBiomeChunk implements BiomeChunk {
|
||||
|
@ -18,11 +16,11 @@ public class SquareBiomeChunk implements BiomeChunk {
|
|||
private static final int SM_CAPACITY = SM_WIDTH * SM_WIDTH;
|
||||
private static final int CAPACITY = WIDTH * WIDTH;
|
||||
|
||||
private final BiomePicker.Entry[] biomes;
|
||||
private final BiomePicker.ActualBiome[] biomes;
|
||||
|
||||
public SquareBiomeChunk(WorldgenRandom random, BiomePicker picker) {
|
||||
BiomePicker.Entry[] PreBio = new BiomePicker.Entry[SM_CAPACITY];
|
||||
biomes = new BiomePicker.Entry[CAPACITY];
|
||||
BiomePicker.ActualBiome[] PreBio = new BiomePicker.ActualBiome[SM_CAPACITY];
|
||||
biomes = new BiomePicker.ActualBiome[CAPACITY];
|
||||
|
||||
for (int x = 0; x < SM_WIDTH; x++) {
|
||||
int offset = x << SM_BIT_OFFSET;
|
||||
|
@ -40,12 +38,12 @@ public class SquareBiomeChunk implements BiomeChunk {
|
|||
}
|
||||
|
||||
@Override
|
||||
public BiomePicker.Entry getBiome(int x, int z) {
|
||||
public BiomePicker.ActualBiome getBiome(int x, int z) {
|
||||
return biomes[getIndex(x & MASK_WIDTH, z & MASK_WIDTH)];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBiome(int x, int z, BiomePicker.Entry biome) {
|
||||
public void setBiome(int x, int z, BiomePicker.ActualBiome biome) {
|
||||
biomes[getIndex(x & MASK_WIDTH, z & MASK_WIDTH)] = biome;
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,6 @@ import ru.bclib.interfaces.BiomeMap;
|
|||
import ru.bclib.interfaces.TriConsumer;
|
||||
import ru.bclib.noise.OpenSimplexNoise;
|
||||
import ru.bclib.util.MHelper;
|
||||
import ru.bclib.world.biomes.BCLBiome;
|
||||
import ru.bclib.world.generator.BiomePicker;
|
||||
|
||||
import java.util.Map;
|
||||
|
@ -45,11 +44,11 @@ public class SquareBiomeMap implements BiomeMap {
|
|||
}
|
||||
|
||||
@Override
|
||||
public BiomePicker.Entry getBiome(double x, double y, double z) {
|
||||
BiomePicker.Entry biome = getRawBiome(x, z);
|
||||
public BiomePicker.ActualBiome getBiome(double x, double y, double z) {
|
||||
BiomePicker.ActualBiome biome = getRawBiome(x, z);
|
||||
|
||||
if (biome.getEdge() != null || (biome.getParentBiome() != null && biome.getParentBiome().getEdge() != null)) {
|
||||
BiomePicker.Entry search = biome;
|
||||
BiomePicker.ActualBiome search = biome;
|
||||
if (biome.getParentBiome() != null) {
|
||||
search = biome.getParentBiome();
|
||||
}
|
||||
|
@ -96,7 +95,7 @@ public class SquareBiomeMap implements BiomeMap {
|
|||
return chunk;
|
||||
}
|
||||
|
||||
private BiomePicker.Entry getRawBiome(double bx, double bz) {
|
||||
private BiomePicker.ActualBiome getRawBiome(double bx, double bz) {
|
||||
double x = bx * size / sizeXZ;
|
||||
double z = bz * size / sizeXZ;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue