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

@ -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.
*
* @param location {@link ResourceLocation} to JSON file
* @return {@link JsonObject}
*/
@ -70,7 +71,8 @@ public class JsonFactory {
stream.close();
}
}
catch (IOException ex) {}
catch (IOException ex) {
}
return obj;
}

View file

@ -1,11 +1,7 @@
package ru.bclib.util;
import java.util.Map;
import java.util.Set;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceLocation;
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.block.Block;
import java.util.Map;
import java.util.Set;
/**
* Utility functions to manage Minecraft Tags
*/
public class TagHelper {
private static final Map<ResourceLocation, Set<ResourceLocation>> TAGS_BLOCK = Maps.newConcurrentMap();
private static final Map<ResourceLocation, Set<ResourceLocation>> TAGS_ITEM = Maps.newConcurrentMap();
/**
* Adds one Tag to multiple Blocks.
*
* <p>
* Example:
* <pre>{@code Tag.Named<Block> DIMENSION_STONE = makeBlockTag("mymod", "dim_stone");
* 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
* {@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.
*/
public static void addTag(Tag.Named<Block> tag, Block... blocks) {
@ -44,18 +43,18 @@ public class TagHelper {
}
}
}
/**
* Adds one Tag to multiple Items.
*
* <p>
* Example:
* <pre>{@code Tag.Named<Item> METALS = makeBlockTag("mymod", "metals");
* 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
* {@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.
*/
public static void addTag(Tag.Named<Item> tag, ItemLike... items) {
@ -68,12 +67,12 @@ public class TagHelper {
}
}
}
/**
* Adds multiple Tags to one Item.
*
* <p>
* 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 tags One or more Tags
@ -84,15 +83,15 @@ public class TagHelper {
addTag(tag, item);
}
}
/**
* Adds multiple Tags to one Block.
*
* <p>
* 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 tags One or more Tags
* @param tags One or more Tags
*/
@SafeVarargs
public static void addTags(Block block, Tag.Named<Block>... tags) {
@ -100,28 +99,27 @@ public class TagHelper {
addTag(tag, block);
}
}
/**
* Adds all {@code ids} to the {@code builder}.
*
* @param builder
* @param ids
*
* @return The Builder passed as {@code builder}.
*/
public static Tag.Builder apply(Tag.Builder builder, Set<ResourceLocation> ids) {
ids.forEach(value -> builder.addElement(value, "Better End Code"));
return builder;
}
/**
* Automatically called in {@link net.minecraft.tags.TagLoader#loadAndBuild(ResourceManager)}.
*
* <p>
* 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
* <i>"tags/items"</i>.
* @param tagsMap The map that will hold the registered Tags
*
* <i>"tags/items"</i>.
* @param tagsMap The map that will hold the registered Tags
* @return The {@code tagsMap} Parameter.
*/
public static Map<ResourceLocation, Tag.Builder> apply(String directory, Map<ResourceLocation, Tag.Builder> tagsMap) {