From d4eaa73e54132f701e66b223069166717a2809cd Mon Sep 17 00:00:00 2001 From: jtJava Date: Thu, 14 Mar 2024 00:34:21 -0500 Subject: [PATCH 1/4] Add WrapperPlayServerWorldEvent --- .../protocol/packettype/PacketType.java | 3 +- .../server/WrapperPlayServerWorldEvent.java | 82 +++++++++++++++++++ 2 files changed, 84 insertions(+), 1 deletion(-) create mode 100644 api/src/main/java/com/github/retrooper/packetevents/wrapper/play/server/WrapperPlayServerWorldEvent.java diff --git a/api/src/main/java/com/github/retrooper/packetevents/protocol/packettype/PacketType.java b/api/src/main/java/com/github/retrooper/packetevents/protocol/packettype/PacketType.java index cf7701ff17..c5c944b66d 100644 --- a/api/src/main/java/com/github/retrooper/packetevents/protocol/packettype/PacketType.java +++ b/api/src/main/java/com/github/retrooper/packetevents/protocol/packettype/PacketType.java @@ -792,7 +792,8 @@ public enum Server implements PacketTypeCommon, ClientBoundPacket { RESET_SCORE, RESOURCE_PACK_REMOVE, TICKING_STATE, - TICKING_STEP; + TICKING_STEP, + WORLD_EVENT; private static int INDEX = 0; private static final Map> PACKET_TYPE_ID_MAP = new HashMap<>(); diff --git a/api/src/main/java/com/github/retrooper/packetevents/wrapper/play/server/WrapperPlayServerWorldEvent.java b/api/src/main/java/com/github/retrooper/packetevents/wrapper/play/server/WrapperPlayServerWorldEvent.java new file mode 100644 index 0000000000..ffe05c2a2e --- /dev/null +++ b/api/src/main/java/com/github/retrooper/packetevents/wrapper/play/server/WrapperPlayServerWorldEvent.java @@ -0,0 +1,82 @@ +package com.github.retrooper.packetevents.wrapper.play.server; + +import com.github.retrooper.packetevents.event.PacketReceiveEvent; +import com.github.retrooper.packetevents.protocol.packettype.PacketType; +import com.github.retrooper.packetevents.util.Vector3i; +import com.github.retrooper.packetevents.wrapper.PacketWrapper; + +class WrapperPlayServerWorldEvent extends PacketWrapper { + private int event; + private Vector3i location; + private int data; + private boolean globalEvent; + + + public WrapperPlayServerWorldEvent(PacketReceiveEvent event) { + super(event); + } + + public WrapperPlayServerWorldEvent(int type, Vector3i location, int data, boolean globalEvent) { + super(PacketType.Play.Server.WORLD_EVENT); + this.event = type; + this.location = location; + this.data = data; + this.globalEvent = globalEvent; + } + + @Override + public void read() { + this.event = readInt(); + this.location = readBlockPosition(); + this.data = readInt(); + this.globalEvent = readBoolean(); + } + + @Override + public void write() { + writeInt(event); + writeBlockPosition(location); + writeInt(data); + writeBoolean(globalEvent); + } + + @Override + public void copy(WrapperPlayServerWorldEvent wrapper) { + this.event = wrapper.event; + this.location = wrapper.location; + this.data = wrapper.data; + this.globalEvent = wrapper.globalEvent; + } + + public int getEvent() { + return event; + } + + public void setEvent(int event) { + this.event = event; + } + + public Vector3i getLocation() { + return location; + } + + public void setLocation(Vector3i location) { + this.location = location; + } + + public int getData() { + return data; + } + + public void setData(int data) { + this.data = data; + } + + public boolean isGlobalEvent() { + return globalEvent; + } + + public void setGlobalEvent(boolean globalEvent) { + this.globalEvent = globalEvent; + } +} \ No newline at end of file From 242a33bf312bcf604c1827575ef35280b066ab49 Mon Sep 17 00:00:00 2001 From: jtJava Date: Wed, 26 Jun 2024 04:28:06 -0500 Subject: [PATCH 2/4] Revert PacketType --- .../retrooper/packetevents/protocol/packettype/PacketType.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/api/src/main/java/com/github/retrooper/packetevents/protocol/packettype/PacketType.java b/api/src/main/java/com/github/retrooper/packetevents/protocol/packettype/PacketType.java index c5c944b66d..cf7701ff17 100644 --- a/api/src/main/java/com/github/retrooper/packetevents/protocol/packettype/PacketType.java +++ b/api/src/main/java/com/github/retrooper/packetevents/protocol/packettype/PacketType.java @@ -792,8 +792,7 @@ public enum Server implements PacketTypeCommon, ClientBoundPacket { RESET_SCORE, RESOURCE_PACK_REMOVE, TICKING_STATE, - TICKING_STEP, - WORLD_EVENT; + TICKING_STEP; private static int INDEX = 0; private static final Map> PACKET_TYPE_ID_MAP = new HashMap<>(); From f50c6548d4e6c14f5cbada4647ddad0c1965edc3 Mon Sep 17 00:00:00 2001 From: jtJava Date: Wed, 26 Jun 2024 04:28:25 -0500 Subject: [PATCH 3/4] Rename WrapperPlayServerEffect --- ...vent.java => WrapperPlayServerEffect.java} | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) rename api/src/main/java/com/github/retrooper/packetevents/wrapper/play/server/{WrapperPlayServerWorldEvent.java => WrapperPlayServerEffect.java} (67%) diff --git a/api/src/main/java/com/github/retrooper/packetevents/wrapper/play/server/WrapperPlayServerWorldEvent.java b/api/src/main/java/com/github/retrooper/packetevents/wrapper/play/server/WrapperPlayServerEffect.java similarity index 67% rename from api/src/main/java/com/github/retrooper/packetevents/wrapper/play/server/WrapperPlayServerWorldEvent.java rename to api/src/main/java/com/github/retrooper/packetevents/wrapper/play/server/WrapperPlayServerEffect.java index ffe05c2a2e..bd97fe9d33 100644 --- a/api/src/main/java/com/github/retrooper/packetevents/wrapper/play/server/WrapperPlayServerWorldEvent.java +++ b/api/src/main/java/com/github/retrooper/packetevents/wrapper/play/server/WrapperPlayServerEffect.java @@ -5,24 +5,24 @@ import com.github.retrooper.packetevents.util.Vector3i; import com.github.retrooper.packetevents.wrapper.PacketWrapper; -class WrapperPlayServerWorldEvent extends PacketWrapper { - private int event; - private Vector3i location; - private int data; - private boolean globalEvent; +public class WrapperPlayServerEffect extends PacketWrapper { + private int event; + private Vector3i location; + private int data; + private boolean globalEvent; - public WrapperPlayServerWorldEvent(PacketReceiveEvent event) { - super(event); - } + public WrapperPlayServerEffect(PacketReceiveEvent event) { + super(event); + } - public WrapperPlayServerWorldEvent(int type, Vector3i location, int data, boolean globalEvent) { - super(PacketType.Play.Server.WORLD_EVENT); - this.event = type; - this.location = location; - this.data = data; - this.globalEvent = globalEvent; - } + public WrapperPlayServerEffect(int type, Vector3i location, int data, boolean globalEvent) { + super(PacketType.Play.Server.EFFECT); + this.event = type; + this.location = location; + this.data = data; + this.globalEvent = globalEvent; + } @Override public void read() { @@ -41,7 +41,7 @@ public void write() { } @Override - public void copy(WrapperPlayServerWorldEvent wrapper) { + public void copy(WrapperPlayServerEffect wrapper) { this.event = wrapper.event; this.location = wrapper.location; this.data = wrapper.data; From 9b8cf6ff5ea382349dcc5ea75ff84be049a4bf93 Mon Sep 17 00:00:00 2001 From: jtJava Date: Sat, 29 Jun 2024 01:10:40 -0500 Subject: [PATCH 4/4] Make packet clientbound --- .../wrapper/play/server/WrapperPlayServerEffect.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/src/main/java/com/github/retrooper/packetevents/wrapper/play/server/WrapperPlayServerEffect.java b/api/src/main/java/com/github/retrooper/packetevents/wrapper/play/server/WrapperPlayServerEffect.java index bd97fe9d33..08310d9b3c 100644 --- a/api/src/main/java/com/github/retrooper/packetevents/wrapper/play/server/WrapperPlayServerEffect.java +++ b/api/src/main/java/com/github/retrooper/packetevents/wrapper/play/server/WrapperPlayServerEffect.java @@ -1,6 +1,6 @@ package com.github.retrooper.packetevents.wrapper.play.server; -import com.github.retrooper.packetevents.event.PacketReceiveEvent; +import com.github.retrooper.packetevents.event.PacketSendEvent; import com.github.retrooper.packetevents.protocol.packettype.PacketType; import com.github.retrooper.packetevents.util.Vector3i; import com.github.retrooper.packetevents.wrapper.PacketWrapper; @@ -12,7 +12,7 @@ public class WrapperPlayServerEffect extends PacketWrapper