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 ItemHelperImpl method registerSmithingRecipe.
@Override
public void registerSmithingRecipe(String keyName, ItemStack result, ItemStack[] baseItem, boolean baseExact, ItemStack[] upgradeItem, boolean upgradeExact) {
ResourceLocation key = new ResourceLocation("denizen", keyName);
Ingredient baseItemRecipe = itemArrayToRecipe(baseItem, baseExact);
Ingredient upgradeItemRecipe = itemArrayToRecipe(upgradeItem, upgradeExact);
UpgradeRecipe recipe = new UpgradeRecipe(key, baseItemRecipe, upgradeItemRecipe, CraftItemStack.asNMSCopy(result));
((CraftServer) Bukkit.getServer()).getServer().getRecipeManager().addRecipe(recipe);
}
use of net.minecraft.resources.ResourceLocation in project Denizen-For-Bukkit by DenizenScript.
the class ItemHelperImpl method registerStonecuttingRecipe.
@Override
public void registerStonecuttingRecipe(String keyName, String group, ItemStack result, ItemStack[] ingredient, boolean exact) {
ResourceLocation key = new ResourceLocation("denizen", keyName);
Ingredient itemRecipe = itemArrayToRecipe(ingredient, exact);
StonecutterRecipe recipe = new StonecutterRecipe(key, group, itemRecipe, CraftItemStack.asNMSCopy(result));
((CraftServer) Bukkit.getServer()).getServer().getRecipeManager().addRecipe(recipe);
}
use of net.minecraft.resources.ResourceLocation in project Denizen-For-Bukkit by DenizenScript.
the class PacketHelperImpl method clearDebugTestMarker.
@Override
public void clearDebugTestMarker(Player player) {
ResourceLocation packetKey = new ResourceLocation("minecraft", "debug/game_test_clear");
FriendlyByteBuf buf = new FriendlyByteBuf(Unpooled.buffer());
ClientboundCustomPayloadPacket packet = new ClientboundCustomPayloadPacket(packetKey, buf);
send(player, packet);
}
Aggregations