Search in sources :

Example 36 with ResourceLocation

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

the class PlayerHelperImpl method stopSound.

@Override
public void stopSound(Player player, String sound, SoundCategory category) {
    ResourceLocation soundKey = sound == null ? null : new ResourceLocation(sound);
    net.minecraft.sounds.SoundSource nmsCategory = category == null ? null : net.minecraft.sounds.SoundSource.valueOf(category.name());
    ((CraftPlayer) player).getHandle().connection.send(new ClientboundStopSoundPacket(soundKey, nmsCategory));
}
Also used : ResourceLocation(net.minecraft.resources.ResourceLocation) CraftPlayer(org.bukkit.craftbukkit.v1_18_R1.entity.CraftPlayer)

Example 37 with ResourceLocation

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

the class PacketHelperImpl method showDebugTestMarker.

@Override
public void showDebugTestMarker(Player player, Location location, ColorTag color, int alpha, String name, int time) {
    ResourceLocation packetKey = new ResourceLocation("minecraft", "debug/game_test_add_marker");
    FriendlyByteBuf buf = new FriendlyByteBuf(Unpooled.buffer());
    buf.writeBlockPos(new BlockPos(location.getBlockX(), location.getBlockY(), location.getBlockZ()));
    int colorInt = color.getColor().getBlue() | (color.getColor().getGreen() << 8) | (color.getColor().getRed() << 16) | (alpha << 24);
    buf.writeInt(colorInt);
    buf.writeByteArray(name.getBytes(StandardCharsets.UTF_8));
    buf.writeInt(time);
    ClientboundCustomPayloadPacket packet = new ClientboundCustomPayloadPacket(packetKey, buf);
    send(player, packet);
}
Also used : FriendlyByteBuf(net.minecraft.network.FriendlyByteBuf) ResourceLocation(net.minecraft.resources.ResourceLocation) BlockPos(net.minecraft.core.BlockPos)

Example 38 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 39 with ResourceLocation

use of net.minecraft.resources.ResourceLocation in project MyPet by xXKeyleXx.

the class EntityMyVillager method updateVisuals.

@Override
public void updateVisuals() {
    this.getEntityData().set(AGE_WATCHER, getMyPet().isBaby());
    String professionKey = MyVillager.Profession.values()[getMyPet().getProfession()].getKey();
    VillagerProfession profession = Registry.VILLAGER_PROFESSION.get(new ResourceLocation(professionKey));
    // TODO
    VillagerType type = Registry.VILLAGER_TYPE.get(new ResourceLocation(getMyPet().getType().getKey()));
    this.getEntityData().set(PROFESSION_WATCHER, new VillagerData(type, profession, getMyPet().getVillagerLevel()));
}
Also used : VillagerType(net.minecraft.world.entity.npc.VillagerType) VillagerProfession(net.minecraft.world.entity.npc.VillagerProfession) ResourceLocation(net.minecraft.resources.ResourceLocation) VillagerData(net.minecraft.world.entity.npc.VillagerData)

Example 40 with ResourceLocation

use of net.minecraft.resources.ResourceLocation in project MyPet by xXKeyleXx.

the class EntityMyVillager method updateVisuals.

@Override
public void updateVisuals() {
    this.getEntityData().set(AGE_WATCHER, getMyPet().isBaby());
    String professionKey = MyVillager.Profession.values()[getMyPet().getProfession()].getKey();
    VillagerProfession profession = Registry.VILLAGER_PROFESSION.get(new ResourceLocation(professionKey));
    // TODO
    VillagerType type = Registry.VILLAGER_TYPE.get(new ResourceLocation(getMyPet().getType().getKey()));
    this.getEntityData().set(PROFESSION_WATCHER, new VillagerData(type, profession, getMyPet().getVillagerLevel()));
}
Also used : VillagerType(net.minecraft.world.entity.npc.VillagerType) VillagerProfession(net.minecraft.world.entity.npc.VillagerProfession) ResourceLocation(net.minecraft.resources.ResourceLocation) VillagerData(net.minecraft.world.entity.npc.VillagerData)

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