|
| 1 | +package com.kneelawk.graphlib.v3.api.pos; |
| 2 | + |
| 3 | +import com.mojang.serialization.MapCodec; |
| 4 | + |
| 5 | +import net.minecraft.core.BlockPos; |
| 6 | +import net.minecraft.resources.ResourceLocation; |
| 7 | + |
| 8 | +import com.kneelawk.graphlib.v3.api.graph.user.GraphNode; |
| 9 | + |
| 10 | +/** |
| 11 | + * Generic Node position. This can have different implementations, depending on what the node is actually attached to. |
| 12 | + */ |
| 13 | +public interface NodePos { |
| 14 | + /** |
| 15 | + * Utility method for creating a block node position. |
| 16 | + * |
| 17 | + * @param pos the block position of the node. |
| 18 | + * @param dimension the dimension the node is in. |
| 19 | + * @param node the node itself. |
| 20 | + * @return the node pos for uniquely describing that node. |
| 21 | + */ |
| 22 | + static NodePos block(BlockPos pos, ResourceLocation dimension, GraphNode node) { |
| 23 | + return new BlockNodePos(pos, new LevelRef(dimension), node); |
| 24 | + } |
| 25 | + |
| 26 | + /** |
| 27 | + * {@return the graph node of this node pos} |
| 28 | + */ |
| 29 | + GraphNode node(); |
| 30 | + |
| 31 | + /** |
| 32 | + * {@return this dimension ref's type} |
| 33 | + */ |
| 34 | + Type<? extends NodePos> getType(); |
| 35 | + |
| 36 | + /** |
| 37 | + * The type of a dimension reference. |
| 38 | + * |
| 39 | + * @param id the id of this type of dimension reference within a given universe. |
| 40 | + * @param codec the codec for encoding and decoding this dimension reference type. |
| 41 | + * @param <T> the type of node pos this type describes. |
| 42 | + */ |
| 43 | + record Type<T extends NodePos>(ResourceLocation id, MapCodec<T> codec) {} |
| 44 | +} |
0 commit comments