diff --git a/src/main/java/ru/bclib/api/PostInitAPI.java b/src/main/java/ru/bclib/api/PostInitAPI.java index 4e8c4644..fa3aa7f7 100644 --- a/src/main/java/ru/bclib/api/PostInitAPI.java +++ b/src/main/java/ru/bclib/api/PostInitAPI.java @@ -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> postInitFunctions = Lists.newArrayList(); - private static List> blockTags = Lists.newArrayList(); - private static List> itemTags = Lists.newArrayList(); + private static List> blockTags = Lists.newArrayList(); + private static List> itemTags = Lists.newArrayList(); /** * Register a new function which will be called after all mods are initiated. Will be called on both client and server. diff --git a/src/main/java/ru/bclib/api/tag/CommonBlockTags.java b/src/main/java/ru/bclib/api/tag/CommonBlockTags.java index 6fb30a7d..25b8a388 100644 --- a/src/main/java/ru/bclib/api/tag/CommonBlockTags.java +++ b/src/main/java/ru/bclib/api/tag/CommonBlockTags.java @@ -21,5 +21,7 @@ public class CommonBlockTags { public static final TagKey WOODEN_CHEST = TagAPI.makeCommonBlockTag("wooden_chests"); public static final TagKey WORKBENCHES = TagAPI.makeCommonBlockTag("workbench"); + public static final TagKey DRAGON_IMMUNE = TagAPI.makeCommonBlockTag("dragon_immune"); + public static final TagKey MINABLE_WITH_HAMMER = TagAPI.makeCommonBlockTag("mineable/hammer"); } diff --git a/src/main/java/ru/bclib/api/tag/NamedBlockTags.java b/src/main/java/ru/bclib/api/tag/NamedBlockTags.java index 5dc301d7..d7a3779a 100644 --- a/src/main/java/ru/bclib/api/tag/NamedBlockTags.java +++ b/src/main/java/ru/bclib/api/tag/NamedBlockTags.java @@ -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 ANVIL = new TagLocation<>("anvil"); - public static final TagLocation BUTTONS = new TagLocation<>("buttons"); - public static final TagLocation CLIMBABLE = new TagLocation<>("climbable"); - public static final TagLocation DOORS = new TagLocation<>("doors"); - public static final TagLocation FENCES = new TagLocation<>("fences"); - public static final TagLocation FENCE_GATES = new TagLocation<>("fence_gates"); - public static final TagLocation LEAVES = new TagLocation<>("leaves"); - public static final TagLocation LOGS = new TagLocation<>("logs"); - public static final TagLocation LOGS_THAT_BURN = new TagLocation<>("logs_that_burn"); - public static final TagLocation NYLIUM = new TagLocation<>("nylium"); - public static final TagLocation PLANKS = new TagLocation<>("planks"); - public static final TagLocation PRESSURE_PLATES = new TagLocation<>("pressure_plates"); - public static final TagLocation SAPLINGS = new TagLocation<>("saplings"); - public static final TagLocation SIGNS = new TagLocation<>("signs"); - public static final TagLocation SLABS = new TagLocation<>("slabs"); - public static final TagLocation STAIRS = new TagLocation<>("stairs"); - public static final TagLocation STONE_PRESSURE_PLATES = new TagLocation<>("stone_pressure_plates"); - public static final TagLocation TRAPDOORS = new TagLocation<>("trapdoors"); - public static final TagLocation WALLS = new TagLocation<>("walls"); - public static final TagLocation WOODEN_BUTTONS = new TagLocation<>("wooden_buttons"); - public static final TagLocation WOODEN_DOORS = new TagLocation<>("wooden_doors"); - public static final TagLocation WOODEN_FENCES = new TagLocation<>("wooden_fences"); - public static final TagLocation WOODEN_PRESSURE_PLATES = new TagLocation<>("wooden_pressure_plates"); - public static final TagLocation WOODEN_SLABS = new TagLocation<>("wooden_slabs"); - public static final TagLocation WOODEN_STAIRS = new TagLocation<>("wooden_stairs"); - public static final TagLocation WOODEN_TRAPDOORS = new TagLocation<>("wooden_trapdoors"); - public static final TagLocation SOUL_FIRE_BASE_BLOCKS = new TagLocation<>("soul_fire_base_blocks"); - public static final TagLocation SOUL_SPEED_BLOCKS = new TagLocation<>("soul_speed_blocks"); - public static final TagLocation BEACON_BASE_BLOCKS = new TagLocation<>("beacon_base_blocks"); - public static final TagLocation STONE_BRICKS = new TagLocation("stone_bricks"); + public static final TagKey ANVIL = BlockTags.ANVIL; + public static final TagKey BUTTONS = BlockTags.BUTTONS; + public static final TagKey CLIMBABLE = BlockTags.CLIMBABLE; + public static final TagKey DOORS = BlockTags.DOORS; + public static final TagKey FENCES = BlockTags.FENCES; + public static final TagKey FENCE_GATES = BlockTags.FENCE_GATES; + public static final TagKey LEAVES = BlockTags.LEAVES; + public static final TagKey LOGS = BlockTags.LOGS; + public static final TagKey LOGS_THAT_BURN = BlockTags.LOGS_THAT_BURN; + public static final TagKey NYLIUM = BlockTags.NYLIUM; + public static final TagKey PLANKS = BlockTags.PLANKS; + public static final TagKey PRESSURE_PLATES = BlockTags.PRESSURE_PLATES; + public static final TagKey SAPLINGS = BlockTags.SAPLINGS; + public static final TagKey SIGNS = BlockTags.SIGNS; + public static final TagKey SLABS = BlockTags.SLABS; + public static final TagKey STAIRS = BlockTags.STAIRS; + public static final TagKey STONE_PRESSURE_PLATES = BlockTags.STONE_PRESSURE_PLATES; + public static final TagKey TRAPDOORS = BlockTags.TRAPDOORS; + public static final TagKey WALLS = BlockTags.WALLS; + public static final TagKey WOODEN_BUTTONS = BlockTags.WOODEN_BUTTONS; + public static final TagKey WOODEN_DOORS = BlockTags.WOODEN_DOORS; + public static final TagKey WOODEN_FENCES = BlockTags.WOODEN_FENCES; + public static final TagKey WOODEN_PRESSURE_PLATES = BlockTags.WOODEN_PRESSURE_PLATES; + public static final TagKey WOODEN_SLABS = BlockTags.WOODEN_SLABS; + public static final TagKey WOODEN_STAIRS = BlockTags.WOODEN_STAIRS; + public static final TagKey WOODEN_TRAPDOORS = BlockTags.WOODEN_TRAPDOORS; + public static final TagKey SOUL_FIRE_BASE_BLOCKS = BlockTags.SOUL_FIRE_BASE_BLOCKS; + public static final TagKey SOUL_SPEED_BLOCKS = BlockTags.SOUL_SPEED_BLOCKS; + public static final TagKey BEACON_BASE_BLOCKS = BlockTags.BEACON_BASE_BLOCKS; + public static final TagKey STONE_BRICKS = BlockTags.STONE_BRICKS; } diff --git a/src/main/java/ru/bclib/api/tag/NamedCommonBlockTags.java b/src/main/java/ru/bclib/api/tag/NamedCommonBlockTags.java deleted file mode 100644 index 8640cea1..00000000 --- a/src/main/java/ru/bclib/api/tag/NamedCommonBlockTags.java +++ /dev/null @@ -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 BARREL = new TagLocation<>("c", "barrel"); - public static final TagLocation BOOKSHELVES = new TagLocation<>("c", "bookshelves"); - public static final TagLocation CHEST = new TagLocation<>("c", "chest"); - public static final TagLocation END_STONES = new TagLocation<>("c", "end_stones"); - public static final TagLocation GEN_END_STONES = END_STONES; - public static final TagLocation IMMOBILE = new TagLocation<>("c", "immobile"); - public static final TagLocation LEAVES = new TagLocation<>("c", "leaves"); - public static final TagLocation NETHERRACK = new TagLocation<>("c", "netherrack"); - public static final TagLocation NETHER_MYCELIUM = new TagLocation<>("c", "nether_mycelium"); - public static final TagLocation NETHER_PORTAL_FRAME = new TagLocation<>("c", "nether_pframe"); - public static final TagLocation NETHER_STONES = new TagLocation<>("c", "nether_stones"); - public static final TagLocation SAPLINGS = new TagLocation<>("c", "saplings"); - public static final TagLocation SOUL_GROUND = new TagLocation<>("c", "soul_ground"); - public static final TagLocation WOODEN_BARREL = new TagLocation<>("c", "wooden_barrels"); - public static final TagLocation WOODEN_CHEST = new TagLocation<>("c", "wooden_chests"); - public static final TagLocation WORKBENCHES = new TagLocation<>("c", "workbench"); - public static final TagLocation DRAGON_IMMUNE = new TagLocation<>("c", "dragon_immune"); -} diff --git a/src/main/java/ru/bclib/api/tag/NamedCommonItemTags.java b/src/main/java/ru/bclib/api/tag/NamedCommonItemTags.java deleted file mode 100644 index ddb52cfb..00000000 --- a/src/main/java/ru/bclib/api/tag/NamedCommonItemTags.java +++ /dev/null @@ -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 BARREL = new TagLocation<>("c", "barrel"); - public static final TagLocation CHEST = new TagLocation<>("c", "chest"); - public static final TagLocation FURNACES = new TagLocation<>("c", "furnaces"); - public static final TagLocation HAMMERS = new TagLocation<>("c", "hammers"); - public static final TagLocation IRON_INGOTS = new TagLocation<>("c", "iron_ingots"); - public static final TagLocation LEAVES = new TagLocation<>("c", "leaves"); - public static final TagLocation SAPLINGS = new TagLocation<>("c", "saplings"); - public static final TagLocation SHEARS = new TagLocation<>("c", "shears"); - public static final TagLocation SOUL_GROUND = new TagLocation<>("c", "soul_ground"); - public static final TagLocation WOODEN_BARREL = new TagLocation<>("c", "wooden_barrels"); - public static final TagLocation WOODEN_CHEST = new TagLocation<>("c", "wooden_chests"); - public static final TagLocation WORKBENCHES = new TagLocation<>("c", "workbench"); -} diff --git a/src/main/java/ru/bclib/api/tag/NamedItemTags.java b/src/main/java/ru/bclib/api/tag/NamedItemTags.java index 5790458b..6dabcbca 100644 --- a/src/main/java/ru/bclib/api/tag/NamedItemTags.java +++ b/src/main/java/ru/bclib/api/tag/NamedItemTags.java @@ -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 BUTTONS = new TagLocation<>("buttons"); - public static final TagLocation DOORS = new TagLocation<>("doors"); - public static final TagLocation FENCES = new TagLocation<>("fences"); - public static final TagLocation FENCE_GATES = new TagLocation<>("fence_gates"); - public static final TagLocation LEAVES = new TagLocation<>("leaves"); - public static final TagLocation LOGS = new TagLocation<>("logs"); - public static final TagLocation LOGS_THAT_BURN = new TagLocation<>("logs_that_burn"); - public static final TagLocation PLANKS = new TagLocation<>("planks"); - public static final TagLocation PRESSURE_PLATES = new TagLocation<>("pressure_plates"); - public static final TagLocation SAPLINGS = new TagLocation<>("saplings"); - public static final TagLocation SHEARS = new TagLocation<>("shears"); - public static final TagLocation SIGNS = new TagLocation<>("signs"); - public static final TagLocation SLABS = new TagLocation<>("slabs"); - public static final TagLocation STAIRS = new TagLocation<>("stairs"); - public static final TagLocation STONE_PRESSURE_PLATES = new TagLocation<>("stone_pressure_plates"); - public static final TagLocation TRAPDOORS = new TagLocation<>("trapdoors"); - public static final TagLocation WOODEN_BUTTONS = new TagLocation<>("wooden_buttons"); - public static final TagLocation WOODEN_DOORS = new TagLocation<>("wooden_doors"); - public static final TagLocation WOODEN_FENCES = new TagLocation<>("wooden_fences"); - public static final TagLocation WOODEN_PRESSURE_PLATES = new TagLocation<>("wooden_pressure_plates"); - public static final TagLocation WOODEN_SLABS = new TagLocation<>("wooden_slabs"); - public static final TagLocation WOODEN_STAIRS = new TagLocation<>("wooden_stairs"); - public static final TagLocation WOODEN_TRAPDOORS = new TagLocation<>("wooden_trapdoors"); - public static final TagLocation BEACON_PAYMENT_ITEMS = new TagLocation<>("beacon_payment_items"); - public static final TagLocation STONE_BRICKS = new TagLocation<>("stone_bricks"); - public static final TagLocation STONE_CRAFTING_MATERIALS = new TagLocation<>("stone_crafting_materials"); - public static final TagLocation STONE_TOOL_MATERIALS = new TagLocation<>("stone_tool_materials"); + public static final TagKey BUTTONS = ItemTags.BUTTONS; + public static final TagKey DOORS = ItemTags.DOORS; + public static final TagKey FENCES = ItemTags.FENCES; + public static final TagKey LEAVES = ItemTags.LEAVES; + public static final TagKey LOGS = ItemTags.LOGS; + public static final TagKey LOGS_THAT_BURN = ItemTags.LOGS_THAT_BURN; + public static final TagKey PLANKS = ItemTags.PLANKS; + public static final TagKey SAPLINGS = ItemTags.SAPLINGS; + public static final TagKey SIGNS = ItemTags.SIGNS; + public static final TagKey SLABS = ItemTags.SLABS; + public static final TagKey STAIRS = ItemTags.STAIRS; + public static final TagKey TRAPDOORS = ItemTags.TRAPDOORS; + public static final TagKey WOODEN_BUTTONS = ItemTags.WOODEN_BUTTONS; + public static final TagKey WOODEN_DOORS = ItemTags.WOODEN_DOORS; + public static final TagKey WOODEN_FENCES = ItemTags.WOODEN_FENCES; + public static final TagKey WOODEN_PRESSURE_PLATES = ItemTags.WOODEN_PRESSURE_PLATES; + public static final TagKey WOODEN_SLABS = ItemTags.WOODEN_SLABS; + public static final TagKey WOODEN_STAIRS = ItemTags.WOODEN_STAIRS; + public static final TagKey WOODEN_TRAPDOORS = ItemTags.WOODEN_TRAPDOORS; + public static final TagKey BEACON_PAYMENT_ITEMS = ItemTags.BEACON_PAYMENT_ITEMS; + public static final TagKey STONE_BRICKS = ItemTags.STONE_BRICKS; + public static final TagKey STONE_CRAFTING_MATERIALS = ItemTags.STONE_CRAFTING_MATERIALS; + public static final TagKey STONE_TOOL_MATERIALS = ItemTags.STONE_TOOL_MATERIALS; } diff --git a/src/main/java/ru/bclib/api/tag/NamedMineableTags.java b/src/main/java/ru/bclib/api/tag/NamedMineableTags.java index b78e0a16..2d36faa8 100644 --- a/src/main/java/ru/bclib/api/tag/NamedMineableTags.java +++ b/src/main/java/ru/bclib/api/tag/NamedMineableTags.java @@ -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 AXE = new TagLocation<>("mineable/axe"); - public static final TagLocation HOE = new TagLocation<>("mineable/hoe"); - public static final TagLocation PICKAXE = new TagLocation<>("mineable/pickaxe"); - public static final TagLocation SHEARS = new TagLocation<>("fabric", "mineable/shears"); - public static final TagLocation SHOVEL = new TagLocation<>("mineable/shovel"); - public static final TagLocation SWORD = new TagLocation<>("fabric", "mineable/sword"); - public static final TagLocation HAMMER = new TagLocation<>("c", "mineable/hammer"); + public static final TagKey AXE = BlockTags.MINEABLE_WITH_AXE; + public static final TagKey HOE = BlockTags.MINEABLE_WITH_HOE; + public static final TagKey PICKAXE = BlockTags.MINEABLE_WITH_PICKAXE; + public static final TagKey SHEARS = TagAPI.makeBlockTag("fabric", "mineable/shears"); + public static final TagKey SHOVEL = BlockTags.MINEABLE_WITH_SHOVEL; + public static final TagKey SWORD = TagAPI.makeBlockTag("fabric", "mineable/sword"); + public static final TagKey HAMMER = TagAPI.makeCommonBlockTag( "mineable/hammer"); } diff --git a/src/main/java/ru/bclib/api/tag/NamedToolTags.java b/src/main/java/ru/bclib/api/tag/NamedToolTags.java index 349f81e5..a16d840b 100644 --- a/src/main/java/ru/bclib/api/tag/NamedToolTags.java +++ b/src/main/java/ru/bclib/api/tag/NamedToolTags.java @@ -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 FABRIC_AXES = new TagLocation<>("fabric", "axes"); - public static final TagLocation FABRIC_HOES = new TagLocation<>("fabric", "hoes"); - public static final TagLocation FABRIC_PICKAXES = new TagLocation<>("fabric", "pickaxes"); - public static final TagLocation FABRIC_SHEARS = new TagLocation<>("fabric", "shears"); - public static final TagLocation FABRIC_SHOVELS = new TagLocation<>("fabric", "shovels"); - public static final TagLocation FABRIC_SWORDS = new TagLocation<>("fabric", "swords"); + public static final TagKey FABRIC_AXES = TagAPI.makeItemTag("fabric", "axes"); + public static final TagKey FABRIC_HOES = TagAPI.makeItemTag("fabric", "hoes"); + public static final TagKey FABRIC_PICKAXES = TagAPI.makeItemTag("fabric", "pickaxes"); + public static final TagKey FABRIC_SHEARS = TagAPI.makeItemTag("fabric", "shears"); + public static final TagKey FABRIC_SHOVELS = TagAPI.makeItemTag("fabric", "shovels"); + public static final TagKey FABRIC_SWORDS = TagAPI.makeItemTag("fabric", "swords"); } diff --git a/src/main/java/ru/bclib/api/tag/TagAPI.java b/src/main/java/ru/bclib/api/tag/TagAPI.java index ad0667df..2fd4ceac 100644 --- a/src/main/java/ru/bclib/api/tag/TagAPI.java +++ b/src/main/java/ru/bclib/api/tag/TagAPI.java @@ -45,25 +45,6 @@ public class TagAPI { return (TagType.UnTyped)TYPES.computeIfAbsent(directory, (dir)->new TagType.UnTyped<>(registry, dir)); } - - - - /** - * Get or create {@link TagKey}. - * - * @param registry - {@link Registry} tag collection; - * @param id - {@link ResourceLocation} tag id. - * @return {@link TagKey}. - */ - @Deprecated(forRemoval = true) - public static TagKey makeTag(Registry registry, TagLocation 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} tag IDs. + * @param tagIDs array of {@link TagKey} tag IDs. * @param biome The {@link Biome} to add tag. */ @SafeVarargs @Deprecated(forRemoval = true) - public static void addBiomeTags(Biome biome, TagLocation... tagIDs) { + public static void addBiomeTags(Biome biome, TagKey... tagIDs) { BIOMES.add(biome, tagIDs); } - /** - * Adds one Tag to multiple Biomes. - * @param tagID {@link TagLocation} tag ID. - * @param biomes array of {@link Biome} to add into tag. - */ - - @Deprecated(forRemoval = true) - public static void addBiomeTag(TagLocation tagID, Biome... biomes) { - BIOMES.add(tagID, biomes); - } - /** * Adds one Tag to multiple Biomes. * @param tagID {@link TagKey} tag ID. @@ -189,24 +159,15 @@ public class TagAPI { /** * Adds multiple Tags to one Block. - * @param tagIDs array of {@link TagLocation} tag IDs. + * @param tagIDs array of {@link TagKey} tag IDs. * @param block The {@link Block} to add tag. */ @SafeVarargs @Deprecated(forRemoval = true) - public static void addBlockTags(Block block, TagLocation... tagIDs) { + public static void addBlockTags(Block block, TagKey... tagIDs) { BLOCKS.add(block, tagIDs); } - - /** - * Adds one Tag to multiple Blocks. - * @param tagID {@link TagLocation} tag ID. - * @param blocks array of {@link Block} to add into tag. - */ - @Deprecated(forRemoval = true) - public static void addBlockTag(TagLocation 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} tag IDs. + * @param tagIDs array of {@link TagKey} tag IDs. * @param item The {@link Item} to add tag. */ @Deprecated(forRemoval = true) @SafeVarargs - public static void addItemTags(ItemLike item, TagLocation... tagIDs) { + public static void addItemTags(ItemLike item, TagKey... tagIDs) { ITEMS.add(item.asItem(), tagIDs); } - - /** - * Adds one Tag to multiple Items. - * @param tagID {@link TagLocation} tag ID. - * @param items array of {@link ItemLike} to add into tag. - */ - @Deprecated(forRemoval = true) - public static void addItemTag(TagLocation tagID, Item... items) { - ITEMS.add(tagID, items); - } - - /** - * Adds one Tag to multiple Items. - * @param tagID {@link TagLocation} tag ID. - * @param items array of {@link ItemLike} to add into tag. - */ - @Deprecated(forRemoval = true) - public static void addItemTag(TagLocation 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 The Type of the underlying {@link Tag} - */ - public static class TagLocation 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 TagLocation of(TagKey tag){ - return new TagLocation(tag.location()); - } - } - public static boolean isToolWithMineableTag(ItemStack stack, TagKey tag){ - return isToolWithUntypedMineableTag(stack, tag.location()); - } - - public static boolean isToolWithMineableTag(ItemStack stack, TagLocation 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; } diff --git a/src/main/java/ru/bclib/blocks/BaseDoorBlock.java b/src/main/java/ru/bclib/blocks/BaseDoorBlock.java index 6c8609e2..96c7be13 100644 --- a/src/main/java/ru/bclib/blocks/BaseDoorBlock.java +++ b/src/main/java/ru/bclib/blocks/BaseDoorBlock.java @@ -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> blockTags, List> itemTags) { + public void addTags(List> blockTags, List> itemTags) { blockTags.add(NamedBlockTags.DOORS); itemTags.add(NamedItemTags.DOORS); } diff --git a/src/main/java/ru/bclib/blocks/BaseLeavesBlock.java b/src/main/java/ru/bclib/blocks/BaseLeavesBlock.java index 12b2e2b6..493513ce 100644 --- a/src/main/java/ru/bclib/blocks/BaseLeavesBlock.java +++ b/src/main/java/ru/bclib/blocks/BaseLeavesBlock.java @@ -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> blockTags, List> itemTags) { + public void addTags(List> blockTags, List> itemTags) { blockTags.add(NamedBlockTags.LEAVES); itemTags.add(NamedItemTags.LEAVES); } diff --git a/src/main/java/ru/bclib/blocks/SimpleLeavesBlock.java b/src/main/java/ru/bclib/blocks/SimpleLeavesBlock.java index 50ffe3df..f5cf201e 100644 --- a/src/main/java/ru/bclib/blocks/SimpleLeavesBlock.java +++ b/src/main/java/ru/bclib/blocks/SimpleLeavesBlock.java @@ -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> blockTags, List> itemTags) { + public void addTags(List> blockTags, List> itemTags) { blockTags.add(NamedBlockTags.LEAVES); itemTags.add(NamedItemTags.LEAVES); } diff --git a/src/main/java/ru/bclib/complexmaterials/WoodenComplexMaterial.java b/src/main/java/ru/bclib/complexmaterials/WoodenComplexMaterial.java index 0cb232b2..710478a9 100644 --- a/src/main/java/ru/bclib/complexmaterials/WoodenComplexMaterial.java +++ b/src/main/java/ru/bclib/complexmaterials/WoodenComplexMaterial.java @@ -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 tagBlockLog = TagLocation.of(getBlockTag(TAG_LOGS)); - TagLocation tagItemLog = TagLocation.of(getItemTag(TAG_LOGS)); + TagKey tagBlockLog = getBlockTag(TAG_LOGS); + TagKey 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)))); } diff --git a/src/main/java/ru/bclib/complexmaterials/entry/BlockEntry.java b/src/main/java/ru/bclib/complexmaterials/entry/BlockEntry.java index e168ab3f..3cb3a37b 100644 --- a/src/main/java/ru/bclib/complexmaterials/entry/BlockEntry.java +++ b/src/main/java/ru/bclib/complexmaterials/entry/BlockEntry.java @@ -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 initFunction; final boolean hasItem; - TagLocation[] blockTags; - TagLocation[] itemTags; + TagKey[] blockTags; + TagKey[] itemTags; public BlockEntry(String suffix, BiFunction initFunction) { this(suffix, true, initFunction); @@ -28,12 +29,12 @@ public class BlockEntry extends ComplexMaterialEntry { this.hasItem = hasItem; } - public BlockEntry setBlockTags(TagLocation... blockTags) { + public BlockEntry setBlockTags(TagKey... blockTags) { this.blockTags = blockTags; return this; } - public BlockEntry setItemTags(TagLocation... itemTags) { + public BlockEntry setItemTags(TagKey... itemTags) { this.itemTags = itemTags; return this; } diff --git a/src/main/java/ru/bclib/complexmaterials/entry/ItemEntry.java b/src/main/java/ru/bclib/complexmaterials/entry/ItemEntry.java index e5beff4e..d1c92289 100644 --- a/src/main/java/ru/bclib/complexmaterials/entry/ItemEntry.java +++ b/src/main/java/ru/bclib/complexmaterials/entry/ItemEntry.java @@ -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 initFunction; - TagLocation[] itemTags; + TagKey[] itemTags; public ItemEntry(String suffix, BiFunction initFunction) { super(suffix); this.initFunction = initFunction; } - public ItemEntry setItemTags(TagLocation[] itemTags) { + public ItemEntry setItemTags(TagKey[] itemTags) { this.itemTags = itemTags; return this; } diff --git a/src/main/java/ru/bclib/interfaces/BiomeChunk.java b/src/main/java/ru/bclib/interfaces/BiomeChunk.java index 04f77174..e0848f06 100644 --- a/src/main/java/ru/bclib/interfaces/BiomeChunk.java +++ b/src/main/java/ru/bclib/interfaces/BiomeChunk.java @@ -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(); } diff --git a/src/main/java/ru/bclib/interfaces/BiomeMap.java b/src/main/java/ru/bclib/interfaces/BiomeMap.java index 786e21cd..b2ededd6 100644 --- a/src/main/java/ru/bclib/interfaces/BiomeMap.java +++ b/src/main/java/ru/bclib/interfaces/BiomeMap.java @@ -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 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(); } diff --git a/src/main/java/ru/bclib/interfaces/TagProvider.java b/src/main/java/ru/bclib/interfaces/TagProvider.java index 24d38380..7072308d 100644 --- a/src/main/java/ru/bclib/interfaces/TagProvider.java +++ b/src/main/java/ru/bclib/interfaces/TagProvider.java @@ -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> blockTags, List> itemTags); + void addTags(List> blockTags, List> itemTags); } diff --git a/src/main/java/ru/bclib/registry/BlockRegistry.java b/src/main/java/ru/bclib/registry/BlockRegistry.java index a349a046..4c56bab8 100644 --- a/src/main/java/ru/bclib/registry/BlockRegistry.java +++ b/src/main/java/ru/bclib/registry/BlockRegistry.java @@ -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 { 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); } } diff --git a/src/main/java/ru/bclib/registry/ItemRegistry.java b/src/main/java/ru/bclib/registry/ItemRegistry.java index 8652b471..480a72f7 100644 --- a/src/main/java/ru/bclib/registry/ItemRegistry.java +++ b/src/main/java/ru/bclib/registry/ItemRegistry.java @@ -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 { 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()); } diff --git a/src/main/java/ru/bclib/world/generator/BCLibEndBiomeSource.java b/src/main/java/ru/bclib/world/generator/BCLibEndBiomeSource.java index 37403f2c..ea45802b 100644 --- a/src/main/java/ru/bclib/world/generator/BCLibEndBiomeSource.java +++ b/src/main/java/ru/bclib/world/generator/BCLibEndBiomeSource.java @@ -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; } } } diff --git a/src/main/java/ru/bclib/world/generator/BCLibNetherBiomeSource.java b/src/main/java/ru/bclib/world/generator/BCLibNetherBiomeSource.java index 95f95484..0af0e2e4 100644 --- a/src/main/java/ru/bclib/world/generator/BCLibNetherBiomeSource.java +++ b/src/main/java/ru/bclib/world/generator/BCLibNetherBiomeSource.java @@ -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 diff --git a/src/main/java/ru/bclib/world/generator/BiomePicker.java b/src/main/java/ru/bclib/world/generator/BiomePicker.java index 92681944..9a4c62f6 100644 --- a/src/main/java/ru/bclib/world/generator/BiomePicker.java +++ b/src/main/java/ru/bclib/world/generator/BiomePicker.java @@ -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 all = new HashMap<>(); - public class Entry { + public final Map all = new HashMap<>(); + public class ActualBiome { public final BCLBiome bclBiome; - public final Holder actual; + public final Holder biome; public final ResourceKey key; - private final WeightedList subbiomes = new WeightedList<>(); - private final Entry edge; - private final Entry parent; + private final WeightedList 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 biomes = Lists.newArrayList(); + private final List biomes = Lists.newArrayList(); public final Registry biomeRegistry; - private WeighTree tree; + private WeighTree tree; public BiomePicker(Registry 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 list = new WeightedList<>(); + WeightedList list = new WeightedList<>(); biomes.forEach(biome -> { list.add(biome, biome.bclBiome.getGenChance()); }); diff --git a/src/main/java/ru/bclib/world/generator/map/MapStack.java b/src/main/java/ru/bclib/world/generator/map/MapStack.java index 981a6fed..1cec112b 100644 --- a/src/main/java/ru/bclib/world/generator/map/MapStack.java +++ b/src/main/java/ru/bclib/world/generator/map/MapStack.java @@ -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; diff --git a/src/main/java/ru/bclib/world/generator/map/hex/HexBiomeChunk.java b/src/main/java/ru/bclib/world/generator/map/hex/HexBiomeChunk.java index 02533e28..c9cf1bbb 100644 --- a/src/main/java/ru/bclib/world/generator/map/hex/HexBiomeChunk.java +++ b/src/main/java/ru/bclib/world/generator/map/hex/HexBiomeChunk.java @@ -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; } diff --git a/src/main/java/ru/bclib/world/generator/map/hex/HexBiomeMap.java b/src/main/java/ru/bclib/world/generator/map/hex/HexBiomeMap.java index b277abba..6e80dc78 100644 --- a/src/main/java/ru/bclib/world/generator/map/hex/HexBiomeMap.java +++ b/src/main/java/ru/bclib/world/generator/map/hex/HexBiomeMap.java @@ -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); diff --git a/src/main/java/ru/bclib/world/generator/map/square/SquareBiomeChunk.java b/src/main/java/ru/bclib/world/generator/map/square/SquareBiomeChunk.java index 58a7ca55..a7757a7b 100644 --- a/src/main/java/ru/bclib/world/generator/map/square/SquareBiomeChunk.java +++ b/src/main/java/ru/bclib/world/generator/map/square/SquareBiomeChunk.java @@ -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; } diff --git a/src/main/java/ru/bclib/world/generator/map/square/SquareBiomeMap.java b/src/main/java/ru/bclib/world/generator/map/square/SquareBiomeMap.java index dba3d729..8aea90b9 100644 --- a/src/main/java/ru/bclib/world/generator/map/square/SquareBiomeMap.java +++ b/src/main/java/ru/bclib/world/generator/map/square/SquareBiomeMap.java @@ -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;