use of net.minecraft.network.PacketByteBuf in project LittleMaidModelLoader-Fabric by SistrScarlet.
the class SyncMultiModelPacket method createS2CPacket.
public static PacketByteBuf createS2CPacket(Entity entity, IHasMultiModel hasMultiModel) {
PacketByteBuf passedData = new PacketByteBuf(Unpooled.buffer());
passedData.writeInt(entity.getEntityId());
passedData.writeString(hasMultiModel.getTextureHolder(Layer.SKIN, Part.HEAD).getTextureName());
for (Part part : Part.values()) {
passedData.writeString(hasMultiModel.getTextureHolder(Layer.INNER, part).getTextureName());
}
passedData.writeEnumConstant(hasMultiModel.getColor());
passedData.writeBoolean(hasMultiModel.isContract());
return passedData;
}
use of net.minecraft.network.PacketByteBuf in project LittleMaidModelLoader-Fabric by SistrScarlet.
the class SyncMultiModelPacket method createC2SPacket.
public static PacketByteBuf createC2SPacket(Entity entity, IHasMultiModel hasMultiModel) {
PacketByteBuf passedData = new PacketByteBuf(Unpooled.buffer());
passedData.writeInt(entity.getEntityId());
passedData.writeString(hasMultiModel.getTextureHolder(Layer.SKIN, Part.HEAD).getTextureName());
for (Part part : Part.values()) {
passedData.writeString(hasMultiModel.getTextureHolder(Layer.INNER, part).getTextureName());
}
passedData.writeEnumConstant(hasMultiModel.getColor());
passedData.writeBoolean(hasMultiModel.isContract());
return passedData;
}
use of net.minecraft.network.PacketByteBuf in project LittleMaidModelLoader-Fabric by SistrScarlet.
the class CustomMobSpawnPacket method receiveS2CPacket.
@Environment(EnvType.CLIENT)
public static void receiveS2CPacket(MinecraftClient client, ClientPlayNetworkHandler handler, PacketByteBuf buf, PacketSender responseSender) {
int id = buf.readVarInt();
UUID uuid = buf.readUuid();
int entityTypeId = buf.readVarInt();
double x = buf.readDouble();
double y = buf.readDouble();
double z = buf.readDouble();
float yaw = (buf.readByte() * 360F) / 256F;
float pitch = (buf.readByte() * 360F) / 256F;
float headYaw = (buf.readByte() * 360F) / 256F;
float velocityX = buf.readShort() / 8000F;
float velocityY = buf.readShort() / 8000F;
float velocityZ = buf.readShort() / 8000F;
// そのまんまbuf渡すと、spawnが実行されるまでの間に読み込めなくなるため、コピーする
PacketByteBuf additional = new PacketByteBuf(buf.copy());
client.execute(() -> spawn(id, uuid, entityTypeId, x, y, z, yaw, pitch, headYaw, velocityX, velocityY, velocityZ, additional));
}
use of net.minecraft.network.PacketByteBuf in project Carrier by GabrielOlvH.
the class MixinClientPlayerEntity method carrier_sendPacket.
@Inject(method = "tick", at = @At("RETURN"))
private void carrier_sendPacket(CallbackInfo ci) {
if (lastPressed != pressed) {
lastPressed = pressed;
PacketByteBuf buf = new PacketByteBuf(Unpooled.buffer());
buf.writeBoolean(pressed);
ClientSidePacketRegistry.INSTANCE.sendToServer(Carrier.SET_CAN_CARRY_PACKET, buf);
}
}
use of net.minecraft.network.PacketByteBuf in project quilt-standard-libraries by QuiltMC.
the class NetworkingImpl method init.
public static void init(ModContainer mod) {
// Login setup
ServerLoginConnectionEvents.QUERY_START.register((handler, server, sender, synchronizer) -> {
// Send early registration packet
PacketByteBuf buf = PacketByteBufs.create();
Collection<Identifier> channelsNames = ServerPlayNetworking.getGlobalReceivers();
buf.writeVarInt(channelsNames.size());
for (Identifier id : channelsNames) {
buf.writeIdentifier(id);
}
sender.sendPacket(EARLY_REGISTRATION_CHANNEL, buf);
sender.sendPacket(EARLY_REGISTRATION_CHANNEL_FABRIC, buf);
NetworkingImpl.LOGGER.debug("Sent accepted channels to the client for \"{}\"", handler.getConnectionInfo());
});
ServerLoginNetworking.registerGlobalReceiver(EARLY_REGISTRATION_CHANNEL, NetworkingImpl::receiveEarlyRegistration);
ServerLoginNetworking.registerGlobalReceiver(EARLY_REGISTRATION_CHANNEL_FABRIC, NetworkingImpl::receiveEarlyRegistration);
}
Aggregations