| 1 | package net.minecraft.network.protocol.game;
|
| 2 |
|
| 3 | import net.minecraft.network.FriendlyByteBuf;
|
| 4 | import net.minecraft.network.codec.StreamCodec;
|
| 5 | import net.minecraft.network.protocol.Packet;
|
| 6 | import net.minecraft.network.protocol.PacketType;
|
| 7 | import net.minecraft.world.level.border.WorldBorder;
|
| 8 |
|
| 9 | public class ClientboundInitializeBorderPacket implements Packet<ClientGamePacketListener> {
|
| 10 | public static final StreamCodec<FriendlyByteBuf, ClientboundInitializeBorderPacket> STREAM_CODEC = Packet.codec(
|
| 11 | ClientboundInitializeBorderPacket::write, ClientboundInitializeBorderPacket::new
|
| 12 | );
|
| 13 | private final double newCenterX;
|
| 14 | private final double newCenterZ;
|
| 15 | private final double oldSize;
|
| 16 | private final double newSize;
|
| 17 | private final long lerpTime;
|
| 18 | private final int newAbsoluteMaxSize;
|
| 19 | private final int warningBlocks;
|
| 20 | private final int warningTime;
|
| 21 |
|
| 22 | private ClientboundInitializeBorderPacket(final FriendlyByteBuf input) {
|
| 23 | this.newCenterX = input.readDouble();
|
| 24 | this.newCenterZ = input.readDouble();
|
| 25 | this.oldSize = input.readDouble();
|
| 26 | this.newSize = input.readDouble();
|
| 27 | this.lerpTime = input.readVarLong();
|
| 28 | this.newAbsoluteMaxSize = input.readVarInt();
|
| 29 | this.warningBlocks = input.readVarInt();
|
| 30 | this.warningTime = input.readVarInt();
|
| 31 | }
|
| 32 |
|
| 33 | public ClientboundInitializeBorderPacket(final WorldBorder border) {
|
| 34 | this.newCenterX = border.getCenterX();
|
| 35 | this.newCenterZ = border.getCenterZ();
|
| 36 | this.oldSize = border.getSize();
|
| 37 | this.newSize = border.getLerpTarget();
|
| 38 | this.lerpTime = border.getLerpTime();
|
| 39 | this.newAbsoluteMaxSize = border.getAbsoluteMaxSize();
|
| 40 | this.warningBlocks = border.getWarningBlocks();
|
| 41 | this.warningTime = border.getWarningTime();
|
| 42 | }
|
| 43 |
|
| 44 | private void write(final FriendlyByteBuf output) {
|
| 45 | output.writeDouble(this.newCenterX);
|
| 46 | output.writeDouble(this.newCenterZ);
|
| 47 | output.writeDouble(this.oldSize);
|
| 48 | output.writeDouble(this.newSize);
|
| 49 | output.writeVarLong(this.lerpTime);
|
| 50 | output.writeVarInt(this.newAbsoluteMaxSize);
|
| 51 | output.writeVarInt(this.warningBlocks);
|
| 52 | output.writeVarInt(this.warningTime);
|
| 53 | }
|
| 54 |
|
| 55 | @Override
|
| 56 | public PacketType<ClientboundInitializeBorderPacket> type() {
|
| 57 | return GamePacketTypes.CLIENTBOUND_INITIALIZE_BORDER;
|
| 58 | }
|
| 59 |
|
| 60 | public void handle(final ClientGamePacketListener listener) {
|
| 61 | listener.handleInitializeBorder(this);
|
| 62 | }
|
| 63 |
|
| 64 | public double getNewCenterX() {
|
| 65 | return this.newCenterX;
|
| 66 | }
|
| 67 |
|
| 68 | public double getNewCenterZ() {
|
| 69 | return this.newCenterZ;
|
| 70 | }
|
| 71 |
|
| 72 | public double getNewSize() {
|
| 73 | return this.newSize;
|
| 74 | }
|
| 75 |
|
| 76 | public double getOldSize() {
|
| 77 | return this.oldSize;
|
| 78 | }
|
| 79 |
|
| 80 | public long getLerpTime() {
|
| 81 | return this.lerpTime;
|
| 82 | }
|
| 83 |
|
| 84 | public int getNewAbsoluteMaxSize() {
|
| 85 | return this.newAbsoluteMaxSize;
|
| 86 | }
|
| 87 |
|
| 88 | public int getWarningTime() {
|
| 89 | return this.warningTime;
|
| 90 | }
|
| 91 |
|
| 92 | public int getWarningBlocks() {
|
| 93 | return this.warningBlocks;
|
| 94 | }
|
| 95 | }
|
| 96 |
|