Sort Custom Presets to Front

This commit is contained in:
Frank 2022-05-20 01:59:30 +02:00
parent fdc068f6bb
commit 9f8409ebe0
7 changed files with 90 additions and 43 deletions

View file

@ -5,7 +5,6 @@ import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.packs.resources.ResourceManager;
import net.minecraft.tags.TagEntry;
import net.minecraft.tags.TagKey;
import net.minecraft.tags.TagLoader;
import net.minecraft.world.item.Item;
@ -17,13 +16,11 @@ import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import com.google.common.collect.Maps;
import org.betterx.bclib.BCLib;
import org.betterx.bclib.api.biomes.BiomeAPI;
import org.betterx.bclib.mixin.common.DiggerItemAccessor;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.function.Function;
public class TagAPI {
@ -259,19 +256,6 @@ public class TagAPI {
return tagsMap;
}
/**
* Adds all {@code ids} to the {@code builder}.
*
* @param builder
* @param ids
* @return The Builder passed as {@code builder}.
*/
public static List<TagLoader.EntryWithSource> apply(List<TagLoader.EntryWithSource> builder,
Set<ResourceLocation> ids) {
ids.forEach(value -> builder.add(new TagLoader.EntryWithSource(TagEntry.element(value), BCLib.MOD_ID)));
return builder;
}
public static boolean isToolWithMineableTag(ItemStack stack, TagKey<Block> tag) {
if (stack.getItem() instanceof DiggerItemAccessor dig) {

View file

@ -4,6 +4,7 @@ import net.minecraft.core.DefaultedRegistry;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.TagEntry;
import net.minecraft.tags.TagKey;
import net.minecraft.tags.TagLoader;
import net.minecraft.tags.TagManager;
@ -196,6 +197,12 @@ public class TagType<T> {
if (Registry.BIOME_REGISTRY.equals(registryKey)) BiomeAPI._runTagAdders();
//this.isFrozen = true;
this.forEach((id, ids) -> TagAPI.apply(tagsMap.computeIfAbsent(id, key -> Lists.newArrayList()), ids));
this.forEach((id, ids) -> apply(tagsMap.computeIfAbsent(id, key -> Lists.newArrayList()), ids));
}
private static List<TagLoader.EntryWithSource> apply(List<TagLoader.EntryWithSource> builder,
Set<ResourceLocation> ids) {
ids.forEach(value -> builder.add(new TagLoader.EntryWithSource(TagEntry.element(value), BCLib.MOD_ID)));
return builder;
}
}