Update TagHelper.java
This commit is contained in:
parent
81edbacc12
commit
50d42c1218
1 changed files with 4 additions and 12 deletions
|
@ -12,16 +12,12 @@ import com.google.common.collect.Maps;
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
|
|
||||||
public class TagHelper {
|
public class TagHelper {
|
||||||
private static final Map<ResourceLocation, Set<ResourceLocation>> TAGS_BLOCK = Maps.newHashMap();
|
private static final Map<ResourceLocation, Set<ResourceLocation>> TAGS_BLOCK = Maps.newConcurrentMap();
|
||||||
private static final Map<ResourceLocation, Set<ResourceLocation>> TAGS_ITEM = Maps.newHashMap();
|
private static final Map<ResourceLocation, Set<ResourceLocation>> TAGS_ITEM = Maps.newConcurrentMap();
|
||||||
|
|
||||||
public static void addTag(Tag.Named<Block> tag, Block... blocks) {
|
public static void addTag(Tag.Named<Block> tag, Block... blocks) {
|
||||||
ResourceLocation tagID = tag.getName();
|
ResourceLocation tagID = tag.getName();
|
||||||
Set<ResourceLocation> set = TAGS_BLOCK.get(tagID);
|
Set<ResourceLocation> set = TAGS_BLOCK.computeIfAbsent(tagID, k -> Sets.newHashSet());
|
||||||
if (set == null) {
|
|
||||||
set = Sets.newHashSet();
|
|
||||||
TAGS_BLOCK.put(tagID, set);
|
|
||||||
}
|
|
||||||
for (Block block: blocks) {
|
for (Block block: blocks) {
|
||||||
ResourceLocation id = Registry.BLOCK.getKey(block);
|
ResourceLocation id = Registry.BLOCK.getKey(block);
|
||||||
if (id != Registry.BLOCK.getDefaultKey()) {
|
if (id != Registry.BLOCK.getDefaultKey()) {
|
||||||
|
@ -32,11 +28,7 @@ public class TagHelper {
|
||||||
|
|
||||||
public static void addTag(Tag.Named<Item> tag, ItemLike... items) {
|
public static void addTag(Tag.Named<Item> tag, ItemLike... items) {
|
||||||
ResourceLocation tagID = tag.getName();
|
ResourceLocation tagID = tag.getName();
|
||||||
Set<ResourceLocation> set = TAGS_ITEM.get(tagID);
|
Set<ResourceLocation> set = TAGS_ITEM.computeIfAbsent(tagID, k -> Sets.newHashSet());
|
||||||
if (set == null) {
|
|
||||||
set = Sets.newHashSet();
|
|
||||||
TAGS_ITEM.put(tagID, set);
|
|
||||||
}
|
|
||||||
for (ItemLike item: items) {
|
for (ItemLike item: items) {
|
||||||
ResourceLocation id = Registry.ITEM.getKey(item.asItem());
|
ResourceLocation id = Registry.ITEM.getKey(item.asItem());
|
||||||
if (id != Registry.ITEM.getDefaultKey()) {
|
if (id != Registry.ITEM.getDefaultKey()) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue