ProtocolLib

3M Downloads

Vector3F cannot be cast to Vector3f

JVerbruggen opened this issue · 1 comments

commented
  • This issue is not solved in a development build

Describe the bug
When trying to send rotation metadata about a given entity Id, I get the following error since migrating from 1.19.2 to 1.20.1.

PacketContainer packet = new PacketContainer(PacketType.Play.Server.ENTITY_METADATA);
packet.getIntegers().write(0, this.entityId);

WrappedDataWatcher.Serializer serializer = WrappedDataWatcher.Registry.getVectorSerializer();

List<WrappedDataValue> values = Lists.newArrayList(
        new WrappedDataValue(rotationType, serializer, rotation.toVector3F())
);
packet.getDataValueCollectionModifier().write(0, values);

rotationType = 16 ( for armorstand head rotation )
rotation = my internal vector type, toVector3F returns a protocollib Vector3F
this.entityId = entityId :)

I used to not even use datavaluecollectionmodifier, instead, i used the datawatchermodifier, but that didnt seem to work at all anymore.

Error:
image

Expected behavior
No error

Screenshots
As above

Version Info
5.1.0

commented

Hi,

the constructor of WrappedDataValue requires the unwrapped NMS object as the 3rd argument and does not accept any Wrappers. You can use the setValue(Object), which takes care of automatically unwrapping the provided value like so:

WrappedDataValue value =  new WrappedDataValue(rotationType, serializer, null);
value.setValue(rotation.toVector3F());
List<WrappedDataValue> values = Lists.newArrayList(
       value
);