use of net.minecraft.client.network.packet.CustomPayloadS2CPacket in project ImmersivePortalsMod by qouteall.
the class MyNetwork method createStcSpawnEntity.
// NOTE my packet is redirected but I cannot get the packet handler info here
public static CustomPayloadS2CPacket createStcSpawnEntity(Entity entity) {
EntityType entityType = entity.getType();
PacketByteBuf buf = new PacketByteBuf(Unpooled.buffer());
buf.writeString(EntityType.getId(entityType).toString());
buf.writeInt(entity.getEntityId());
buf.writeInt(entity.dimension.getRawId());
CompoundTag tag = new CompoundTag();
entity.toTag(tag);
buf.writeCompoundTag(tag);
return new CustomPayloadS2CPacket(id_stcSpawnEntity, buf);
}
use of net.minecraft.client.network.packet.CustomPayloadS2CPacket in project ImmersivePortalsMod by qouteall.
the class MyNetwork method createSpawnLoadingIndicator.
public static CustomPayloadS2CPacket createSpawnLoadingIndicator(DimensionType dimensionType, Vec3d pos) {
PacketByteBuf buf = new PacketByteBuf(Unpooled.buffer());
buf.writeInt(dimensionType.getRawId());
buf.writeDouble(pos.x);
buf.writeDouble(pos.y);
buf.writeDouble(pos.z);
return new CustomPayloadS2CPacket(id_stcSpawnLoadingIndicator, buf);
}
use of net.minecraft.client.network.packet.CustomPayloadS2CPacket in project ImmersivePortalsMod by qouteall.
the class ServerTeleportationManager method sendPositionConfirmMessage.
private void sendPositionConfirmMessage(ServerPlayerEntity player) {
CustomPayloadS2CPacket packet = MyNetwork.createStcDimensionConfirm(player.dimension, player.getPos());
player.networkHandler.sendPacket(packet);
}
use of net.minecraft.client.network.packet.CustomPayloadS2CPacket in project ImmersivePortalsMod by qouteall.
the class MyNetwork method createCustomPacketStc.
// you can input a lambda expression and it will be invoked remotely
// but java serialization is not stable
@Deprecated
public static CustomPayloadS2CPacket createCustomPacketStc(ICustomStcPacket serializable) {
// it copies the data twice but as the packet is small it's of no problem
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
ObjectOutputStream stream = null;
try {
stream = new ObjectOutputStream(byteArrayOutputStream);
stream.writeObject(serializable);
} catch (IOException e) {
throw new IllegalArgumentException(e);
}
ByteBuf buffer = Unpooled.buffer();
buffer.writeBytes(byteArrayOutputStream.toByteArray());
PacketByteBuf buf = new PacketByteBuf(buffer);
return new CustomPayloadS2CPacket(id_stcCustom, buf);
}
use of net.minecraft.client.network.packet.CustomPayloadS2CPacket in project ImmersivePortalsMod by qouteall.
the class MyNetwork method createStcDimensionConfirm.
public static CustomPayloadS2CPacket createStcDimensionConfirm(DimensionType dimensionType, Vec3d pos) {
PacketByteBuf buf = new PacketByteBuf(Unpooled.buffer());
buf.writeInt(dimensionType.getRawId());
buf.writeDouble(pos.x);
buf.writeDouble(pos.y);
buf.writeDouble(pos.z);
return new CustomPayloadS2CPacket(id_stcDimensionConfirm, buf);
}
Aggregations