Code style fix & version update

This commit is contained in:
paulevsGitch 2021-07-19 21:41:07 +03:00
parent 6266b30088
commit 179ada3296
20 changed files with 392 additions and 427 deletions

View file

@ -8,7 +8,7 @@ yarn_mappings= 6
loader_version= 0.11.6 loader_version= 0.11.6
# Mod Properties # Mod Properties
mod_version = 0.2.4 mod_version = 0.2.5
maven_group = ru.bclib maven_group = ru.bclib
archives_base_name = bclib archives_base_name = bclib

View file

@ -1,5 +1,17 @@
package ru.bclib.api; package ru.bclib.api;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListTag;
import net.minecraft.nbt.NbtIo;
import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.chunk.storage.RegionFile;
import org.jetbrains.annotations.NotNull;
import ru.bclib.BCLib;
import ru.bclib.config.Configs;
import ru.bclib.config.PathConfig;
import ru.bclib.config.SessionConfig;
import ru.bclib.util.Logger;
import java.io.DataInputStream; import java.io.DataInputStream;
import java.io.DataOutputStream; import java.io.DataOutputStream;
import java.io.File; import java.io.File;
@ -12,278 +24,259 @@ import java.util.Set;
import java.util.function.Supplier; import java.util.function.Supplier;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import org.jetbrains.annotations.NotNull;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListTag;
import net.minecraft.nbt.NbtIo;
import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.chunk.storage.RegionFile;
import ru.bclib.BCLib;
import ru.bclib.config.Configs;
import ru.bclib.config.PathConfig;
import ru.bclib.config.SessionConfig;
import ru.bclib.util.Logger;
public class DataFixerAPI2 { public class DataFixerAPI2 {
private static final Logger LOGGER = new Logger("DataFixerAPI"); private static final Logger LOGGER = new Logger("DataFixerAPI");
public static void fixData(SessionConfig config) { public static void fixData(SessionConfig config) {
if (true || !Configs.MAIN_CONFIG.getBoolean(Configs.MAIN_PATCH_CATEGORY, "applyPatches", true)){ if (true || !Configs.MAIN_CONFIG.getBoolean(Configs.MAIN_PATCH_CATEGORY, "applyPatches", true)) {
LOGGER.info("World Patches are disabled"); LOGGER.info("World Patches are disabled");
return; return;
} }
final File dir = config.levelFolder; final File dir = config.levelFolder;
Patch.MigrationData data = Patch.createMigrationData(config); Patch.MigrationData data = Patch.createMigrationData(config);
if (!data.hasAnyFixes()) { if (!data.hasAnyFixes()) {
LOGGER.info("Everything up to date"); LOGGER.info("Everything up to date");
return; return;
} }
List<File> regions = getAllRegions(dir, null); List<File> regions = getAllRegions(dir, null);
regions.parallelStream().forEach((file) -> { regions.parallelStream().forEach((file) -> {
try { try {
LOGGER.info("Inspecting " + file); LOGGER.info("Inspecting " + file);
boolean[] changed = new boolean[1]; boolean[] changed = new boolean[1];
RegionFile region = new RegionFile(file, file.getParentFile(), true); RegionFile region = new RegionFile(file, file.getParentFile(), true);
for (int x = 0; x < 32; x++) { for (int x = 0; x < 32; x++) {
for (int z = 0; z < 32; z++) { for (int z = 0; z < 32; z++) {
ChunkPos pos = new ChunkPos(x, z); ChunkPos pos = new ChunkPos(x, z);
changed[0] = false; changed[0] = false;
if (region.hasChunk(pos)) { if (region.hasChunk(pos)) {
DataInputStream input = region.getChunkDataInputStream(pos); DataInputStream input = region.getChunkDataInputStream(pos);
CompoundTag root = NbtIo.read(input); CompoundTag root = NbtIo.read(input);
// if ((root.toString().contains("betternether") || root.toString().contains("bclib")) && root.toString().contains("chest")) { // if ((root.toString().contains("betternether") || root.toString().contains("bclib")) && root.toString().contains("chest")) {
// NbtIo.write(root, new File(file.toString() + "-" + x + "-" + z + ".nbt")); // NbtIo.write(root, new File(file.toString() + "-" + x + "-" + z + ".nbt"));
// } // }
input.close(); input.close();
ListTag tileEntities = root.getCompound("Level").getList("TileEntities", 10); ListTag tileEntities = root.getCompound("Level").getList("TileEntities", 10);
fixItemArrayWithID(tileEntities, changed, data, true); fixItemArrayWithID(tileEntities, changed, data, true);
ListTag sections = root.getCompound("Level").getList("Sections", 10); ListTag sections = root.getCompound("Level").getList("Sections", 10);
sections.forEach((tag) -> { sections.forEach((tag) -> {
ListTag palette = ((CompoundTag) tag).getList("Palette", 10); ListTag palette = ((CompoundTag) tag).getList("Palette", 10);
palette.forEach((blockTag) -> { palette.forEach((blockTag) -> {
CompoundTag blockTagCompound = ((CompoundTag) blockTag); CompoundTag blockTagCompound = ((CompoundTag) blockTag);
changed[0] = data.replaceStringFromIDs(blockTagCompound, "Name"); changed[0] = data.replaceStringFromIDs(blockTagCompound, "Name");
}); });
}); });
if (changed[0]) { if (changed[0]) {
LOGGER.warning("Writing '{}': {}/{}", file, x, z); LOGGER.warning("Writing '{}': {}/{}", file, x, z);
DataOutputStream output = region.getChunkDataOutputStream(pos); DataOutputStream output = region.getChunkDataOutputStream(pos);
NbtIo.write(root, output); NbtIo.write(root, output);
output.close(); output.close();
} }
} }
} }
} }
region.close(); region.close();
} }
catch (Exception e) { catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
}); });
data.markApplied(); data.markApplied();
} }
private static boolean fixItemArrayWithID(ListTag items, boolean[] changed, Patch.MigrationData data, boolean recursive){ private static boolean fixItemArrayWithID(ListTag items, boolean[] changed, Patch.MigrationData data, boolean recursive) {
items.forEach(inTag -> { items.forEach(inTag -> {
final CompoundTag tag = (CompoundTag) inTag; final CompoundTag tag = (CompoundTag) inTag;
changed[0] |= data.replaceStringFromIDs(tag, "id"); changed[0] |= data.replaceStringFromIDs(tag, "id");
if (recursive && tag.contains("Items")){ if (recursive && tag.contains("Items")) {
changed[0] |= fixItemArrayWithID(tag.getList("Items", 10), changed, data, true); changed[0] |= fixItemArrayWithID(tag.getList("Items", 10), changed, data, true);
} }
}); });
return changed[0]; return changed[0];
} }
private static List<File> getAllRegions(File dir, List<File> list) { private static List<File> getAllRegions(File dir, List<File> list) {
if (list == null) { if (list == null) {
list = new ArrayList<>(); list = new ArrayList<>();
} }
for (File file : dir.listFiles()) { for (File file : dir.listFiles()) {
if (file.isDirectory()) { if (file.isDirectory()) {
getAllRegions(file, list); getAllRegions(file, list);
} }
else if (file.isFile() && file.getName().endsWith(".mca")) { else if (file.isFile() && file.getName().endsWith(".mca")) {
list.add(file); list.add(file);
} }
} }
return list; return list;
} }
public abstract static class Patch { public abstract static class Patch {
private static List<Patch> ALL = new ArrayList<>(10); private static List<Patch> ALL = new ArrayList<>(10);
private final int level; private final int level;
@NotNull @NotNull
private final String modID; private final String modID;
static List<Patch> getALL() { static List<Patch> getALL() {
return ALL; return ALL;
} }
/** /**
* register a new Patch * register a new Patch
* @param patch A #Supplier that will instantiate the new Patch Object *
*/ * @param patch A #Supplier that will instantiate the new Patch Object
public static void registerPatch(Supplier<Patch> patch){ */
ALL.add(patch.get()); public static void registerPatch(Supplier<Patch> patch) {
} ALL.add(patch.get());
}
/**
* Returns the highest patch-level that is available for the given mod. If no patches were /**
* registerd for the mod, this will return 0 * Returns the highest patch-level that is available for the given mod. If no patches were
* @param modID The ID of the mod you want to query * registerd for the mod, this will return 0
* @return The highest Patch-Level that was found *
*/ * @param modID The ID of the mod you want to query
public static int maxPatchLevel(@NotNull String modID){ * @return The highest Patch-Level that was found
return ALL.stream() */
.filter(p-> p.getModID().equals(modID)) public static int maxPatchLevel(@NotNull String modID) {
.mapToInt(p->p.level) return ALL.stream().filter(p -> p.getModID().equals(modID)).mapToInt(p -> p.level).max().orElse(0);
.max() }
.orElse(0);
} /**
* Called by inheriting classes.
/** * <p>
* Called by inheriting classes. * Performs some sanity checks on the values and might throw a #RuntimeException if any
* * inconsistencies are found.
* Performs some sanity checks on the values and might throw a #RuntimeException if any *
* inconsistencies are found. * @param modID The ID of the Mod you want to register a patch for. This should be your
* * ModID only. The ModID can not be {@code null} or an empty String.
* @param modID The ID of the Mod you want to register a patch for. This should be your * @param level The level of the Patch. This needs to be a non-zero positive value.
* ModID only. The ModID can not be {@code null} or an empty String. * Developers are responsible for registering their patches in the correct
* @param level The level of the Patch. This needs to be a non-zero positive value. * order (with increasing levels). You are not allowed to register a new
* Developers are responsible for registering their patches in the correct * Patch with a Patch-level lower or equal than
* order (with increasing levels). You are not allowed to register a new * {@link Patch#maxPatchLevel(String)}
* Patch with a Patch-level lower or equal than */
* {@link Patch#maxPatchLevel(String)} protected Patch(@NotNull String modID, int level) {
*/ //Patchlevels need to be unique and registered in ascending order
protected Patch(@NotNull String modID, int level) { if (modID == null || "".equals(modID)) {
//Patchlevels need to be unique and registered in ascending order throw new RuntimeException("[INTERNAL ERROR] Patches need a valid modID!");
if (modID==null || "".equals(modID)){ }
throw new RuntimeException("[INTERNAL ERROR] Patches need a valid modID!"); if (!ALL.stream().filter(p -> p.getModID().equals(modID)).noneMatch(p -> p.getLevel() >= level) || level <= 0) {
} throw new RuntimeException("[INTERNAL ERROR] Patch-levels need to be created in ascending order beginning with 1.");
if (!ALL.stream().filter(p-> p.getModID().equals(modID)).noneMatch(p -> p.getLevel() >= level) || level <= 0){ }
throw new RuntimeException("[INTERNAL ERROR] Patch-levels need to be created in ascending order beginning with 1.");
}
BCLib.LOGGER.info("Creating Patchlevel {} ({}, {})", level, ALL, ALL.stream().noneMatch(p -> p.getLevel() >= level));
this.level = level;
BCLib.LOGGER.info("Creating Patchlevel {} ({}, {})", level, ALL, ALL.stream().noneMatch(p -> p.getLevel() >= level)); this.modID = modID;
this.level = level; }
this.modID = modID;
} @Override
public String toString() {
@Override return "Patch{" + "level=" + getModID() + ":" + getLevel() + '}';
public String toString() { }
return "Patch{" +
"level=" + getModID() + ":" + getLevel() + final public int getLevel() {
'}'; return level;
} }
final public int getLevel() { /**
return level; * The Mod-ID that registered this Patch
} *
* @return The ID
/** */
* The Mod-ID that registered this Patch final public String getModID() {
* @return The ID return modID;
*/ }
final public String getModID() {
return modID;
} /**
* Return block data fixes. Fixes will be applied on world load if current patch-level for
* the linked mod is lower than the {@link #level}.
/** * <p>
* Return block data fixes. Fixes will be applied on world load if current patch-level for * The default implementation of this method returns an empty map.
* the linked mod is lower than the {@link #level}. *
* * @return The returned Map should contain the replacements. All occurences of the
* The default implementation of this method returns an empty map. * {@code KeySet} are replaced with the associated value.
* */
* @return The returned Map should contain the replacements. All occurences of the public Map<String, String> getIDReplacements() {
* {@code KeySet} are replaced with the associated value. return new HashMap<String, String>();
*/ }
public Map<String, String> getIDReplacements(){
return new HashMap<String, String>(); /**
} * Generates ready to use data for all currently registered patches. The list of
* patches is selected by the current patch-level of the world.
/** * <p>
* Generates ready to use data for all currently registered patches. The list of * A {@link #Patch} with a given {@link #level} is only included if the patch-level of the
* patches is selected by the current patch-level of the world. * world is less
* *
* A {@link #Patch} with a given {@link #level} is only included if the patch-level of the * @return a new {@link MigrationData} Object.
* world is less */
* @return a new {@link MigrationData} Object. static MigrationData createMigrationData(PathConfig config) {
*/ return new MigrationData(config);
static MigrationData createMigrationData(PathConfig config){ }
return new MigrationData(config);
} static class MigrationData {
final Set<String> mods;
static class MigrationData{ final Map<String, String> idReplacements;
final Set<String> mods; private final PathConfig config;
final Map<String, String> idReplacements;
private final PathConfig config; private MigrationData(PathConfig config) {
this.config = config;
private MigrationData(PathConfig config){
this.config = config; this.mods = Collections.unmodifiableSet(Patch.getALL().stream().map(p -> p.modID).collect(Collectors.toSet()));
this.mods = Collections.unmodifiableSet(Patch.getALL().stream().map(p -> p.modID).collect(Collectors.toSet())); HashMap<String, String> replacements = new HashMap<String, String>();
for (String modID : mods) {
HashMap<String, String> replacements = new HashMap<String, String>(); Patch.getALL().stream().filter(p -> p.modID.equals(modID)).forEach(patch -> {
for(String modID : mods){ if (currentPatchLevel(modID) < patch.level) {
Patch.getALL().stream().filter(p -> p.modID.equals(modID)).forEach(patch -> { replacements.putAll(patch.getIDReplacements());
if (currentPatchLevel(modID) < patch.level) { LOGGER.info("Applying " + patch);
replacements.putAll(patch.getIDReplacements()); }
LOGGER.info("Applying " + patch); else {
} else { LOGGER.info("Ignoring " + patch);
LOGGER.info("Ignoring " + patch); }
} });
}); }
}
this.idReplacements = Collections.unmodifiableMap(replacements);
this.idReplacements = Collections.unmodifiableMap(replacements); }
}
final public void markApplied() {
final public void markApplied(){ for (String modID : mods) {
for(String modID : mods){ LOGGER.info("Updating Patch-Level for '{}' from {} to {} -> {}", modID, currentPatchLevel(modID), Patch.maxPatchLevel(modID), config.setInt(Configs.MAIN_PATCH_CATEGORY, modID, Patch.maxPatchLevel(modID)));
LOGGER.info("Updating Patch-Level for '{}' from {} to {} -> {}", }
modID,
currentPatchLevel(modID), config.saveChanges();
Patch.maxPatchLevel(modID), }
config.setInt(Configs.MAIN_PATCH_CATEGORY, modID, Patch.maxPatchLevel(modID))
); public int currentPatchLevel(@NotNull String modID) {
} return config.getInt(Configs.MAIN_PATCH_CATEGORY, modID, 0);
}
config.saveChanges();
} public boolean hasAnyFixes() {
return idReplacements.size() > 0;
public int currentPatchLevel(@NotNull String modID){ }
return config.getInt(Configs.MAIN_PATCH_CATEGORY, modID, 0);
} public boolean replaceStringFromIDs(@NotNull CompoundTag tag, @NotNull String key) {
if (!tag.contains(key)) return false;
public boolean hasAnyFixes(){
return idReplacements.size()>0; final String val = tag.getString(key);
} final String replace = idReplacements.get(val);
public boolean replaceStringFromIDs(@NotNull CompoundTag tag, @NotNull String key){ if (replace != null) {
if (!tag.contains(key)) return false; LOGGER.warning("Replacing ID '{}' with '{}'.", val, replace);
tag.putString(key, replace);
final String val = tag.getString(key); return true;
final String replace = idReplacements.get(val); }
if (replace != null){ return false;
LOGGER.warning("Replacing ID '{}' with '{}'.", val, replace); }
tag.putString(key, replace); }
return true; }
}
return false;
}
}
}
} }

View file

@ -1,7 +1,5 @@
package ru.bclib.api; package ru.bclib.api;
import java.util.function.Supplier;
import net.fabricmc.fabric.api.tag.TagRegistry; import net.fabricmc.fabric.api.tag.TagRegistry;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.BlockTags; import net.minecraft.tags.BlockTags;
@ -16,6 +14,8 @@ import net.minecraft.world.level.block.Blocks;
import ru.bclib.BCLib; import ru.bclib.BCLib;
import ru.bclib.util.TagHelper; import ru.bclib.util.TagHelper;
import java.util.function.Supplier;
public class TagAPI { public class TagAPI {
// Block Tags // Block Tags
public static final Tag.Named<Block> BOOKSHELVES = makeCommonBlockTag("bookshelves"); public static final Tag.Named<Block> BOOKSHELVES = makeCommonBlockTag("bookshelves");

View file

@ -1,9 +1,5 @@
package ru.bclib.blocks; package ru.bclib.blocks;
import java.util.Collections;
import java.util.List;
import java.util.function.Consumer;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.client.renderer.block.model.BlockModel; import net.minecraft.client.renderer.block.model.BlockModel;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
@ -14,9 +10,13 @@ import net.minecraft.world.level.material.MaterialColor;
import net.minecraft.world.level.storage.loot.LootContext; import net.minecraft.world.level.storage.loot.LootContext;
import ru.bclib.client.models.BlockModelProvider; import ru.bclib.client.models.BlockModelProvider;
import java.util.Collections;
import java.util.List;
import java.util.function.Consumer;
/** /**
* Base class for a default Block. * Base class for a default Block.
* * <p>
* This Block-Type will: * This Block-Type will:
* <ul> * <ul>
* <li>Drop itself</li> * <li>Drop itself</li>
@ -26,15 +26,16 @@ import ru.bclib.client.models.BlockModelProvider;
public class BaseBlock extends Block implements BlockModelProvider { public class BaseBlock extends Block implements BlockModelProvider {
/** /**
* Creates a new Block with the passed properties * Creates a new Block with the passed properties
*
* @param settings The properties of the Block. * @param settings The properties of the Block.
*/ */
public BaseBlock(Properties settings) { public BaseBlock(Properties settings) {
super(settings); super(settings);
} }
/** /**
* {@inheritDoc} * {@inheritDoc}
* * <p>
* This implementation will drop the Block itself * This implementation will drop the Block itself
*/ */
@Override @Override
@ -42,29 +43,30 @@ public class BaseBlock extends Block implements BlockModelProvider {
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) { public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
return Collections.singletonList(new ItemStack(this)); return Collections.singletonList(new ItemStack(this));
} }
/** /**
* {@inheritDoc} * {@inheritDoc}
* * <p>
* This implementation will load the Block-Model and return it as the Item-Model * This implementation will load the Block-Model and return it as the Item-Model
*/ */
@Override @Override
public BlockModel getItemModel(ResourceLocation blockId) { public BlockModel getItemModel(ResourceLocation blockId) {
return getBlockModel(blockId, defaultBlockState()); return getBlockModel(blockId, defaultBlockState());
} }
/** /**
* This method is used internally. * This method is used internally.
* * <p>
* It is called from Block-Contructors, to allow the augmentation of the blocks * It is called from Block-Contructors, to allow the augmentation of the blocks
* preset properties. * preset properties.
* * <p>
* For example in {@link BaseLeavesBlock#BaseLeavesBlock(Block, MaterialColor, Consumer)} * For example in {@link BaseLeavesBlock#BaseLeavesBlock(Block, MaterialColor, Consumer)}
*
* @param customizeProperties A {@link Consumer} to call with the preset properties * @param customizeProperties A {@link Consumer} to call with the preset properties
* @param settings The properties as created by the Block * @param settings The properties as created by the Block
* @return The reconfigured {@code settings} * @return The reconfigured {@code settings}
*/ */
static FabricBlockSettings acceptAndReturn(Consumer<FabricBlockSettings> customizeProperties, FabricBlockSettings settings){ static FabricBlockSettings acceptAndReturn(Consumer<FabricBlockSettings> customizeProperties, FabricBlockSettings settings) {
customizeProperties.accept(settings); customizeProperties.accept(settings);
return settings; return settings;
} }

View file

@ -1,11 +1,6 @@
package ru.bclib.blocks; package ru.bclib.blocks;
import java.util.Collections;
import java.util.List;
import java.util.function.Consumer;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.minecraft.client.renderer.block.model.BlockModel; import net.minecraft.client.renderer.block.model.BlockModel;
@ -25,29 +20,25 @@ import ru.bclib.client.render.BCLRenderLayer;
import ru.bclib.interfaces.IRenderTyped; import ru.bclib.interfaces.IRenderTyped;
import ru.bclib.util.MHelper; import ru.bclib.util.MHelper;
import java.util.Collections;
import java.util.List;
import java.util.function.Consumer;
public class BaseLeavesBlock extends LeavesBlock implements BlockModelProvider, IRenderTyped { public class BaseLeavesBlock extends LeavesBlock implements BlockModelProvider, IRenderTyped {
private final Block sapling; private final Block sapling;
private static FabricBlockSettings makeLeaves(MaterialColor color){ private static FabricBlockSettings makeLeaves(MaterialColor color) {
return FabricBlockSettings return FabricBlockSettings.copyOf(Blocks.OAK_LEAVES).mapColor(color).breakByTool(FabricToolTags.HOES).breakByTool(FabricToolTags.SHEARS).breakByHand(true).allowsSpawning((state, world, pos, type) -> false).suffocates((state, world, pos) -> false).blockVision((state, world, pos) -> false);
.copyOf(Blocks.OAK_LEAVES)
.mapColor(color)
.breakByTool(FabricToolTags.HOES)
.breakByTool(FabricToolTags.SHEARS)
.breakByHand(true)
.allowsSpawning((state, world, pos, type) -> false)
.suffocates((state, world, pos) -> false)
.blockVision((state, world, pos) -> false);
} }
public BaseLeavesBlock(Block sapling, MaterialColor color, Consumer<FabricBlockSettings> customizeProperties) { public BaseLeavesBlock(Block sapling, MaterialColor color, Consumer<FabricBlockSettings> customizeProperties) {
super(BaseBlock.acceptAndReturn(customizeProperties, makeLeaves(color))); super(BaseBlock.acceptAndReturn(customizeProperties, makeLeaves(color)));
this.sapling = sapling; this.sapling = sapling;
} }
public BaseLeavesBlock(Block sapling, MaterialColor color, int light, Consumer<FabricBlockSettings> customizeProperties) { public BaseLeavesBlock(Block sapling, MaterialColor color, int light, Consumer<FabricBlockSettings> customizeProperties) {
super(BaseBlock.acceptAndReturn(customizeProperties, makeLeaves(color).luminance(light))); super(BaseBlock.acceptAndReturn(customizeProperties, makeLeaves(color).luminance(light)));
this.sapling = sapling; this.sapling = sapling;
} }
public BaseLeavesBlock(Block sapling, MaterialColor color) { public BaseLeavesBlock(Block sapling, MaterialColor color) {

View file

@ -3,16 +3,20 @@ package ru.bclib.blocks.properties;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import net.minecraft.world.level.block.state.properties.Property; import net.minecraft.world.level.block.state.properties.Property;
import java.util.*; import java.util.Collection;
import java.util.Collections;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
@Deprecated @Deprecated
public class StringProperty extends Property<String> { public class StringProperty extends Property<String> {
private final Set<String> values; private final Set<String> values;
public static StringProperty create(String name, String... values) { public static StringProperty create(String name, String... values) {
return new StringProperty(name, values); return new StringProperty(name, values);
} }
protected StringProperty(String string, String... values) { protected StringProperty(String string, String... values) {
super(string, String.class); super(string, String.class);
this.values = Sets.newHashSet(values); this.values = Sets.newHashSet(values);
@ -21,31 +25,32 @@ public class StringProperty extends Property<String> {
public void addValue(String name) { public void addValue(String name) {
values.add(name); values.add(name);
} }
@Override @Override
public Collection<String> getPossibleValues() { public Collection<String> getPossibleValues() {
return Collections.unmodifiableSet(values); return Collections.unmodifiableSet(values);
} }
@Override @Override
public String getName(String comparable) { public String getName(String comparable) {
return comparable; return comparable;
} }
@Override @Override
public Optional<String> getValue(String string) { public Optional<String> getValue(String string) {
if (values.contains(string)) { if (values.contains(string)) {
return Optional.of(string); return Optional.of(string);
} else { }
else {
return Optional.empty(); return Optional.empty();
} }
} }
@Override @Override
public int generateHashCode() { public int generateHashCode() {
return super.generateHashCode() + Objects.hashCode(values); return super.generateHashCode() + Objects.hashCode(values);
} }
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {
if (this == o) return true; if (this == o) return true;

View file

@ -1,7 +1,5 @@
package ru.bclib.config; package ru.bclib.config;
import java.io.File;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import ru.bclib.BCLib; import ru.bclib.BCLib;
import ru.bclib.config.ConfigKeeper.BooleanEntry; import ru.bclib.config.ConfigKeeper.BooleanEntry;
@ -11,12 +9,14 @@ import ru.bclib.config.ConfigKeeper.IntegerEntry;
import ru.bclib.config.ConfigKeeper.RangeEntry; import ru.bclib.config.ConfigKeeper.RangeEntry;
import ru.bclib.config.ConfigKeeper.StringEntry; import ru.bclib.config.ConfigKeeper.StringEntry;
import java.io.File;
public abstract class Config { public abstract class Config {
protected final ConfigKeeper keeper; protected final ConfigKeeper keeper;
protected abstract void registerEntries(); protected abstract void registerEntries();
public Config(String modID, String group){ public Config(String modID, String group) {
this(modID, group, null); this(modID, group, null);
} }

View file

@ -1,21 +1,19 @@
package ru.bclib.config; package ru.bclib.config;
import com.google.common.collect.Maps;
import com.google.common.reflect.TypeToken;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import net.minecraft.util.GsonHelper;
import org.jetbrains.annotations.Nullable;
import ru.bclib.util.JsonFactory;
import java.io.File; import java.io.File;
import java.lang.reflect.Type; import java.lang.reflect.Type;
import java.util.Map; import java.util.Map;
import java.util.function.Consumer; import java.util.function.Consumer;
import java.util.function.Supplier; import java.util.function.Supplier;
import org.jetbrains.annotations.Nullable;
import com.google.common.collect.Maps;
import com.google.common.reflect.TypeToken;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import net.minecraft.util.GsonHelper;
import ru.bclib.util.JsonFactory;
public final class ConfigKeeper { public final class ConfigKeeper {
private final Map<ConfigKey, Entry<?>> configEntries = Maps.newHashMap(); private final Map<ConfigKey, Entry<?>> configEntries = Maps.newHashMap();
private final JsonObject configObject; private final JsonObject configObject;
@ -26,7 +24,7 @@ public final class ConfigKeeper {
public ConfigKeeper(String modID, String group) { public ConfigKeeper(String modID, String group) {
this(modID, group, null); this(modID, group, null);
} }
protected ConfigKeeper(String modID, String group, File path) { protected ConfigKeeper(String modID, String group, File path) {
this.writer = new ConfigWriter(modID, group, path); this.writer = new ConfigWriter(modID, group, path);
this.configObject = writer.load(); this.configObject = writer.load();

View file

@ -1,9 +1,9 @@
package ru.bclib.config; package ru.bclib.config;
import java.util.Arrays;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import java.util.Arrays;
public class ConfigKey { public class ConfigKey {
private final String path[]; private final String path[];
private final String entry; private final String entry;

View file

@ -1,14 +1,13 @@
package ru.bclib.config; package ru.bclib.config;
import java.io.File;
import java.nio.file.Path;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import net.fabricmc.loader.api.FabricLoader; import net.fabricmc.loader.api.FabricLoader;
import ru.bclib.util.JsonFactory; import ru.bclib.util.JsonFactory;
import java.io.File;
import java.nio.file.Path;
public class ConfigWriter { public class ConfigWriter {
private final static Path GAME_CONFIG_DIR = FabricLoader.getInstance().getConfigDir(); private final static Path GAME_CONFIG_DIR = FabricLoader.getInstance().getConfigDir();
@ -18,14 +17,9 @@ public class ConfigWriter {
public ConfigWriter(String modID, String configFile) { public ConfigWriter(String modID, String configFile) {
this(modID, configFile, null); this(modID, configFile, null);
} }
public ConfigWriter(String modID, String configFile, File configFolder) { public ConfigWriter(String modID, String configFile, File configFolder) {
this.configFile = new File( this.configFile = new File((configFolder == null ? GAME_CONFIG_DIR.resolve(modID).toFile() : new File(configFolder, modID)), configFile + ".json");
(configFolder==null
? GAME_CONFIG_DIR.resolve(modID).toFile()
: new File(configFolder, modID)),
configFile + ".json"
);
File parent = this.configFile.getParentFile(); File parent = this.configFile.getParentFile();
if (!parent.exists()) { if (!parent.exists()) {
parent.mkdirs(); parent.mkdirs();

View file

@ -5,7 +5,7 @@ import ru.bclib.BCLib;
public class Configs { public class Configs {
public static final PathConfig MAIN_CONFIG = new PathConfig(BCLib.MOD_ID, "main"); public static final PathConfig MAIN_CONFIG = new PathConfig(BCLib.MOD_ID, "main");
public static final String MAIN_PATCH_CATEGORY = "patches"; public static final String MAIN_PATCH_CATEGORY = "patches";
public static final PathConfig RECIPE_CONFIG = new PathConfig(BCLib.MOD_ID, "recipes"); public static final PathConfig RECIPE_CONFIG = new PathConfig(BCLib.MOD_ID, "recipes");
public static void save() { public static void save() {

View file

@ -1,18 +1,18 @@
package ru.bclib.config; package ru.bclib.config;
import java.io.File;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import ru.bclib.config.ConfigKeeper.Entry; import ru.bclib.config.ConfigKeeper.Entry;
import ru.bclib.config.ConfigKeeper.FloatRange; import ru.bclib.config.ConfigKeeper.FloatRange;
import ru.bclib.config.ConfigKeeper.IntegerRange; import ru.bclib.config.ConfigKeeper.IntegerRange;
import java.io.File;
public class PathConfig extends Config { public class PathConfig extends Config {
public PathConfig(String modID, String group) { public PathConfig(String modID, String group) {
this(modID, group, null); this(modID, group, null);
} }
protected PathConfig(String modID, String group, File path) { protected PathConfig(String modID, String group, File path) {
super(modID, group, path); super(modID, group, path);
} }

View file

@ -1,25 +1,25 @@
package ru.bclib.config; package ru.bclib.config;
import java.io.File;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.level.storage.LevelStorageSource; import net.minecraft.world.level.storage.LevelStorageSource;
import ru.bclib.BCLib; import ru.bclib.BCLib;
public class SessionConfig extends PathConfig{ import java.io.File;
private static File getWorldFolder(LevelStorageSource.LevelStorageAccess session, ServerLevel world){
File dir = session.getDimensionPath(world.dimension());
if (!new File(dir, "level.dat").exists()) {
dir = dir.getParentFile();
}
return dir;
}
public final File levelFolder; public class SessionConfig extends PathConfig {
private static File getWorldFolder(LevelStorageSource.LevelStorageAccess session, ServerLevel world) {
public SessionConfig(String modID, String group, LevelStorageSource.LevelStorageAccess session, ServerLevel world) { File dir = session.getDimensionPath(world.dimension());
super(modID, group, new File(getWorldFolder(session, world), BCLib.MOD_ID)); if (!new File(dir, "level.dat").exists()) {
dir = dir.getParentFile();
this.levelFolder = new File(getWorldFolder(session, world), BCLib.MOD_ID); }
} return dir;
}
public final File levelFolder;
public SessionConfig(String modID, String group, LevelStorageSource.LevelStorageAccess session, ServerLevel world) {
super(modID, group, new File(getWorldFolder(session, world), BCLib.MOD_ID));
this.levelFolder = new File(getWorldFolder(session, world), BCLib.MOD_ID);
}
} }

View file

@ -3,36 +3,26 @@ package ru.bclib.mixin.client;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.color.block.BlockColors; import net.minecraft.client.color.block.BlockColors;
import net.minecraft.client.color.item.ItemColors; import net.minecraft.client.color.item.ItemColors;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.gui.screens.WinScreen;
import net.minecraft.client.main.GameConfig; import net.minecraft.client.main.GameConfig;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.core.Registry; import net.minecraft.core.Registry;
import net.minecraft.sounds.Music;
import net.minecraft.sounds.Musics;
import net.minecraft.world.level.Level;
import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import ru.bclib.interfaces.IColorProvider; import ru.bclib.interfaces.IColorProvider;
import ru.bclib.util.MHelper;
@Mixin(Minecraft.class) @Mixin(Minecraft.class)
public class MinecraftMixin { public class MinecraftMixin {
@Final @Final
@Shadow @Shadow
private BlockColors blockColors; private BlockColors blockColors;
@Final @Final
@Shadow @Shadow
private ItemColors itemColors; private ItemColors itemColors;
@Inject(method = "<init>*", at = @At("TAIL")) @Inject(method = "<init>*", at = @At("TAIL"))
private void bclib_onMCInit(GameConfig args, CallbackInfo info) { private void bclib_onMCInit(GameConfig args, CallbackInfo info) {
Registry.BLOCK.forEach(block -> { Registry.BLOCK.forEach(block -> {

View file

@ -25,11 +25,7 @@ public class TextureAtlasMixin {
bclib_modifyAtlas = resourceLocation.toString().equals("minecraft:textures/atlas/blocks.png"); bclib_modifyAtlas = resourceLocation.toString().equals("minecraft:textures/atlas/blocks.png");
} }
@Inject( @Inject(method = "load(Lnet/minecraft/server/packs/resources/ResourceManager;Lnet/minecraft/client/renderer/texture/TextureAtlasSprite$Info;IIIII)Lnet/minecraft/client/renderer/texture/TextureAtlasSprite;", at = @At("HEAD"), cancellable = true)
method = "load(Lnet/minecraft/server/packs/resources/ResourceManager;Lnet/minecraft/client/renderer/texture/TextureAtlasSprite$Info;IIIII)Lnet/minecraft/client/renderer/texture/TextureAtlasSprite;",
at = @At("HEAD"),
cancellable = true
)
private void bclib_loadSprite(ResourceManager resourceManager, TextureAtlasSprite.Info spriteInfo, int atlasWidth, int atlasHeight, int maxLevel, int posX, int posY, CallbackInfoReturnable<TextureAtlasSprite> info) { private void bclib_loadSprite(ResourceManager resourceManager, TextureAtlasSprite.Info spriteInfo, int atlasWidth, int atlasHeight, int maxLevel, int posX, int posY, CallbackInfoReturnable<TextureAtlasSprite> info) {
ResourceLocation location = spriteInfo.name(); ResourceLocation location = spriteInfo.name();
if (bclib_modifyAtlas && location.getPath().startsWith("block")) { if (bclib_modifyAtlas && location.getPath().startsWith("block")) {

View file

@ -7,7 +7,6 @@ import net.minecraft.world.InteractionResult;
import net.minecraft.world.item.BoneMealItem; import net.minecraft.world.item.BoneMealItem;
import net.minecraft.world.item.context.UseOnContext; import net.minecraft.world.item.context.UseOnContext;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
import net.minecraft.world.level.biome.Biome.BiomeCategory;
import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
@ -18,12 +17,9 @@ import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import ru.bclib.api.BiomeAPI; import ru.bclib.api.BiomeAPI;
import ru.bclib.api.BonemealAPI; import ru.bclib.api.BonemealAPI;
import ru.bclib.api.TagAPI;
import ru.bclib.util.BlocksHelper; import ru.bclib.util.BlocksHelper;
import ru.bclib.util.MHelper; import ru.bclib.util.MHelper;
import java.util.Collection;
@Mixin(BoneMealItem.class) @Mixin(BoneMealItem.class)
public class BoneMealItemMixin { public class BoneMealItemMixin {
private static final MutableBlockPos bclib_BLOCK_POS = new MutableBlockPos(); private static final MutableBlockPos bclib_BLOCK_POS = new MutableBlockPos();
@ -139,7 +135,7 @@ public class BoneMealItemMixin {
Block terrain = BonemealAPI.getSpreadable(state.getBlock()); Block terrain = BonemealAPI.getSpreadable(state.getBlock());
if (center.is(terrain)) { if (center.is(terrain)) {
if (haveSameProperties(state, center)) { if (haveSameProperties(state, center)) {
for (Property property: center.getProperties()) { for (Property property : center.getProperties()) {
state = state.setValue(property, center.getValue(property)); state = state.setValue(property, center.getValue(property));
} }
} }

View file

@ -1,10 +1,5 @@
package ru.bclib.mixin.common; package ru.bclib.mixin.common;
import java.io.File;
import java.util.List;
import java.util.concurrent.Executor;
import java.util.function.Supplier;
import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceKey;
import net.minecraft.server.MinecraftServer; import net.minecraft.server.MinecraftServer;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
@ -27,6 +22,11 @@ import ru.bclib.api.DataFixerAPI2;
import ru.bclib.api.WorldDataAPI; import ru.bclib.api.WorldDataAPI;
import ru.bclib.config.SessionConfig; import ru.bclib.config.SessionConfig;
import java.io.File;
import java.util.List;
import java.util.concurrent.Executor;
import java.util.function.Supplier;
@Mixin(ServerLevel.class) @Mixin(ServerLevel.class)
public abstract class ServerLevelMixin extends Level { public abstract class ServerLevelMixin extends Level {
private static String bclib_lastWorld = null; private static String bclib_lastWorld = null;

View file

@ -44,7 +44,7 @@ public class BaseBlockEntities {
public static Block[] getFurnaces() { public static Block[] getFurnaces() {
return BaseRegistry.getRegisteredBlocks().values().stream().filter(item -> item instanceof BlockItem && ((BlockItem) item).getBlock() instanceof BaseFurnaceBlock).map(item -> ((BlockItem) item).getBlock()).toArray(Block[]::new); return BaseRegistry.getRegisteredBlocks().values().stream().filter(item -> item instanceof BlockItem && ((BlockItem) item).getBlock() instanceof BaseFurnaceBlock).map(item -> ((BlockItem) item).getBlock()).toArray(Block[]::new);
} }
public static boolean registerSpecialBlock(Block block) { public static boolean registerSpecialBlock(Block block) {
if (block instanceof BaseChestBlock) { if (block instanceof BaseChestBlock) {
BaseBlockEntities.CHEST.registerBlock(block); BaseBlockEntities.CHEST.registerBlock(block);
@ -62,7 +62,7 @@ public class BaseBlockEntities {
BaseBlockEntities.FURNACE.registerBlock(block); BaseBlockEntities.FURNACE.registerBlock(block);
return true; return true;
} }
return false; return false;
} }
} }

View file

@ -52,6 +52,7 @@ public class JsonFactory {
/** /**
* Loads {@link JsonObject} from resource location using Minecraft resource manager. Can be used to load JSON from resourcepacks and resources. * Loads {@link JsonObject} from resource location using Minecraft resource manager. Can be used to load JSON from resourcepacks and resources.
*
* @param location {@link ResourceLocation} to JSON file * @param location {@link ResourceLocation} to JSON file
* @return {@link JsonObject} * @return {@link JsonObject}
*/ */
@ -70,7 +71,8 @@ public class JsonFactory {
stream.close(); stream.close();
} }
} }
catch (IOException ex) {} catch (IOException ex) {
}
return obj; return obj;
} }

View file

@ -1,11 +1,7 @@
package ru.bclib.util; package ru.bclib.util;
import java.util.Map;
import java.util.Set;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import net.minecraft.core.Registry; import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.packs.resources.ResourceManager; import net.minecraft.server.packs.resources.ResourceManager;
@ -14,24 +10,27 @@ import net.minecraft.world.item.Item;
import net.minecraft.world.level.ItemLike; import net.minecraft.world.level.ItemLike;
import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Block;
import java.util.Map;
import java.util.Set;
/** /**
* Utility functions to manage Minecraft Tags * Utility functions to manage Minecraft Tags
*/ */
public class TagHelper { public class TagHelper {
private static final Map<ResourceLocation, Set<ResourceLocation>> TAGS_BLOCK = Maps.newConcurrentMap(); private static final Map<ResourceLocation, Set<ResourceLocation>> TAGS_BLOCK = Maps.newConcurrentMap();
private static final Map<ResourceLocation, Set<ResourceLocation>> TAGS_ITEM = Maps.newConcurrentMap(); private static final Map<ResourceLocation, Set<ResourceLocation>> TAGS_ITEM = Maps.newConcurrentMap();
/** /**
* Adds one Tag to multiple Blocks. * Adds one Tag to multiple Blocks.
* * <p>
* Example: * Example:
* <pre>{@code Tag.Named<Block> DIMENSION_STONE = makeBlockTag("mymod", "dim_stone"); * <pre>{@code Tag.Named<Block> DIMENSION_STONE = makeBlockTag("mymod", "dim_stone");
* TagHelper.addTag(DIMENSION_STONE, Blocks.END_STONE, Blocks.NETHERRACK);}</pre> * TagHelper.addTag(DIMENSION_STONE, Blocks.END_STONE, Blocks.NETHERRACK);}</pre>
* * <p>
* The call will reserve the Tag. The Tag is added to the blocks once * The call will reserve the Tag. The Tag is added to the blocks once
* {@link #apply(String, Map)} was executed. * {@link #apply(String, Map)} was executed.
* *
* @param tag The new Tag * @param tag The new Tag
* @param blocks One or more blocks that should receive the Tag. * @param blocks One or more blocks that should receive the Tag.
*/ */
public static void addTag(Tag.Named<Block> tag, Block... blocks) { public static void addTag(Tag.Named<Block> tag, Block... blocks) {
@ -44,18 +43,18 @@ public class TagHelper {
} }
} }
} }
/** /**
* Adds one Tag to multiple Items. * Adds one Tag to multiple Items.
* * <p>
* Example: * Example:
* <pre>{@code Tag.Named<Item> METALS = makeBlockTag("mymod", "metals"); * <pre>{@code Tag.Named<Item> METALS = makeBlockTag("mymod", "metals");
* TagHelper.addTag(METALS, Items.IRON_INGOT, Items.GOLD_INGOT, Items.COPPER_INGOT);}</pre> * TagHelper.addTag(METALS, Items.IRON_INGOT, Items.GOLD_INGOT, Items.COPPER_INGOT);}</pre>
* * <p>
* The call will reserve the Tag. The Tag is added to the items once * The call will reserve the Tag. The Tag is added to the items once
* {@link #apply(String, Map)} was executed. * {@link #apply(String, Map)} was executed.
* *
* @param tag The new Tag * @param tag The new Tag
* @param items One or more item that should receive the Tag. * @param items One or more item that should receive the Tag.
*/ */
public static void addTag(Tag.Named<Item> tag, ItemLike... items) { public static void addTag(Tag.Named<Item> tag, ItemLike... items) {
@ -68,12 +67,12 @@ public class TagHelper {
} }
} }
} }
/** /**
* Adds multiple Tags to one Item. * Adds multiple Tags to one Item.
* * <p>
* The call will reserve the Tags. The Tags are added to the Item once * The call will reserve the Tags. The Tags are added to the Item once
* * {@link #apply(String, Map)} was executed. * * {@link #apply(String, Map)} was executed.
* *
* @param item The Item that will receive all Tags * @param item The Item that will receive all Tags
* @param tags One or more Tags * @param tags One or more Tags
@ -84,15 +83,15 @@ public class TagHelper {
addTag(tag, item); addTag(tag, item);
} }
} }
/** /**
* Adds multiple Tags to one Block. * Adds multiple Tags to one Block.
* * <p>
* The call will reserve the Tags. The Tags are added to the Block once * The call will reserve the Tags. The Tags are added to the Block once
* * {@link #apply(String, Map)} was executed. * * {@link #apply(String, Map)} was executed.
* *
* @param block The Block that will receive all Tags * @param block The Block that will receive all Tags
* @param tags One or more Tags * @param tags One or more Tags
*/ */
@SafeVarargs @SafeVarargs
public static void addTags(Block block, Tag.Named<Block>... tags) { public static void addTags(Block block, Tag.Named<Block>... tags) {
@ -100,28 +99,27 @@ public class TagHelper {
addTag(tag, block); addTag(tag, block);
} }
} }
/** /**
* Adds all {@code ids} to the {@code builder}. * Adds all {@code ids} to the {@code builder}.
*
* @param builder * @param builder
* @param ids * @param ids
*
* @return The Builder passed as {@code builder}. * @return The Builder passed as {@code builder}.
*/ */
public static Tag.Builder apply(Tag.Builder builder, Set<ResourceLocation> ids) { public static Tag.Builder apply(Tag.Builder builder, Set<ResourceLocation> ids) {
ids.forEach(value -> builder.addElement(value, "Better End Code")); ids.forEach(value -> builder.addElement(value, "Better End Code"));
return builder; return builder;
} }
/** /**
* Automatically called in {@link net.minecraft.tags.TagLoader#loadAndBuild(ResourceManager)}. * Automatically called in {@link net.minecraft.tags.TagLoader#loadAndBuild(ResourceManager)}.
* * <p>
* In most cases there is no need to call this Method manually. * In most cases there is no need to call this Method manually.
* *
* @param directory The name of the Tag-directory. Should be either <i>"tags/blocks"</i> or * @param directory The name of the Tag-directory. Should be either <i>"tags/blocks"</i> or
* <i>"tags/items"</i>. * <i>"tags/items"</i>.
* @param tagsMap The map that will hold the registered Tags * @param tagsMap The map that will hold the registered Tags
*
* @return The {@code tagsMap} Parameter. * @return The {@code tagsMap} Parameter.
*/ */
public static Map<ResourceLocation, Tag.Builder> apply(String directory, Map<ResourceLocation, Tag.Builder> tagsMap) { public static Map<ResourceLocation, Tag.Builder> apply(String directory, Map<ResourceLocation, Tag.Builder> tagsMap) {