use of net.minecraft.resources.ResourceLocation in project Denizen-For-Bukkit by DenizenScript.
the class Handler method getBiomeAt.
@Override
public BiomeNMS getBiomeAt(Block block) {
// Based on CraftWorld source
ServerLevel level = ((CraftWorld) block.getWorld()).getHandle();
Biome biome = level.getNoiseBiome(block.getX() >> 2, block.getY() >> 2, block.getZ() >> 2);
ResourceLocation key = level.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY).getKey(biome);
String keyText = key.getNamespace().equals("minecraft") ? key.getPath() : key.toString();
return new BiomeNMSImpl(level, keyText);
}
use of net.minecraft.resources.ResourceLocation in project Denizen-For-Bukkit by DenizenScript.
the class AdvancementHelperImpl method unregister.
@Override
public void unregister(com.denizenscript.denizen.nms.util.Advancement advancement) {
if (advancement.temporary || !advancement.registered) {
return;
}
Map<ResourceLocation, Advancement> advancements = getAdvancementDataWorld().advancements.advancements;
ResourceLocation key = asResourceLocation(advancement.key);
Advancement nms = advancements.get(key);
if (advancement.parent == null) {
Set<Advancement> roots = ReflectionHelper.getFieldValue(AdvancementList.class, ReflectionMappingsInfo.AdvancementList_roots, getAdvancementDataWorld().advancements);
roots.remove(nms);
} else {
Set<Advancement> branches = ReflectionHelper.getFieldValue(AdvancementList.class, ReflectionMappingsInfo.AdvancementList_tasks, getAdvancementDataWorld().advancements);
branches.remove(nms);
}
advancements.remove(key);
advancement.registered = false;
((CraftServer) Bukkit.getServer()).getHandle().sendAll(new ClientboundUpdateAdvancementsPacket(false, Collections.emptySet(), Collections.singleton(key), Collections.emptyMap()), (net.minecraft.world.entity.player.Player) null);
}
use of net.minecraft.resources.ResourceLocation in project Denizen-For-Bukkit by DenizenScript.
the class Handler method getBiomeAt.
@Override
public BiomeNMS getBiomeAt(Block block) {
// Based on CraftWorld source
ServerLevel level = ((CraftWorld) block.getWorld()).getHandle();
Biome biome = level.getNoiseBiome(block.getX() >> 2, block.getY() >> 2, block.getZ() >> 2);
ResourceLocation key = level.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY).getKey(biome);
String keyText = key.getNamespace().equals("minecraft") ? key.getPath() : key.toString();
return new BiomeNMSImpl(level, keyText);
}
use of net.minecraft.resources.ResourceLocation in project Denizen-For-Bukkit by DenizenScript.
the class AdvancementHelperImpl method unregister.
@Override
public void unregister(com.denizenscript.denizen.nms.util.Advancement advancement) {
if (advancement.temporary || !advancement.registered) {
return;
}
Map<ResourceLocation, Advancement> advancements = getAdvancementDataWorld().advancements.advancements;
ResourceLocation key = asResourceLocation(advancement.key);
Advancement nms = advancements.get(key);
if (advancement.parent == null) {
Set<Advancement> roots = ReflectionHelper.getFieldValue(AdvancementList.class, ReflectionMappingsInfo.AdvancementList_roots, getAdvancementDataWorld().advancements);
roots.remove(nms);
} else {
Set<Advancement> branches = ReflectionHelper.getFieldValue(AdvancementList.class, ReflectionMappingsInfo.AdvancementList_tasks, getAdvancementDataWorld().advancements);
branches.remove(nms);
}
advancements.remove(key);
advancement.registered = false;
((CraftServer) Bukkit.getServer()).getHandle().broadcastAll(new ClientboundUpdateAdvancementsPacket(false, Collections.emptySet(), Collections.singleton(key), Collections.emptyMap()), (net.minecraft.world.entity.player.Player) null);
}
use of net.minecraft.resources.ResourceLocation in project Denizen-For-Bukkit by DenizenScript.
the class EntityHelperImpl method getDiscoveredRecipes.
public List<String> getDiscoveredRecipes(Player player) {
try {
ServerRecipeBook book = ((CraftPlayer) player).getHandle().getRecipeBook();
Set<ResourceLocation> set = (Set<ResourceLocation>) RECIPE_BOOK_DISCOVERED_SET.get(book);
List<String> output = new ArrayList<>();
for (ResourceLocation key : set) {
output.add(key.toString());
}
return output;
} catch (Throwable ex) {
Debug.echoError(ex);
}
return null;
}
Aggregations