Archived
0

used Vector

This commit is contained in:
2021-07-12 19:10:40 +03:00
parent 51f01f84cf
commit 9c9523d629
5 changed files with 41 additions and 27 deletions

View File

@@ -1,18 +1,10 @@
package mc.protocol.model;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import mc.utils.vector.Vector3d;
@Data
public class Location {
private double x = 0d;
private double y = 0d;
private double z = 0d;
public Location set(double x, double y, double z) {
this.x = x;
this.y = y;
this.z = z;
return this;
}
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class Location extends Vector3d {
}

View File

@@ -1,16 +1,26 @@
package mc.protocol.model;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import mc.utils.vector.Vector2f;
@Data
public class Look {
private float yaw;
private float pitch;
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class Look extends Vector2f {
public Look set(float yaw, float pitch) {
this.yaw = yaw;
this.pitch = pitch;
/**
* Equal X
* @return X
*/
public float getYaw() {
return this.getX();
}
return this;
/**
* Equal Y
* @return Y
*/
public float getPitch() {
return this.getY();
}
}

View File

@@ -43,21 +43,27 @@ public class CPlayerPositionAndLookPacket implements ClientSidePacket {
double x = netByteBuf.readDouble();
double y = netByteBuf.readDouble();
double z = netByteBuf.readDouble();
this.position = ProtocolObjectPool.getLocationPool().borrowObject().set(x, y, z);
this.position = ProtocolObjectPool.getLocationPool().borrowObject();
position.set(x, y, z);
float yaw = netByteBuf.readFloat();
float pitch = netByteBuf.readFloat();
this.look = ProtocolObjectPool.getLookPool().borrowObject().set(yaw, pitch);
this.look = ProtocolObjectPool.getLookPool().borrowObject();
this.look.set(yaw, pitch);
this.onGround = netByteBuf.readBoolean();
}
@Override
public void passivate() {
this.position.set(0, 0, 0);
ProtocolObjectPool.getLocationPool().returnObject(this.position);
this.position = null;
this.look.set(0, 0);
ProtocolObjectPool.getLookPool().returnObject(this.look);
this.look = null;
this.onGround = false;
}

View File

@@ -36,15 +36,18 @@ public class PlayerLookPacket implements ClientSidePacket {
public void readSelf(NetByteBuf netByteBuf) {
float yaw = netByteBuf.readFloat();
float pitch = netByteBuf.readFloat();
this.look = ProtocolObjectPool.getLookPool().borrowObject().set(yaw, pitch);
this.look = ProtocolObjectPool.getLookPool().borrowObject();
this.look.set(yaw, pitch);
this.onGround = netByteBuf.readBoolean();
}
@Override
public void passivate() {
this.look.set(0, 0);
ProtocolObjectPool.getLookPool().returnObject(this.look);
this.look = null;
this.onGround = false;
}
}

View File

@@ -39,15 +39,18 @@ public class PlayerPositionPacket implements ClientSidePacket {
double x = netByteBuf.readDouble();
double y = netByteBuf.readDouble();
double z = netByteBuf.readDouble();
this.position = ProtocolObjectPool.getLocationPool().borrowObject().set(x, y, z);
this.position = ProtocolObjectPool.getLocationPool().borrowObject();
this.position.set(x, y, z);
this.onGround = netByteBuf.readBoolean();
}
@Override
public void passivate() {
this.position.set(0, 0, 0);
ProtocolObjectPool.getLocationPool().returnObject(this.position);
this.position = null;
this.onGround = false;
}