Search in sources :

Example 1 with DataWatcherWrapper

use of dev.rosewood.rosestacker.nms.v1_16_R2.entity.DataWatcherWrapper in project RoseStacker by Rosewood-Development.

the class NMSHandlerImpl method updateEntityNameTagVisibilityForPlayer.

@Override
public void updateEntityNameTagVisibilityForPlayer(Player player, org.bukkit.entity.Entity entity, boolean customNameVisible) {
    try {
        List<DataWatcher.Item<?>> dataItems = Lists.newArrayList(new DataWatcher.Item<>(DataWatcherRegistry.i.a(3), customNameVisible));
        PacketPlayOutEntityMetadata packetPlayOutEntityMetadata = new PacketPlayOutEntityMetadata(entity.getEntityId(), new DataWatcherWrapper(dataItems), false);
        ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packetPlayOutEntityMetadata);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : PacketPlayOutEntityMetadata(net.minecraft.server.v1_16_R3.PacketPlayOutEntityMetadata) DataWatcherWrapper(dev.rosewood.rosestacker.nms.v1_16_R3.entity.DataWatcherWrapper) CraftPlayer(org.bukkit.craftbukkit.v1_16_R3.entity.CraftPlayer) DataWatcher(net.minecraft.server.v1_16_R3.DataWatcher)

Example 2 with DataWatcherWrapper

use of dev.rosewood.rosestacker.nms.v1_16_R2.entity.DataWatcherWrapper in project RoseStacker by Rosewood-Development.

the class NMSHandlerImpl method updateEntityNameTagForPlayer.

@Override
public void updateEntityNameTagForPlayer(Player player, org.bukkit.entity.Entity entity, String customName, boolean customNameVisible) {
    try {
        List<DataWatcher.Item<?>> dataWatchers = new ArrayList<>();
        Optional<IChatBaseComponent> nameComponent = Optional.ofNullable(CraftChatMessage.fromStringOrNull(customName));
        dataWatchers.add(new DataWatcher.Item<>(DataWatcherRegistry.f.a(2), nameComponent));
        dataWatchers.add(new DataWatcher.Item<>(DataWatcherRegistry.i.a(3), customNameVisible));
        PacketPlayOutEntityMetadata packetPlayOutEntityMetadata = new PacketPlayOutEntityMetadata(entity.getEntityId(), new DataWatcherWrapper(dataWatchers), false);
        ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packetPlayOutEntityMetadata);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : ArrayList(java.util.ArrayList) PacketPlayOutEntityMetadata(net.minecraft.server.v1_16_R2.PacketPlayOutEntityMetadata) IChatBaseComponent(net.minecraft.server.v1_16_R2.IChatBaseComponent) DataWatcherWrapper(dev.rosewood.rosestacker.nms.v1_16_R2.entity.DataWatcherWrapper) CraftPlayer(org.bukkit.craftbukkit.v1_16_R2.entity.CraftPlayer) DataWatcher(net.minecraft.server.v1_16_R2.DataWatcher)

Example 3 with DataWatcherWrapper

use of dev.rosewood.rosestacker.nms.v1_16_R2.entity.DataWatcherWrapper in project RoseStacker by Rosewood-Development.

the class HologramImpl method update.

@Override
protected void update(Player player) {
    Boolean visible = this.watchers.get(player);
    if (visible == null)
        return;
    List<DataWatcher.Item<?>> dataItems = new ArrayList<>();
    Optional<IChatBaseComponent> nameComponent = Optional.of(CraftChatMessage.fromStringOrNull(this.text));
    dataItems.add(new DataWatcher.Item<>(DataWatcherRegistry.f.a(2), nameComponent));
    dataItems.add(new DataWatcher.Item<>(DataWatcherRegistry.i.a(3), visible));
    dataItems.add(new DataWatcher.Item<>(DataWatcherRegistry.c.a(7), 0.5F));
    dataItems.add(new DataWatcher.Item<>(DataWatcherRegistry.i.a(9), true));
    dataItems.add(new DataWatcher.Item<>(DataWatcherRegistry.j.a(10), new ParticleParamBlock(Particles.BLOCK, Blocks.AIR.getBlockData())));
    PacketPlayOutEntityMetadata packet = new PacketPlayOutEntityMetadata(this.entityId, new DataWatcherWrapper(dataItems), false);
    ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
}
Also used : ArrayList(java.util.ArrayList) PacketPlayOutEntityMetadata(net.minecraft.server.v1_16_R2.PacketPlayOutEntityMetadata) IChatBaseComponent(net.minecraft.server.v1_16_R2.IChatBaseComponent) DataWatcherWrapper(dev.rosewood.rosestacker.nms.v1_16_R2.entity.DataWatcherWrapper) CraftPlayer(org.bukkit.craftbukkit.v1_16_R2.entity.CraftPlayer) ParticleParamBlock(net.minecraft.server.v1_16_R2.ParticleParamBlock) DataWatcher(net.minecraft.server.v1_16_R2.DataWatcher)

Example 4 with DataWatcherWrapper

use of dev.rosewood.rosestacker.nms.v1_16_R2.entity.DataWatcherWrapper in project RoseStacker by Rosewood-Development.

the class NMSHandlerImpl method updateEntityNameTagForPlayer.

@Override
public void updateEntityNameTagForPlayer(Player player, org.bukkit.entity.Entity entity, String customName, boolean customNameVisible) {
    try {
        List<DataWatcher.Item<?>> dataWatchers = new ArrayList<>();
        Optional<IChatBaseComponent> nameComponent = Optional.ofNullable(CraftChatMessage.fromStringOrNull(customName));
        dataWatchers.add(new DataWatcher.Item<>(DataWatcherRegistry.f.a(2), nameComponent));
        dataWatchers.add(new DataWatcher.Item<>(DataWatcherRegistry.i.a(3), customNameVisible));
        PacketPlayOutEntityMetadata packetPlayOutEntityMetadata = new PacketPlayOutEntityMetadata(entity.getEntityId(), new DataWatcherWrapper(dataWatchers), false);
        ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packetPlayOutEntityMetadata);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : ArrayList(java.util.ArrayList) PacketPlayOutEntityMetadata(net.minecraft.server.v1_16_R3.PacketPlayOutEntityMetadata) IChatBaseComponent(net.minecraft.server.v1_16_R3.IChatBaseComponent) DataWatcherWrapper(dev.rosewood.rosestacker.nms.v1_16_R3.entity.DataWatcherWrapper) CraftPlayer(org.bukkit.craftbukkit.v1_16_R3.entity.CraftPlayer) DataWatcher(net.minecraft.server.v1_16_R3.DataWatcher)

Example 5 with DataWatcherWrapper

use of dev.rosewood.rosestacker.nms.v1_16_R2.entity.DataWatcherWrapper in project RoseStacker by Rosewood-Development.

the class HologramImpl method update.

@Override
protected void update(Player player) {
    Boolean visible = this.watchers.get(player);
    if (visible == null)
        return;
    List<DataWatcher.Item<?>> dataItems = new ArrayList<>();
    Optional<IChatBaseComponent> nameComponent = Optional.of(CraftChatMessage.fromStringOrNull(this.text));
    dataItems.add(new DataWatcher.Item<>(DataWatcherRegistry.f.a(2), nameComponent));
    dataItems.add(new DataWatcher.Item<>(DataWatcherRegistry.i.a(3), visible));
    dataItems.add(new DataWatcher.Item<>(DataWatcherRegistry.c.a(7), 0.5F));
    dataItems.add(new DataWatcher.Item<>(DataWatcherRegistry.i.a(9), true));
    dataItems.add(new DataWatcher.Item<>(DataWatcherRegistry.j.a(10), new ParticleParamBlock(Particles.BLOCK, Blocks.AIR.getBlockData())));
    PacketPlayOutEntityMetadata packet = new PacketPlayOutEntityMetadata(this.entityId, new DataWatcherWrapper(dataItems), false);
    ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
}
Also used : ArrayList(java.util.ArrayList) PacketPlayOutEntityMetadata(net.minecraft.server.v1_16_R3.PacketPlayOutEntityMetadata) IChatBaseComponent(net.minecraft.server.v1_16_R3.IChatBaseComponent) DataWatcherWrapper(dev.rosewood.rosestacker.nms.v1_16_R3.entity.DataWatcherWrapper) CraftPlayer(org.bukkit.craftbukkit.v1_16_R3.entity.CraftPlayer) ParticleParamBlock(net.minecraft.server.v1_16_R3.ParticleParamBlock) DataWatcher(net.minecraft.server.v1_16_R3.DataWatcher)

Aggregations

ArrayList (java.util.ArrayList)4 DataWatcherWrapper (dev.rosewood.rosestacker.nms.v1_16_R2.entity.DataWatcherWrapper)3 DataWatcherWrapper (dev.rosewood.rosestacker.nms.v1_16_R3.entity.DataWatcherWrapper)3 DataWatcher (net.minecraft.server.v1_16_R2.DataWatcher)3 PacketPlayOutEntityMetadata (net.minecraft.server.v1_16_R2.PacketPlayOutEntityMetadata)3 DataWatcher (net.minecraft.server.v1_16_R3.DataWatcher)3 PacketPlayOutEntityMetadata (net.minecraft.server.v1_16_R3.PacketPlayOutEntityMetadata)3 CraftPlayer (org.bukkit.craftbukkit.v1_16_R2.entity.CraftPlayer)3 CraftPlayer (org.bukkit.craftbukkit.v1_16_R3.entity.CraftPlayer)3 IChatBaseComponent (net.minecraft.server.v1_16_R2.IChatBaseComponent)2 IChatBaseComponent (net.minecraft.server.v1_16_R3.IChatBaseComponent)2 ParticleParamBlock (net.minecraft.server.v1_16_R2.ParticleParamBlock)1 ParticleParamBlock (net.minecraft.server.v1_16_R3.ParticleParamBlock)1