use of net.minecraft.network.FriendlyByteBuf 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);
}
use of net.minecraft.network.FriendlyByteBuf in project Denizen-For-Bukkit by DenizenScript.
the class DenizenNetworkManagerImpl method copyPacket.
public static FriendlyByteBuf copyPacket(Packet<?> original) {
try {
FriendlyByteBuf copier = new FriendlyByteBuf(Unpooled.buffer());
original.write(copier);
return copier;
} catch (Throwable ex) {
com.denizenscript.denizen.utilities.debugging.Debug.echoError(ex);
return null;
}
}
use of net.minecraft.network.FriendlyByteBuf in project Denizen-For-Bukkit by DenizenScript.
the class PacketHelperImpl method showMobHealth.
@Override
public void showMobHealth(Player player, LivingEntity mob, double health, double maxHealth) {
AttributeInstance attr = new AttributeInstance(Attributes.MAX_HEALTH, (a) -> {
});
attr.setBaseValue(maxHealth);
send(player, new ClientboundUpdateAttributesPacket(mob.getEntityId(), Collections.singletonList(attr)));
FriendlyByteBuf healthData = new FriendlyByteBuf(Unpooled.buffer());
healthData.writeVarInt(mob.getEntityId());
// health id
healthData.writeByte(9);
// type = float
healthData.writeVarInt(2);
healthData.writeFloat((float) health);
// Mark end of packet
healthData.writeByte(255);
send(player, new ClientboundSetEntityDataPacket(healthData));
}
use of net.minecraft.network.FriendlyByteBuf 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);
}
use of net.minecraft.network.FriendlyByteBuf in project Denizen-For-Bukkit by DenizenScript.
the class PacketHelperImpl method showMobHealth.
@Override
public void showMobHealth(Player player, LivingEntity mob, double health, double maxHealth) {
AttributeInstance attr = new AttributeInstance(Attributes.MAX_HEALTH, (a) -> {
});
attr.setBaseValue(maxHealth);
send(player, new ClientboundUpdateAttributesPacket(mob.getEntityId(), Collections.singletonList(attr)));
FriendlyByteBuf healthData = new FriendlyByteBuf(Unpooled.buffer());
healthData.writeVarInt(mob.getEntityId());
// health id
healthData.writeByte(9);
// type = float
healthData.writeVarInt(2);
healthData.writeFloat((float) health);
// Mark end of packet
healthData.writeByte(255);
send(player, new ClientboundSetEntityDataPacket(healthData));
}
Aggregations