Tags Helper
This commit is contained in:
parent
1d206295b7
commit
b9962bd6a5
4 changed files with 41 additions and 30 deletions
|
@ -1,7 +0,0 @@
|
|||
package ru.betterend;
|
||||
|
||||
import net.minecraft.tag.Tag;
|
||||
|
||||
public class TagHelper {
|
||||
public static Tag.Entry lastEntry;
|
||||
}
|
|
@ -1,18 +1,11 @@
|
|||
package ru.betterend.blocks.complex;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.fabricmc.fabric.api.tag.TagRegistry;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.Material;
|
||||
import net.minecraft.block.MaterialColor;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.sound.BlockSoundGroup;
|
||||
import net.minecraft.tag.BlockTags;
|
||||
import net.minecraft.tag.SetTag;
|
||||
import net.minecraft.tag.Tag;
|
||||
import net.minecraft.util.Identifier;
|
||||
import ru.betterend.blocks.basis.BlockBarrel;
|
||||
import ru.betterend.blocks.basis.BlockBase;
|
||||
import ru.betterend.blocks.basis.BlockChest;
|
||||
|
@ -31,6 +24,7 @@ import ru.betterend.blocks.basis.BlockTrapdoor;
|
|||
import ru.betterend.blocks.basis.BlockWoodenButton;
|
||||
import ru.betterend.recipe.RecipeBuilder;
|
||||
import ru.betterend.registry.BlockRegistry;
|
||||
import ru.betterend.util.TagHelper;
|
||||
|
||||
public class WoodenMaterial
|
||||
{
|
||||
|
@ -58,7 +52,6 @@ public class WoodenMaterial
|
|||
public final Block chest;
|
||||
public final Block barrel;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public WoodenMaterial(String name, MaterialColor woodColor, MaterialColor planksColor)
|
||||
{
|
||||
FabricBlockSettings materialPlanks = FabricBlockSettings.of(Material.WOOD).sounds(BlockSoundGroup.WOOD).materialColor(planksColor);
|
||||
|
@ -101,17 +94,7 @@ public class WoodenMaterial
|
|||
RecipeBuilder.make(name + "_chest", chest).setShape("###", "# #", "###").addMaterial('#', planks).setGroup("end_chests").build();
|
||||
RecipeBuilder.make(name + "_barrel", barrel).setShape("#S#", "# #", "#S#").addMaterial('#', planks).addMaterial('S', slab).setGroup("end_barrels").build();
|
||||
|
||||
/*try {
|
||||
Field field = BlockTags.CLIMBABLE.getClass().getDeclaredField("delegate");
|
||||
field.setAccessible(true);
|
||||
SetTag<Block> tag = SetTag.empty();
|
||||
tag = (SetTag<Block>) field.get(tag);
|
||||
System.out.println(tag.getClass());
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}*/
|
||||
//System.out.println(BlockTags.CLIMBABLE.getClass());
|
||||
TagHelper.addTag(TagHelper.CLIMBABLE, name + "_ladder");
|
||||
}
|
||||
|
||||
public boolean isTreeLog(Block block)
|
||||
|
|
|
@ -11,16 +11,14 @@ import net.minecraft.tag.Tag;
|
|||
import net.minecraft.tag.TagGroup;
|
||||
import net.minecraft.tag.TagGroupLoader;
|
||||
import net.minecraft.util.Identifier;
|
||||
import ru.betterend.BetterEnd;
|
||||
import ru.betterend.util.TagHelper;
|
||||
|
||||
@Mixin(TagGroupLoader.class)
|
||||
public class TagGroupLoaderMixin {
|
||||
@Inject(method = "applyReload", at = @At(value = "HEAD"))
|
||||
private void onReload(Map<Identifier, Tag.Builder> tags, CallbackInfoReturnable<TagGroup<?>> info) {
|
||||
tags.forEach((id, builder) -> {
|
||||
if (id.toString().equals("minecraft:climbable")) {
|
||||
builder.add(new Identifier(BetterEnd.MOD_ID, "mossy_glowshroom_ladder"), "code");
|
||||
}
|
||||
TagHelper.apply(id, builder);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
37
src/main/java/ru/betterend/util/TagHelper.java
Normal file
37
src/main/java/ru/betterend/util/TagHelper.java
Normal file
|
@ -0,0 +1,37 @@
|
|||
package ru.betterend.util;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import net.minecraft.tag.Tag;
|
||||
import net.minecraft.util.Identifier;
|
||||
import ru.betterend.BetterEnd;
|
||||
|
||||
public class TagHelper {
|
||||
private static final Map<Identifier, Set<Identifier>> TAGS = Maps.newHashMap();
|
||||
|
||||
public static final Identifier CLIMBABLE = new Identifier("climbable");
|
||||
|
||||
public static void addTag(Identifier tagID, String... values) {
|
||||
Set<Identifier> set = TAGS.get(tagID);
|
||||
if (set == null) {
|
||||
set = Sets.newHashSet();
|
||||
TAGS.put(tagID, set);
|
||||
}
|
||||
for (String value: values) {
|
||||
set.add(new Identifier(BetterEnd.MOD_ID, value));
|
||||
}
|
||||
}
|
||||
|
||||
public static void apply(Identifier id, Tag.Builder builder) {
|
||||
Set<Identifier> values = TAGS.get(id);
|
||||
if (values != null) {
|
||||
values.forEach((value) -> {
|
||||
builder.add(value, "Better End Code");
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue