Add processors for a sed of id only entity packets

This commit is contained in:
D4rkr34lm
2026-05-15 16:23:23 +02:00
parent 9a75f38226
commit 0452a9faa5
@@ -308,7 +308,7 @@ public abstract class TechHider {
// 7.1.2 Spawn Entity: entity type and position can reveal hidden contraptions.
processors.put(ClientboundAddEntityPacket.class, this.<ClientboundAddEntityPacket>buildEntityWithPositionProcessor(ClientboundAddEntityPacket::getId, ClientboundAddEntityPacket::getX, ClientboundAddEntityPacket::getY, ClientboundAddEntityPacket::getZ));
// 7.1.3 Entity Animation: entity id based signal, keep blocked until entity visibility is modeled.
processors.put(ClientboundAnimatePacket.class, tossPacket);
processors.put(ClientboundAnimatePacket.class, this.<ClientboundAnimatePacket>buildEntityProcessor(ClientboundAnimatePacket::getId));
// 7.1.26 Damage Event: entity ids and damage source location can leak hidden
// activity.
processors.put(ClientboundDamageEventPacket.class, tossPacket);
@@ -317,30 +317,30 @@ public abstract class TechHider {
// 7.1.36 Teleport Entity: entity id and absolute position.
processors.put(ClientboundTeleportEntityPacket.class, tossPacket);
// 7.1.42 Hurt Animation: entity id based signal.
processors.put(ClientboundHurtAnimationPacket.class, tossPacket);
processors.put(ClientboundHurtAnimationPacket.class, this.<ClientboundHurtAnimationPacket>buildEntityProcessor(ClientboundHurtAnimationPacket::id));
// 7.1.52/53/55 Update Entity Position/Rotation: entity id and movement signal.
processors.put(ClientboundMoveEntityPacket.class, tossPacket);
processors.put(Pos.class, tossPacket);
processors.put(PosRot.class, tossPacket);
processors.put(Rot.class, tossPacket);
// 7.1.100 Set Entity Velocity: entity id and movement.
processors.put(ClientboundSetEntityMotionPacket.class, tossPacket);
processors.put(ClientboundSetEntityMotionPacket.class, this.<ClientboundSetEntityMotionPacket>buildEntityProcessor(ClientboundSetEntityMotionPacket::getId));
// 7.1.101 Set Equipment: entity equipment can reveal wargear.
processors.put(ClientboundSetEquipmentPacket.class, tossPacket);
processors.put(ClientboundSetEquipmentPacket.class, this.<ClientboundSetEquipmentPacket>buildEntityProcessor(ClientboundSetEquipmentPacket::getEntity));
// 7.1.106 Set Passengers: entity relationship signal.
processors.put(ClientboundSetPassengersPacket.class, tossPacket);
// 7.1.130 Update Attributes: entity id and attribute state.
processors.put(ClientboundUpdateAttributesPacket.class, tossPacket);
processors.put(ClientboundUpdateAttributesPacket.class, this.<ClientboundUpdateAttributesPacket>buildEntityProcessor(ClientboundUpdateAttributesPacket::getEntityId));
// 7.1.131 Entity Effect: entity id and effect state.
processors.put(ClientboundUpdateMobEffectPacket.class, tossPacket);
processors.put(ClientboundUpdateMobEffectPacket.class, this.<ClientboundUpdateMobEffectPacket>buildEntityProcessor(ClientboundUpdateMobEffectPacket::getEntityId));
// 7.1.76 Remove Entities: entity id visibility side channel.
processors.put(ClientboundRemoveEntitiesPacket.class, tossPacket);
// 7.1.77 Remove Entity Effect: entity id and effect state.
processors.put(ClientboundRemoveMobEffectPacket.class, tossPacket);
processors.put(ClientboundRemoveMobEffectPacket.class, this.<ClientboundRemoveMobEffectPacket>buildEntityProcessor(ClientboundRemoveMobEffectPacket::entityId));
// 7.1.82 Set Head Rotation: entity id and rotation.
processors.put(ClientboundRotateHeadPacket.class, tossPacket);
// 7.1.98 Set Entity Metadata: entity state can reveal blocks/items/displays.
processors.put(ClientboundSetEntityDataPacket.class, tossPacket);
processors.put(ClientboundSetEntityDataPacket.class, this.<ClientboundSetEntityDataPacket>buildEntityProcessor(ClientboundSetEntityDataPacket::id));
// 7.1.99 Link Entities: entity relationship signal.
processors.put(ClientboundSetEntityLinkPacket.class, tossPacket);
@@ -419,7 +419,7 @@ public abstract class TechHider {
// --- Sound packets natural part of the game -> should not be hidden ---
// 7.1.115 Entity Sound Effect: entity id and sound.
processors.put(ClientboundSoundEntityPacket.class, tossPacket);
processors.put(ClientboundSoundEntityPacket.class, this.<ClientboundSoundEntityPacket>buildEntityProcessor(ClientboundSoundEntityPacket::getId));
// 7.1.116 Sound Effect: sound type and position.
processors.put(ClientboundSoundPacket.class, tossPacket);
// 7.1.118 Stop Sound: sound state side channel.
@@ -457,10 +457,9 @@ public abstract class TechHider {
}
}
private <TTargetPacket extends Packet<?>> BiFunction<Player, Packet<? extends PacketListener>, Packet<? extends PacketListener>> buildEntityWithPositionProcessor(ToIntFunction<TTargetPacket> entityIdExtractor, ToDoubleFunction<TTargetPacket> xExtractor, ToDoubleFunction<TTargetPacket> yExtractor, ToDoubleFunction<TTargetPacket> zExtractor) {
return (p, rawPacket) -> {
TTargetPacket packet = (TTargetPacket) rawPacket;
processEntityPacketWithPosition(p, entityIdExtractor.applyAsInt(packet), xExtractor.applyAsDouble(packet), yExtractor.applyAsDouble(packet), zExtractor.applyAsDouble(packet), packet)
return processEntityPacketWithPosition(p, entityIdExtractor.applyAsInt(packet), xExtractor.applyAsDouble(packet), yExtractor.applyAsDouble(packet), zExtractor.applyAsDouble(packet), packet);
};
}
@@ -471,6 +470,12 @@ public abstract class TechHider {
return new ClientboundRemoveEntitiesPacket(entityId);
}
}
private <TTargetPacket extends Packet<?>> BiFunction<Player, Packet<? extends PacketListener>, Packet<? extends PacketListener>> buildEntityProcessor(ToIntFunction<TTargetPacket> entityIdExtractor) {
return (p, rawPacket) -> {
TTargetPacket packet = (TTargetPacket) rawPacket;
return processEntityPacket(p, entityIdExtractor.applyAsInt(packet), packet);
};
}
private ClientboundBlockEventPacket processBlockEventPacket(Player player, ClientboundBlockEventPacket packet) {
BlockPos blockPos = packet.getPos();
@@ -580,4 +585,4 @@ public abstract class TechHider {
public abstract boolean isPlayerPrivilegedToAccessBlockEntity(Player p, String blockEntityType, int blockX,int blockY, int blockZ);
public abstract boolean isPlayerPrivilegedToAccessEntity(Player p, int entityId);
public abstract boolean isPlayerPrivilegedToAccessContainer(Player p, int containerId);
}
}