
I am having issues making a compass item that tracks a location, I have set the lodestone nbt but it will not track the location.
fooeyround opened this issue ยท 8 comments
Do you have a discord?
also I am basically making a lodestone compass that instead of tracking a loadstone tracks another position. in this case a player. but the location seems to be not used by the client, and the nbt data is there, do you know why this may happen? also the item the item is imitating is the compass item...
-
Could you sent your code? Likely you don't have required nbt data on the item
is a basic example of the way I am using the tags, is there a special method to set it and not be remapped?
I found that all the tags I set to the stack are prefixed under Polymer is there a way to set the vanilla item's tags
I am on 1.19.3.. and
NbtCompound compound = stack.getOrCreateNbt();
BlockPos blockPos = user.getBlockPos();
PlayerEntity trackedPlayer = getPlayerFromString(world,compound.getString("tracked_player"));
if (stack.getCount() > 1 || compound.getInt("uses") == 0 || trackedPlayer == null) {
return TypedActionResult.fail(stack);
}```
or a better part is this.. as that does not need to be remapped
`
private void writeNbt(RegistryKey<World> worldKey, BlockPos pos, NbtCompound nbt) {
nbt.put("LodestonePos", NbtHelper.fromBlockPos(pos));
DataResult<NbtElement> dataResult = World.CODEC.encodeStart(NbtOps.INSTANCE, worldKey);
Objects.requireNonNull(PlayerTracking.LOGGER);
dataResult.resultOrPartial(PlayerTracking.LOGGER::error).ifPresent((nbtElement) -> nbt.put("LodestoneDimension", nbtElement));
nbt.putBoolean("PlayerTracked", true);
}
`
this is called right under that..