Use entity vector fields in 1.17+
NikV2 opened this issue ยท 4 comments
Describe the bug
Field access exception thrown when trying to access the target vectors if the use entity type is INTERACT_AT.
Not sure if this is an issue within ProtocolLib itself since mcp 1.17+ is a pain and couldn't find anything useful there.
Apologies if im looking at the wrong place
To Reproduce
Steps to reproduce the behavior:
- Listen for the use entity packet
- Trigger an INTERACT_AT Action
- Error below pops up
FieldAccessException: No field with type net.minecraft.world.phys.Vec3D exists in class PacketPlayInUseEntity.
[16:56:11 WARN]: at ProtocolLib.jar//com.comphenix.protocol.reflect.StructureModifier.readInternal(StructureModifier.java:218)
[16:56:11 WARN]: at ProtocolLib.jar//com.comphenix.protocol.reflect.StructureModifier.read(StructureModifier.java:197)
Expected behavior
Return the target vector
Version Info
https://pastebin.com/qs7AW1yK
Additional context
Methods used to trigger this error:
/**
* Retrieve the target vector.
* <p>
* Notes: Only if {@link #getType()} is {@link EntityUseAction#INTERACT_AT}.
*
* @return The target vector or null
*/
public Vector getTargetVector() {
return handle.getVectors().readSafely(0);
}```
@dmulloy2 It's provided in the additional context section. (Edit) i changed it to readSafely(0) in order to avoid any errors and return null for the time being)
Here's the code:
if (packet.getPacketType() != PacketType.Play.Client.USE_ENTITY) return;
WrapperPlayClientUseEntity useEntity = new WrapperPlayClientUseEntity(packet.getPacket());
if (useEntity.getType() != EnumWrappers.EntityUseAction.INTERACT_AT) return;
Vector vec = useEntity.getTargetVector();
if (vec == null) return;
And the wrapper's method:
**
* Retrieve the target vector.
* <p>
* Notes: Only if {@link #getType()} is {@link EntityUseAction#INTERACT_AT}.
*
* @return The target vector or null
*/
public Vector getTargetVector() {
return handle.getVectors().readSafely(0);
}
This can only be reproduced in 1.17+ servers by using latest ProtocolLib (Or latest dev build) and right clicking an entity.