Search in sources :

Example 26 with ResourceLocation

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);
}
Also used : ClientboundUpdateAdvancementsPacket(net.minecraft.network.protocol.game.ClientboundUpdateAdvancementsPacket) ResourceLocation(net.minecraft.resources.ResourceLocation)

Example 27 with ResourceLocation

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;
}
Also used : ServerRecipeBook(net.minecraft.stats.ServerRecipeBook) ResourceLocation(net.minecraft.resources.ResourceLocation)

Example 28 with ResourceLocation

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);
}
Also used : FriendlyByteBuf(net.minecraft.network.FriendlyByteBuf) ResourceLocation(net.minecraft.resources.ResourceLocation)

Example 29 with ResourceLocation

use of net.minecraft.resources.ResourceLocation in project Denizen-For-Bukkit by DenizenScript.

the class PacketHelperImpl method sendBrand.

@Override
public void sendBrand(Player player, String brand) {
    ResourceLocation packetKey = new ResourceLocation("minecraft", "brand");
    FriendlyByteBuf buf = new FriendlyByteBuf(Unpooled.buffer());
    buf.writeUtf(brand);
    ClientboundCustomPayloadPacket packet = new ClientboundCustomPayloadPacket(packetKey, buf);
    send(player, packet);
}
Also used : FriendlyByteBuf(net.minecraft.network.FriendlyByteBuf) ResourceLocation(net.minecraft.resources.ResourceLocation)

Example 30 with ResourceLocation

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);
}
Also used : ServerLevel(net.minecraft.server.level.ServerLevel) Biome(net.minecraft.world.level.biome.Biome) ResourceLocation(net.minecraft.resources.ResourceLocation) CraftWorld(org.bukkit.craftbukkit.v1_18_R1.CraftWorld) BiomeNMSImpl(com.denizenscript.denizen.nms.v1_18.impl.BiomeNMSImpl)

Aggregations

ResourceLocation (net.minecraft.resources.ResourceLocation)86 ArrayList (java.util.ArrayList)7 Map (java.util.Map)7 LogManager (org.apache.logging.log4j.LogManager)7 Logger (org.apache.logging.log4j.Logger)7 List (java.util.List)6 FriendlyByteBuf (net.minecraft.network.FriendlyByteBuf)6 JsonObject (com.google.gson.JsonObject)5 CommandSyntaxException (com.mojang.brigadier.exceptions.CommandSyntaxException)5 IOException (java.io.IOException)5 Collectors (java.util.stream.Collectors)5 StringReader (com.mojang.brigadier.StringReader)4 CompoundTag (net.minecraft.nbt.CompoundTag)4 CraftServer (org.bukkit.craftbukkit.v1_17_R1.CraftServer)4 ItemStack (org.bukkit.inventory.ItemStack)4 InputStream (java.io.InputStream)3 Collections (java.util.Collections)3 Set (java.util.Set)3 Function (java.util.function.Function)3 Nullable (javax.annotation.Nullable)3