Search in sources :

Example 31 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)

Example 32 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().broadcastAll(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 33 with ResourceLocation

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);
}
Also used : ResourceLocation(net.minecraft.resources.ResourceLocation) CraftServer(org.bukkit.craftbukkit.v1_18_R1.CraftServer)

Example 34 with ResourceLocation

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);
}
Also used : ResourceLocation(net.minecraft.resources.ResourceLocation) CraftServer(org.bukkit.craftbukkit.v1_18_R1.CraftServer)

Example 35 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)

Aggregations

ResourceLocation (net.minecraft.resources.ResourceLocation)130 Map (java.util.Map)12 IOException (java.io.IOException)11 ArrayList (java.util.ArrayList)11 CompoundTag (net.minecraft.nbt.CompoundTag)11 List (java.util.List)10 BlockPos (net.minecraft.core.BlockPos)9 Collectors (java.util.stream.Collectors)7 Block (net.minecraft.world.level.block.Block)7 LogManager (org.apache.logging.log4j.LogManager)7 Logger (org.apache.logging.log4j.Logger)7 JsonObject (com.google.gson.JsonObject)6 HashMap (java.util.HashMap)6 FriendlyByteBuf (net.minecraft.network.FriendlyByteBuf)6 LivingEntity (net.minecraft.world.entity.LivingEntity)6 JsonElement (com.google.gson.JsonElement)5 CommandSyntaxException (com.mojang.brigadier.exceptions.CommandSyntaxException)5 Registry (net.minecraft.core.Registry)5 ServerLevel (net.minecraft.server.level.ServerLevel)5 InputStream (java.io.InputStream)4