use of net.minecraft.resources.ResourceKey in project Denizen-For-Bukkit by DenizenScript.
the class Handler method getBiomes.
@Override
public List<BiomeNMS> getBiomes(World world) {
ServerLevel level = ((CraftWorld) world).getHandle();
ArrayList<BiomeNMS> output = new ArrayList<>();
for (Map.Entry<ResourceKey<Biome>, Biome> pair : level.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY).entrySet()) {
output.add(new BiomeNMSImpl(level, pair.getKey().location().toString()));
}
return output;
}
use of net.minecraft.resources.ResourceKey in project SpongeCommon by SpongePowered.
the class CompassItemData method register.
static void register(final DataProviderRegistrator registrator) {
registrator.asMutable(ItemStack.class).create(Keys.LODESTONE).get(stack -> {
if (CompassItem.isLodestoneCompass(stack)) {
final CompoundTag tag = stack.getOrCreateTag();
final Optional<ResourceKey<Level>> dimension = CompassItem.getLodestoneDimension(tag);
if (dimension.isPresent()) {
return ServerLocation.of((ServerWorld) SpongeCommon.server().getLevel(dimension.get()), VecHelper.toVector3d(NbtUtils.readBlockPos(tag.getCompound("LodestonePos"))));
}
}
return null;
}).set((stack, location) -> {
final CompoundTag tag = stack.getOrCreateTag();
tag.put("LodestonePos", NbtUtils.writeBlockPos(VecHelper.toBlockPos(location)));
Level.RESOURCE_KEY_CODEC.encodeStart(NbtOps.INSTANCE, ((net.minecraft.server.level.ServerLevel) location.world()).dimension()).resultOrPartial(SpongeCommon.logger()::error).ifPresent(dimension -> tag.put("LodestoneDimension", dimension));
tag.putBoolean("LodestoneTracked", true);
}).delete(stack -> {
final CompoundTag tag = stack.getTag();
if (tag != null) {
tag.remove("LodestoneDimension");
tag.remove("LodestonePos");
tag.remove("LodestoneTracked");
}
});
}
use of net.minecraft.resources.ResourceKey in project Denizen-For-Bukkit by DenizenScript.
the class Handler method getBiomes.
@Override
public List<BiomeNMS> getBiomes(World world) {
ServerLevel level = ((CraftWorld) world).getHandle();
ArrayList<BiomeNMS> output = new ArrayList<>();
for (Map.Entry<ResourceKey<Biome>, Biome> pair : level.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY).entrySet()) {
output.add(new BiomeNMSImpl(level, pair.getKey().location().toString()));
}
return output;
}
Aggregations