9
0
mirror of https://github.com/Xiao-MoMi/craft-engine.git synced 2025-12-29 03:49:15 +00:00

fix(bukkit): 阻止发送仅服务端实体包

This commit is contained in:
jhqwqmc
2025-04-02 16:33:40 +08:00
parent 73f77aacde
commit c1b4384d6b
2 changed files with 0 additions and 45 deletions

View File

@@ -134,9 +134,6 @@ public class BukkitNetworkManager implements NetworkManager, Listener, PluginMes
registerNMSPacketConsumer(PacketConsumers.REMOVE_ENTITY, Reflections.clazz$ClientboundRemoveEntitiesPacket);
registerNMSPacketConsumer(PacketConsumers.SYNC_ENTITY_POSITION, Reflections.clazz$ClientboundEntityPositionSyncPacket);
registerNMSPacketConsumer(PacketConsumers.MOVE_ENTITY, Reflections.clazz$ClientboundMoveEntityPacket$Pos);
registerNMSPacketConsumer(PacketConsumers.MOVE_AND_ROTATION_ENTITY, Reflections.clazz$ClientboundMoveEntityPacket$PosRot);
registerNMSPacketConsumer(PacketConsumers.ROTATE_HEAD, Reflections.clazz$ClientboundRotateHeadPacket);
registerNMSPacketConsumer(PacketConsumers.SET_ENTITY_MOTION, Reflections.clazz$ClientboundSetEntityMotionPacket);
registerNMSPacketConsumer(PacketConsumers.PICK_ITEM_FROM_ENTITY, Reflections.clazz$ServerboundPickItemFromEntityPacket);
registerNMSPacketConsumer(PacketConsumers.SOUND, Reflections.clazz$ClientboundSoundPacket);
registerNMSPacketConsumer(PacketConsumers.RENAME_ITEM, Reflections.clazz$ServerboundRenameItemPacket);

View File

@@ -666,48 +666,6 @@ public class PacketConsumers {
}
};
public static final TriConsumer<NetWorkUser, NMSPacketEvent, Object> MOVE_AND_ROTATION_ENTITY = (user, event, packet) -> {
try {
int entityId = (int) Reflections.field$ClientboundMoveEntityPacket$entityId.get(packet);
if (BukkitFurnitureManager.instance().isFurnitureBaseEntity(entityId)) {
event.setCancelled(true);
}
if (BukkitFurnitureManager.instance().isFurnitureCollisionEntity(entityId)) {
event.setCancelled(true);
}
} catch (Exception e) {
CraftEngine.instance().logger().warn("Failed to handle ClientboundMoveEntityPacket$PosRot", e);
}
};
public static final TriConsumer<NetWorkUser, NMSPacketEvent, Object> ROTATE_HEAD = (user, event, packet) -> {
try {
int entityId = (int) Reflections.field$ClientboundRotateHeadPacket$entityId.get(packet);
if (BukkitFurnitureManager.instance().isFurnitureBaseEntity(entityId)) {
event.setCancelled(true);
}
if (BukkitFurnitureManager.instance().isFurnitureCollisionEntity(entityId)) {
event.setCancelled(true);
}
} catch (Exception e) {
CraftEngine.instance().logger().warn("Failed to handle ClientboundRotateHeadPacket", e);
}
};
public static final TriConsumer<NetWorkUser, NMSPacketEvent, Object> SET_ENTITY_MOTION = (user, event, packet) -> {
try {
int entityId = (int) Reflections.field$ClientboundSetEntityMotionPacket$id.get(packet);
if (BukkitFurnitureManager.instance().isFurnitureBaseEntity(entityId)) {
event.setCancelled(true);
}
if (BukkitFurnitureManager.instance().isFurnitureCollisionEntity(entityId)) {
event.setCancelled(true);
}
} catch (Exception e) {
CraftEngine.instance().logger().warn("Failed to handle ClientboundSetEntityMotionPacket", e);
}
};
public static final TriConsumer<NetWorkUser, NMSPacketEvent, Object> REMOVE_ENTITY = (user, event, packet) -> {
try {
IntList intList = (IntList) Reflections.field$ClientboundRemoveEntitiesPacket$entityIds.get(packet);