Skip to content

Commit

Permalink
Add position parsers (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
Swedz authored Sep 25, 2024
1 parent 453728f commit d8e153a
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package net.swedz.tesseract.neoforge.tooltip;

import net.minecraft.core.BlockPos;
import net.minecraft.core.GlobalPos;
import net.minecraft.core.HolderLookup;
import net.minecraft.core.registries.Registries;
import net.minecraft.network.chat.Component;
Expand All @@ -9,6 +11,7 @@
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.enchantment.Enchantment;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.Fluid;
Expand All @@ -24,6 +27,10 @@ public interface Parser<T>
Parser<Integer> ENCHANTMENT_LEVEL = (level) -> Component.translatable("enchantment.level.%d".formatted(level));
Parser<EntityType> ENTITY_TYPE = (entityType) -> entityType.getDescription().copy();
Parser<String> KEYBIND = (key) -> Component.keybind("key.%s".formatted(key));
Parser<BlockPos> BLOCK_POS = (pos) -> Component.literal(pos.toShortString());
BiParser<ResourceKey<Level>, BlockPos> DIMENSION_POS = (dimension, pos) -> Component.literal("%s (%s)".formatted(pos.toShortString(), dimension.location().toString()));
BiParser<Level, BlockPos> LEVEL_POS = (level, pos) -> DIMENSION_POS.parse(level.dimension(), pos);
Parser<GlobalPos> GLOBAL_POS = (pos) -> DIMENSION_POS.parse(pos.dimension(), pos.pos());
Parser<Component> COMPONENT = (component) -> component;
Parser<Object> OBJECT = (object) -> Component.literal(String.valueOf(object));

Expand Down

0 comments on commit d8e153a

Please sign in to comment.