From 22467698377b345b706dd2104f64c72ef06965b9 Mon Sep 17 00:00:00 2001 From: NoJokeFNA Date: Wed, 11 May 2022 16:59:00 +0200 Subject: [PATCH 1/5] feat: added WrapperPlayServerSculkVibrationSignal --- ...WrapperPlayServerSculkVibrationSignal.java | 128 ++++++++++++++++++ 1 file changed, 128 insertions(+) create mode 100644 api/src/main/java/com/github/retrooper/packetevents/wrapper/play/server/WrapperPlayServerSculkVibrationSignal.java diff --git a/api/src/main/java/com/github/retrooper/packetevents/wrapper/play/server/WrapperPlayServerSculkVibrationSignal.java b/api/src/main/java/com/github/retrooper/packetevents/wrapper/play/server/WrapperPlayServerSculkVibrationSignal.java new file mode 100644 index 0000000000..5e8a891f92 --- /dev/null +++ b/api/src/main/java/com/github/retrooper/packetevents/wrapper/play/server/WrapperPlayServerSculkVibrationSignal.java @@ -0,0 +1,128 @@ +/* + * This file is part of packetevents - https://github.com/retrooper/packetevents + * Copyright (C) 2021 retrooper and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.github.retrooper.packetevents.wrapper.play.server; + +import com.github.retrooper.packetevents.event.PacketSendEvent; +import com.github.retrooper.packetevents.manager.server.ServerVersion; +import com.github.retrooper.packetevents.protocol.packettype.PacketType; +import com.github.retrooper.packetevents.util.Vector3i; +import com.github.retrooper.packetevents.wrapper.PacketWrapper; + +public class WrapperPlayServerSculkVibrationSignal extends PacketWrapper { + private Vector3i sourcePosition; + private String destinationIdentifier; + private Vector3i blockPosition; + private int arrivalTicks; + + public WrapperPlayServerSculkVibrationSignal(PacketSendEvent event) { + super(event); + } + + public WrapperPlayServerSculkVibrationSignal(Vector3i sourcePosition, String destinationIdentifier, Vector3i blockPosition, int arrivalTicks) { + super(PacketType.Play.Server.SCULK_VIBRATION_SIGNAL); + this.sourcePosition = sourcePosition; + this.destinationIdentifier = destinationIdentifier; + this.blockPosition = blockPosition; + this.arrivalTicks = arrivalTicks; + } + + @Override + public void read() { + if (serverVersion.isNewerThanOrEquals(ServerVersion.V_1_8)) { + this.sourcePosition = new Vector3i(readLong()); + } else { + int x = readInt(); + int y = readShort(); + int z = readInt(); + this.sourcePosition = new Vector3i(x, y, z); + } + this.destinationIdentifier = readString(); + if (serverVersion.isNewerThanOrEquals(ServerVersion.V_1_8)) { + this.blockPosition = new Vector3i(readLong()); + } else { + int x = readInt(); + int y = readShort(); + int z = readInt(); + this.blockPosition = new Vector3i(x, y, z); + } + this.arrivalTicks = readVarInt(); + } + + @Override + public void write() { + if (serverVersion.isNewerThanOrEquals(ServerVersion.V_1_8)) { + long positionVector = this.sourcePosition.getSerializedPosition(); + writeLong(positionVector); + } else { + writeInt(this.sourcePosition.x); + writeShort(this.sourcePosition.y); + writeInt(this.sourcePosition.z); + } + writeString(this.destinationIdentifier); + if (serverVersion.isNewerThanOrEquals(ServerVersion.V_1_8)) { + long positionVector = this.blockPosition.getSerializedPosition(); + writeLong(positionVector); + } else { + writeInt(this.blockPosition.x); + writeShort(this.blockPosition.y); + writeInt(this.blockPosition.z); + } + writeVarInt(this.arrivalTicks); + } + + @Override + public void copy(WrapperPlayServerSculkVibrationSignal wrapper) { + this.sourcePosition = wrapper.sourcePosition; + this.destinationIdentifier = wrapper.destinationIdentifier; + this.blockPosition = wrapper.blockPosition; + this.arrivalTicks = wrapper.arrivalTicks; + } + + public Vector3i getSourcePosition() { + return sourcePosition; + } + + public void setSourcePosition(Vector3i sourcePosition) { + this.sourcePosition = sourcePosition; + } + + public String getDestinationIdentifier() { + return destinationIdentifier; + } + + public void setDestinationIdentifier(String destinationIdentifier) { + this.destinationIdentifier = destinationIdentifier; + } + + public Vector3i getBlockPosition() { + return blockPosition; + } + + public void setBlockPosition(Vector3i blockPosition) { + this.blockPosition = blockPosition; + } + + public int getArrivalTicks() { + return arrivalTicks; + } + + public void setArrivalTicks(int arrivalTicks) { + this.arrivalTicks = arrivalTicks; + } +} From 7c93bb4bc2927c7814bb43e4bc07c00808f483d6 Mon Sep 17 00:00:00 2001 From: NoJokeFNA Date: Thu, 19 May 2022 18:15:58 +0200 Subject: [PATCH 2/5] fix: fixed code-style --- ...WrapperPlayServerSculkVibrationSignal.java | 192 +++++++++--------- 1 file changed, 96 insertions(+), 96 deletions(-) diff --git a/api/src/main/java/com/github/retrooper/packetevents/wrapper/play/server/WrapperPlayServerSculkVibrationSignal.java b/api/src/main/java/com/github/retrooper/packetevents/wrapper/play/server/WrapperPlayServerSculkVibrationSignal.java index 5e8a891f92..5345e5bf62 100644 --- a/api/src/main/java/com/github/retrooper/packetevents/wrapper/play/server/WrapperPlayServerSculkVibrationSignal.java +++ b/api/src/main/java/com/github/retrooper/packetevents/wrapper/play/server/WrapperPlayServerSculkVibrationSignal.java @@ -25,104 +25,104 @@ import com.github.retrooper.packetevents.wrapper.PacketWrapper; public class WrapperPlayServerSculkVibrationSignal extends PacketWrapper { - private Vector3i sourcePosition; - private String destinationIdentifier; - private Vector3i blockPosition; - private int arrivalTicks; - - public WrapperPlayServerSculkVibrationSignal(PacketSendEvent event) { - super(event); - } - - public WrapperPlayServerSculkVibrationSignal(Vector3i sourcePosition, String destinationIdentifier, Vector3i blockPosition, int arrivalTicks) { - super(PacketType.Play.Server.SCULK_VIBRATION_SIGNAL); - this.sourcePosition = sourcePosition; - this.destinationIdentifier = destinationIdentifier; - this.blockPosition = blockPosition; - this.arrivalTicks = arrivalTicks; - } - - @Override - public void read() { - if (serverVersion.isNewerThanOrEquals(ServerVersion.V_1_8)) { - this.sourcePosition = new Vector3i(readLong()); - } else { - int x = readInt(); - int y = readShort(); - int z = readInt(); - this.sourcePosition = new Vector3i(x, y, z); + private Vector3i sourcePosition; + private String destinationIdentifier; + private Vector3i blockPosition; + private int arrivalTicks; + + public WrapperPlayServerSculkVibrationSignal(PacketSendEvent event) { + super(event); + } + + public WrapperPlayServerSculkVibrationSignal(Vector3i sourcePosition, String destinationIdentifier, Vector3i blockPosition, int arrivalTicks) { + super(PacketType.Play.Server.SCULK_VIBRATION_SIGNAL); + this.sourcePosition = sourcePosition; + this.destinationIdentifier = destinationIdentifier; + this.blockPosition = blockPosition; + this.arrivalTicks = arrivalTicks; + } + + @Override + public void read() { + if (serverVersion.isNewerThanOrEquals(ServerVersion.V_1_8)) { + this.sourcePosition = new Vector3i(readLong()); + } else { + int x = readInt(); + int y = readShort(); + int z = readInt(); + this.sourcePosition = new Vector3i(x, y, z); + } + this.destinationIdentifier = readString(); + if (serverVersion.isNewerThanOrEquals(ServerVersion.V_1_8)) { + this.blockPosition = new Vector3i(readLong()); + } else { + int x = readInt(); + int y = readShort(); + int z = readInt(); + this.blockPosition = new Vector3i(x, y, z); + } + this.arrivalTicks = readVarInt(); + } + + @Override + public void write() { + if (serverVersion.isNewerThanOrEquals(ServerVersion.V_1_8)) { + long positionVector = this.sourcePosition.getSerializedPosition(); + writeLong(positionVector); + } else { + writeInt(this.sourcePosition.x); + writeShort(this.sourcePosition.y); + writeInt(this.sourcePosition.z); + } + writeString(this.destinationIdentifier); + if (serverVersion.isNewerThanOrEquals(ServerVersion.V_1_8)) { + long positionVector = this.blockPosition.getSerializedPosition(); + writeLong(positionVector); + } else { + writeInt(this.blockPosition.x); + writeShort(this.blockPosition.y); + writeInt(this.blockPosition.z); + } + writeVarInt(this.arrivalTicks); + } + + @Override + public void copy(WrapperPlayServerSculkVibrationSignal wrapper) { + this.sourcePosition = wrapper.sourcePosition; + this.destinationIdentifier = wrapper.destinationIdentifier; + this.blockPosition = wrapper.blockPosition; + this.arrivalTicks = wrapper.arrivalTicks; + } + + public Vector3i getSourcePosition() { + return sourcePosition; } - this.destinationIdentifier = readString(); - if (serverVersion.isNewerThanOrEquals(ServerVersion.V_1_8)) { - this.blockPosition = new Vector3i(readLong()); - } else { - int x = readInt(); - int y = readShort(); - int z = readInt(); - this.blockPosition = new Vector3i(x, y, z); + + public void setSourcePosition(Vector3i sourcePosition) { + this.sourcePosition = sourcePosition; + } + + public String getDestinationIdentifier() { + return destinationIdentifier; } - this.arrivalTicks = readVarInt(); - } - - @Override - public void write() { - if (serverVersion.isNewerThanOrEquals(ServerVersion.V_1_8)) { - long positionVector = this.sourcePosition.getSerializedPosition(); - writeLong(positionVector); - } else { - writeInt(this.sourcePosition.x); - writeShort(this.sourcePosition.y); - writeInt(this.sourcePosition.z); + + public void setDestinationIdentifier(String destinationIdentifier) { + this.destinationIdentifier = destinationIdentifier; + } + + public Vector3i getBlockPosition() { + return blockPosition; } - writeString(this.destinationIdentifier); - if (serverVersion.isNewerThanOrEquals(ServerVersion.V_1_8)) { - long positionVector = this.blockPosition.getSerializedPosition(); - writeLong(positionVector); - } else { - writeInt(this.blockPosition.x); - writeShort(this.blockPosition.y); - writeInt(this.blockPosition.z); + + public void setBlockPosition(Vector3i blockPosition) { + this.blockPosition = blockPosition; + } + + public int getArrivalTicks() { + return arrivalTicks; + } + + public void setArrivalTicks(int arrivalTicks) { + this.arrivalTicks = arrivalTicks; } - writeVarInt(this.arrivalTicks); - } - - @Override - public void copy(WrapperPlayServerSculkVibrationSignal wrapper) { - this.sourcePosition = wrapper.sourcePosition; - this.destinationIdentifier = wrapper.destinationIdentifier; - this.blockPosition = wrapper.blockPosition; - this.arrivalTicks = wrapper.arrivalTicks; - } - - public Vector3i getSourcePosition() { - return sourcePosition; - } - - public void setSourcePosition(Vector3i sourcePosition) { - this.sourcePosition = sourcePosition; - } - - public String getDestinationIdentifier() { - return destinationIdentifier; - } - - public void setDestinationIdentifier(String destinationIdentifier) { - this.destinationIdentifier = destinationIdentifier; - } - - public Vector3i getBlockPosition() { - return blockPosition; - } - - public void setBlockPosition(Vector3i blockPosition) { - this.blockPosition = blockPosition; - } - - public int getArrivalTicks() { - return arrivalTicks; - } - - public void setArrivalTicks(int arrivalTicks) { - this.arrivalTicks = arrivalTicks; - } } From 29d7b9c1d546febbe113c7e817c9b340872b3bb5 Mon Sep 17 00:00:00 2001 From: NoJokeFNA Date: Fri, 20 May 2022 14:40:06 +0200 Subject: [PATCH 3/5] change: changed `String destinationIdentifier` to `ResourceLocation destinationIdentifier` --- .../WrapperPlayServerSculkVibrationSignal.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/api/src/main/java/com/github/retrooper/packetevents/wrapper/play/server/WrapperPlayServerSculkVibrationSignal.java b/api/src/main/java/com/github/retrooper/packetevents/wrapper/play/server/WrapperPlayServerSculkVibrationSignal.java index 5345e5bf62..c08c5b0666 100644 --- a/api/src/main/java/com/github/retrooper/packetevents/wrapper/play/server/WrapperPlayServerSculkVibrationSignal.java +++ b/api/src/main/java/com/github/retrooper/packetevents/wrapper/play/server/WrapperPlayServerSculkVibrationSignal.java @@ -21,12 +21,13 @@ import com.github.retrooper.packetevents.event.PacketSendEvent; import com.github.retrooper.packetevents.manager.server.ServerVersion; import com.github.retrooper.packetevents.protocol.packettype.PacketType; +import com.github.retrooper.packetevents.resources.ResourceLocation; import com.github.retrooper.packetevents.util.Vector3i; import com.github.retrooper.packetevents.wrapper.PacketWrapper; public class WrapperPlayServerSculkVibrationSignal extends PacketWrapper { private Vector3i sourcePosition; - private String destinationIdentifier; + private ResourceLocation destinationIdentifier; private Vector3i blockPosition; private int arrivalTicks; @@ -34,7 +35,7 @@ public WrapperPlayServerSculkVibrationSignal(PacketSendEvent event) { super(event); } - public WrapperPlayServerSculkVibrationSignal(Vector3i sourcePosition, String destinationIdentifier, Vector3i blockPosition, int arrivalTicks) { + public WrapperPlayServerSculkVibrationSignal(Vector3i sourcePosition, ResourceLocation destinationIdentifier, Vector3i blockPosition, int arrivalTicks) { super(PacketType.Play.Server.SCULK_VIBRATION_SIGNAL); this.sourcePosition = sourcePosition; this.destinationIdentifier = destinationIdentifier; @@ -52,7 +53,7 @@ public void read() { int z = readInt(); this.sourcePosition = new Vector3i(x, y, z); } - this.destinationIdentifier = readString(); + this.destinationIdentifier = readIdentifier(); if (serverVersion.isNewerThanOrEquals(ServerVersion.V_1_8)) { this.blockPosition = new Vector3i(readLong()); } else { @@ -74,7 +75,7 @@ public void write() { writeShort(this.sourcePosition.y); writeInt(this.sourcePosition.z); } - writeString(this.destinationIdentifier); + writeIdentifier(this.destinationIdentifier); if (serverVersion.isNewerThanOrEquals(ServerVersion.V_1_8)) { long positionVector = this.blockPosition.getSerializedPosition(); writeLong(positionVector); @@ -102,11 +103,11 @@ public void setSourcePosition(Vector3i sourcePosition) { this.sourcePosition = sourcePosition; } - public String getDestinationIdentifier() { + public ResourceLocation getDestinationIdentifier() { return destinationIdentifier; } - public void setDestinationIdentifier(String destinationIdentifier) { + public void setDestinationIdentifier(ResourceLocation destinationIdentifier) { this.destinationIdentifier = destinationIdentifier; } From 51e5a6ed09eb0aa23ec5eccc688fe473a1868846 Mon Sep 17 00:00:00 2001 From: NoJokeFNA Date: Fri, 27 May 2022 01:53:09 +0200 Subject: [PATCH 4/5] remove: removed useless 1.7.x server version check --- ...WrapperPlayServerSculkVibrationSignal.java | 37 ++----------------- 1 file changed, 4 insertions(+), 33 deletions(-) diff --git a/api/src/main/java/com/github/retrooper/packetevents/wrapper/play/server/WrapperPlayServerSculkVibrationSignal.java b/api/src/main/java/com/github/retrooper/packetevents/wrapper/play/server/WrapperPlayServerSculkVibrationSignal.java index c08c5b0666..01826dd3aa 100644 --- a/api/src/main/java/com/github/retrooper/packetevents/wrapper/play/server/WrapperPlayServerSculkVibrationSignal.java +++ b/api/src/main/java/com/github/retrooper/packetevents/wrapper/play/server/WrapperPlayServerSculkVibrationSignal.java @@ -19,7 +19,6 @@ package com.github.retrooper.packetevents.wrapper.play.server; import com.github.retrooper.packetevents.event.PacketSendEvent; -import com.github.retrooper.packetevents.manager.server.ServerVersion; import com.github.retrooper.packetevents.protocol.packettype.PacketType; import com.github.retrooper.packetevents.resources.ResourceLocation; import com.github.retrooper.packetevents.util.Vector3i; @@ -45,45 +44,17 @@ public WrapperPlayServerSculkVibrationSignal(Vector3i sourcePosition, ResourceLo @Override public void read() { - if (serverVersion.isNewerThanOrEquals(ServerVersion.V_1_8)) { - this.sourcePosition = new Vector3i(readLong()); - } else { - int x = readInt(); - int y = readShort(); - int z = readInt(); - this.sourcePosition = new Vector3i(x, y, z); - } + this.sourcePosition = new Vector3i(readLong()); this.destinationIdentifier = readIdentifier(); - if (serverVersion.isNewerThanOrEquals(ServerVersion.V_1_8)) { - this.blockPosition = new Vector3i(readLong()); - } else { - int x = readInt(); - int y = readShort(); - int z = readInt(); - this.blockPosition = new Vector3i(x, y, z); - } + this.blockPosition = new Vector3i(readLong()); this.arrivalTicks = readVarInt(); } @Override public void write() { - if (serverVersion.isNewerThanOrEquals(ServerVersion.V_1_8)) { - long positionVector = this.sourcePosition.getSerializedPosition(); - writeLong(positionVector); - } else { - writeInt(this.sourcePosition.x); - writeShort(this.sourcePosition.y); - writeInt(this.sourcePosition.z); - } + writeLong(this.sourcePosition.getSerializedPosition()); writeIdentifier(this.destinationIdentifier); - if (serverVersion.isNewerThanOrEquals(ServerVersion.V_1_8)) { - long positionVector = this.blockPosition.getSerializedPosition(); - writeLong(positionVector); - } else { - writeInt(this.blockPosition.x); - writeShort(this.blockPosition.y); - writeInt(this.blockPosition.z); - } + writeLong(this.blockPosition.getSerializedPosition()); writeVarInt(this.arrivalTicks); } From 55a16ce1890a26ebe29376d09485568f8958d6f4 Mon Sep 17 00:00:00 2001 From: NoJokeFNA Date: Tue, 31 May 2022 09:39:56 +0200 Subject: [PATCH 5/5] feat: added `entityId` integer; needs to be tested, not stable --- ...WrapperPlayServerSculkVibrationSignal.java | 36 +++++++++++++++---- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/api/src/main/java/com/github/retrooper/packetevents/wrapper/play/server/WrapperPlayServerSculkVibrationSignal.java b/api/src/main/java/com/github/retrooper/packetevents/wrapper/play/server/WrapperPlayServerSculkVibrationSignal.java index 01826dd3aa..18b9b4e34b 100644 --- a/api/src/main/java/com/github/retrooper/packetevents/wrapper/play/server/WrapperPlayServerSculkVibrationSignal.java +++ b/api/src/main/java/com/github/retrooper/packetevents/wrapper/play/server/WrapperPlayServerSculkVibrationSignal.java @@ -23,22 +23,27 @@ import com.github.retrooper.packetevents.resources.ResourceLocation; import com.github.retrooper.packetevents.util.Vector3i; import com.github.retrooper.packetevents.wrapper.PacketWrapper; +import org.jetbrains.annotations.Nullable; + +import java.util.Optional; public class WrapperPlayServerSculkVibrationSignal extends PacketWrapper { private Vector3i sourcePosition; private ResourceLocation destinationIdentifier; - private Vector3i blockPosition; + private @Nullable Vector3i blockPosition; + private int entityId; private int arrivalTicks; public WrapperPlayServerSculkVibrationSignal(PacketSendEvent event) { super(event); } - public WrapperPlayServerSculkVibrationSignal(Vector3i sourcePosition, ResourceLocation destinationIdentifier, Vector3i blockPosition, int arrivalTicks) { + public WrapperPlayServerSculkVibrationSignal(Vector3i sourcePosition, ResourceLocation destinationIdentifier, Vector3i blockPosition, int entityId, int arrivalTicks) { super(PacketType.Play.Server.SCULK_VIBRATION_SIGNAL); this.sourcePosition = sourcePosition; this.destinationIdentifier = destinationIdentifier; this.blockPosition = blockPosition; + this.entityId = entityId; this.arrivalTicks = arrivalTicks; } @@ -46,7 +51,11 @@ public WrapperPlayServerSculkVibrationSignal(Vector3i sourcePosition, ResourceLo public void read() { this.sourcePosition = new Vector3i(readLong()); this.destinationIdentifier = readIdentifier(); - this.blockPosition = new Vector3i(readLong()); + if (this.destinationIdentifier.getKey().contains("block")) { + this.blockPosition = new Vector3i(readLong()); + } else { + this.entityId = readVarInt(); + } this.arrivalTicks = readVarInt(); } @@ -54,7 +63,11 @@ public void read() { public void write() { writeLong(this.sourcePosition.getSerializedPosition()); writeIdentifier(this.destinationIdentifier); - writeLong(this.blockPosition.getSerializedPosition()); + if (this.destinationIdentifier.getKey().contains("block")) { + writeLong(this.blockPosition.getSerializedPosition()); + } else { + writeVarInt(this.entityId); + } writeVarInt(this.arrivalTicks); } @@ -63,6 +76,7 @@ public void copy(WrapperPlayServerSculkVibrationSignal wrapper) { this.sourcePosition = wrapper.sourcePosition; this.destinationIdentifier = wrapper.destinationIdentifier; this.blockPosition = wrapper.blockPosition; + this.entityId = wrapper.entityId; this.arrivalTicks = wrapper.arrivalTicks; } @@ -82,14 +96,22 @@ public void setDestinationIdentifier(ResourceLocation destinationIdentifier) { this.destinationIdentifier = destinationIdentifier; } - public Vector3i getBlockPosition() { - return blockPosition; + public Optional getBlockPosition() { + return Optional.ofNullable(blockPosition); } - public void setBlockPosition(Vector3i blockPosition) { + public void setBlockPosition(@Nullable Vector3i blockPosition) { this.blockPosition = blockPosition; } + public int getEntityId() { + return entityId; + } + + public void setEntityId(int entityId) { + this.entityId = entityId; + } + public int getArrivalTicks() { return arrivalTicks; }