Skip to content

Commit 6edd44b

Browse files
Fix holograms, item frames and skulls on dimension switch for PE clients
1 parent 9550005 commit 6edd44b

File tree

3 files changed

+26
-9
lines changed

3 files changed

+26
-9
lines changed

src/protocolsupportpocketstuff/hacks/holograms/HologramsPacketListener.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package protocolsupportpocketstuff.hacks.holograms;
22

33
import io.netty.buffer.ByteBuf;
4+
import net.minecraft.server.v1_12_R1.PacketPlayOutRespawn;
45
import protocolsupport.api.Connection;
56
import protocolsupport.api.Connection.PacketListener;
67
import protocolsupport.protocol.packet.middleimpl.clientbound.play.v_pe.SetPosition;
@@ -49,6 +50,15 @@ public HologramsPacketListener(Connection con) {
4950
this.con = con;
5051
}
5152

53+
@Override
54+
public void onPacketSending(PacketEvent event) {
55+
// ===[ WORLD SWITCH ]===
56+
if (event.getPacket() instanceof PacketPlayOutRespawn) {
57+
cachedArmorStands.clear();
58+
return;
59+
}
60+
}
61+
5262
@Override
5363
public void onRawPacketSending(RawPacketEvent event) {
5464
ByteBuf data = event.getData();
@@ -58,11 +68,6 @@ public void onRawPacketSending(RawPacketEvent event) {
5868
data.readByte();
5969
data.readByte();
6070

61-
if (packetId == PEPacketIDs.CHANGE_DIMENSION) {
62-
// Clear cached holograms on dimension switch
63-
cachedArmorStands.clear();
64-
return;
65-
}
6671
if (packetId == PEPacketIDs.ENTITY_TELEPORT) {
6772
long entityId = VarNumberSerializer.readVarLong(data);
6873

src/protocolsupportpocketstuff/hacks/itemframes/ItemFramesPacketListener.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import net.minecraft.server.v1_12_R1.PacketPlayInUseEntity;
77
import net.minecraft.server.v1_12_R1.PacketPlayOutEntityDestroy;
88
import net.minecraft.server.v1_12_R1.PacketPlayOutEntityMetadata;
9+
import net.minecraft.server.v1_12_R1.PacketPlayOutRespawn;
910
import net.minecraft.server.v1_12_R1.PacketPlayOutSpawnEntity;
1011
import protocolsupport.api.Connection;
1112
import protocolsupport.protocol.serializer.ItemStackSerializer;
@@ -117,6 +118,11 @@ public ItemFramesPacketListener(ProtocolSupportPocketStuff plugin, Connection co
117118
public void onPacketSending(PacketEvent event) {
118119
super.onPacketSending(event);
119120

121+
// ===[ WORLD SWITCH ]===
122+
if (event.getPacket() instanceof PacketPlayOutRespawn) {
123+
cachedItemFrames.clear();
124+
return;
125+
}
120126
// ===[ SPAWN ]===
121127
if (event.getPacket() instanceof PacketPlayOutSpawnEntity) {
122128
PacketPlayOutSpawnEntity packet = (PacketPlayOutSpawnEntity) event.getPacket();

src/protocolsupportpocketstuff/hacks/skulls/SkullTilePacketListener.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import io.netty.buffer.ByteBuf;
44
import io.netty.buffer.Unpooled;
5+
import net.minecraft.server.v1_12_R1.PacketPlayOutRespawn;
56
import org.apache.commons.lang3.Validate;
67
import protocolsupport.api.Connection;
78
import protocolsupport.libs.com.google.gson.JsonObject;
@@ -50,6 +51,15 @@ public SkullTilePacketListener(Connection con) {
5051
this.con = con;
5152
}
5253

54+
@Override
55+
public void onPacketSending(PacketEvent event) {
56+
// ===[ WORLD SWITCH ]===
57+
if (event.getPacket() instanceof PacketPlayOutRespawn) {
58+
cachedSkullBlocks.clear();
59+
return;
60+
}
61+
}
62+
5363
@Override
5464
public void onRawPacketSending(RawPacketEvent event) {
5565
ByteBuf data = event.getData();
@@ -58,10 +68,6 @@ public void onRawPacketSending(RawPacketEvent event) {
5868
data.readByte();
5969
data.readByte();
6070

61-
if (packetId == PEPacketIDs.CHANGE_DIMENSION) {
62-
cachedSkullBlocks.clear();
63-
return;
64-
}
6571
if (packetId == PEPacketIDs.TILE_DATA_UPDATE) {
6672
Position position = new Position(0, 0, 0);
6773
PositionSerializer.readPEPositionTo(data, position);

0 commit comments

Comments
 (0)