Stalagmite Placement

This commit is contained in:
Frank 2022-05-29 23:25:54 +02:00
parent abe18ae923
commit 5272861140
3 changed files with 46 additions and 19 deletions

View file

@ -1,5 +1,6 @@
package org.betterx.bclib.api.tag;
import net.minecraft.tags.BlockTags;
import net.minecraft.tags.TagKey;
import net.minecraft.world.level.block.Block;
@ -26,4 +27,16 @@ public class CommonBlockTags {
public static final TagKey<Block> MINABLE_WITH_HAMMER = TagAPI.makeCommonBlockTag("mineable/hammer");
public static final TagKey<Block> IS_OBSIDIAN = TagAPI.makeCommonBlockTag("is_obsidian");
public static final TagKey<Block> STALAGMITE_REPLACEABLE = TagAPI.makeCommonBlockTag("stalagmite_replaceable_blocks");
static {
TagAPI.BLOCKS.addOtherTags(STALAGMITE_REPLACEABLE,
BlockTags.DRIPSTONE_REPLACEABLE,
BlockTags.BASE_STONE_NETHER,
BlockTags.BASE_STONE_OVERWORLD,
NETHER_STONES,
SOUL_GROUND,
NETHER_MYCELIUM,
END_STONES);
}
}

View file

@ -29,8 +29,8 @@ public class TagAPI {
public static TagType.RegistryBacked<Block> BLOCKS = registerType(Registry.BLOCK);
public static TagType.RegistryBacked<Item> ITEMS = registerType(Registry.ITEM);
public static TagType.Simple<Biome> BIOMES = registerType(Registry.BIOME_REGISTRY,
"tags/worldgen/biome",
b -> BiomeAPI.getBiomeID(b));
"tags/worldgen/biome",
b -> BiomeAPI.getBiomeID(b));
public static <T> TagType.RegistryBacked<T> registerType(DefaultedRegistry<T> registry) {
TagType<T> type = new TagType.RegistryBacked<>(registry);
@ -45,9 +45,9 @@ public class TagAPI {
String directory,
Function<T, ResourceLocation> locationProvider) {
return (TagType.Simple<T>) TYPES.computeIfAbsent(directory,
(dir) -> new TagType.Simple<>(registry,
dir,
locationProvider));
(dir) -> new TagType.Simple<>(registry,
dir,
locationProvider));
}
public static <T> TagType.UnTyped<T> registerType(ResourceKey<? extends Registry<T>> registry, String directory) {
@ -240,19 +240,6 @@ public class TagAPI {
if (type != null) {
type.apply(tagsMap);
}
// final BiConsumer<ResourceLocation, Set<ResourceLocation>> consumer;
// consumer = (id, ids) -> apply(tagsMap.computeIfAbsent(id, key -> Tag.Builder.tag()), ids);
//
// if ("tags/blocks".equals(directory)) {
// TAGS_BLOCK.forEach(consumer);
// }
// else if ("tags/items".equals(directory)) {
// TAGS_ITEM.forEach(consumer);
// }
// else if ("tags/worldgen/biome".equals(directory)) {
// TAGS_BIOME.forEach(consumer);
// }
return tagsMap;
}

View file

@ -39,7 +39,7 @@ public class TagType<T> {
}
return null;
}
);
);
this.registry = registry;
}
@ -147,6 +147,33 @@ public class TagType<T> {
}
}
public void addOtherTags(TagKey<T> tagID, TagKey<T>... tags) {
if (isFrozen) BCLib.LOGGER.warning("Adding Tag " + tagID + " after the API was frozen.");
Set<ResourceLocation> set = getSetForTag(tagID);
for (TagKey<T> tag : tags) {
ResourceLocation id = tag.location();
if (id != null) {
set.add(id);
}
}
}
/**
* Adds one Tag to multiple Elements.
*
* @param tagID {@link TagKey< Biome >} tag ID.
* @param locations array of Elements to add into tag.
*/
protected void addUnchecked(TagKey<T> tagID, ResourceLocation... locations) {
if (isFrozen) BCLib.LOGGER.warning("Adding Tag " + tagID + " after the API was frozen.");
Set<ResourceLocation> set = getSetForTag(tagID);
for (ResourceLocation id : locations) {
if (id != null) {
set.add(id);
}
}
}
/**
* Adds one Tag to multiple Elements.
*