Skip to content

Commit

Permalink
Migrate from Vector4f to Quaternionf (#887)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexProgrammerDE authored Feb 28, 2025
1 parent 5743ca3 commit ce4d8ab
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
import net.kyori.adventure.text.Component;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.cloudburstmc.math.imaginary.Quaternionf;
import org.cloudburstmc.math.vector.Vector3d;
import org.cloudburstmc.math.vector.Vector3f;
import org.cloudburstmc.math.vector.Vector3i;
import org.cloudburstmc.math.vector.Vector4f;
import org.cloudburstmc.nbt.NBTInputStream;
import org.cloudburstmc.nbt.NBTOutputStream;
import org.cloudburstmc.nbt.NbtMap;
Expand Down Expand Up @@ -562,16 +562,16 @@ public static void writeRotation(ByteBuf buf, Vector3f rot) {
buf.writeFloat(rot.getZ());
}

public static Vector4f readQuaternion(ByteBuf buf) {
public static Quaternionf readQuaternion(ByteBuf buf) {
float x = buf.readFloat();
float y = buf.readFloat();
float z = buf.readFloat();
float w = buf.readFloat();

return Vector4f.from(x, y, z, w);
return Quaternionf.from(x, y, z, w);
}

public static void writeQuaternion(ByteBuf buf, Vector4f vec4) {
public static void writeQuaternion(ByteBuf buf, Quaternionf vec4) {
buf.writeFloat(vec4.getX());
buf.writeFloat(vec4.getY());
buf.writeFloat(vec4.getZ());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
import it.unimi.dsi.fastutil.ints.Int2ObjectFunction;
import lombok.Getter;
import net.kyori.adventure.text.Component;
import org.cloudburstmc.math.imaginary.Quaternionf;
import org.cloudburstmc.math.vector.Vector3f;
import org.cloudburstmc.math.vector.Vector3i;
import org.cloudburstmc.math.vector.Vector4f;
import org.cloudburstmc.nbt.NbtMap;
import org.geysermc.mcprotocollib.protocol.codec.MinecraftTypes;
import org.geysermc.mcprotocollib.protocol.data.game.Holder;
Expand Down Expand Up @@ -59,7 +59,7 @@ public class MetadataTypes<T> {
public static final MetadataType<SnifferState> SNIFFER_STATE = register(id -> new MetadataType<>(id, MinecraftTypes::readSnifferState, MinecraftTypes::writeSnifferState, ObjectEntityMetadata::new));
public static final MetadataType<ArmadilloState> ARMADILLO_STATE = register(id -> new MetadataType<>(id, MinecraftTypes::readArmadilloState, MinecraftTypes::writeArmadilloState, ObjectEntityMetadata::new));
public static final MetadataType<Vector3f> VECTOR3 = register(id -> new MetadataType<>(id, MinecraftTypes::readRotation, MinecraftTypes::writeRotation, ObjectEntityMetadata::new));
public static final MetadataType<Vector4f> QUATERNION =register(id -> new MetadataType<>(id, MinecraftTypes::readQuaternion, MinecraftTypes::writeQuaternion, ObjectEntityMetadata::new));
public static final MetadataType<Quaternionf> QUATERNION =register(id -> new MetadataType<>(id, MinecraftTypes::readQuaternion, MinecraftTypes::writeQuaternion, ObjectEntityMetadata::new));

public static <T extends MetadataType<?>> T register(Int2ObjectFunction<T> factory) {
T value = factory.apply(VALUES.size());
Expand Down

0 comments on commit ce4d8ab

Please sign in to comment.