used Vector
This commit is contained in:
@@ -1,18 +1,10 @@
|
|||||||
package mc.protocol.model;
|
package mc.protocol.model;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.ToString;
|
||||||
|
import mc.utils.vector.Vector3d;
|
||||||
|
|
||||||
@Data
|
@EqualsAndHashCode(callSuper = true)
|
||||||
public class Location {
|
@ToString(callSuper = true)
|
||||||
private double x = 0d;
|
public class Location extends Vector3d {
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,16 +1,26 @@
|
|||||||
package mc.protocol.model;
|
package mc.protocol.model;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.ToString;
|
||||||
|
import mc.utils.vector.Vector2f;
|
||||||
|
|
||||||
@Data
|
@EqualsAndHashCode(callSuper = true)
|
||||||
public class Look {
|
@ToString(callSuper = true)
|
||||||
private float yaw;
|
public class Look extends Vector2f {
|
||||||
private float pitch;
|
|
||||||
|
|
||||||
public Look set(float yaw, float pitch) {
|
/**
|
||||||
this.yaw = yaw;
|
* Equal X
|
||||||
this.pitch = pitch;
|
* @return X
|
||||||
|
*/
|
||||||
|
public float getYaw() {
|
||||||
|
return this.getX();
|
||||||
|
}
|
||||||
|
|
||||||
return this;
|
/**
|
||||||
|
* Equal Y
|
||||||
|
* @return Y
|
||||||
|
*/
|
||||||
|
public float getPitch() {
|
||||||
|
return this.getY();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,21 +43,27 @@ public class CPlayerPositionAndLookPacket implements ClientSidePacket {
|
|||||||
double x = netByteBuf.readDouble();
|
double x = netByteBuf.readDouble();
|
||||||
double y = netByteBuf.readDouble();
|
double y = netByteBuf.readDouble();
|
||||||
double z = 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 yaw = netByteBuf.readFloat();
|
||||||
float pitch = 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();
|
this.onGround = netByteBuf.readBoolean();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void passivate() {
|
public void passivate() {
|
||||||
|
this.position.set(0, 0, 0);
|
||||||
ProtocolObjectPool.getLocationPool().returnObject(this.position);
|
ProtocolObjectPool.getLocationPool().returnObject(this.position);
|
||||||
this.position = null;
|
this.position = null;
|
||||||
|
|
||||||
|
this.look.set(0, 0);
|
||||||
ProtocolObjectPool.getLookPool().returnObject(this.look);
|
ProtocolObjectPool.getLookPool().returnObject(this.look);
|
||||||
this.look = null;
|
this.look = null;
|
||||||
|
|
||||||
this.onGround = false;
|
this.onGround = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -36,15 +36,18 @@ public class PlayerLookPacket implements ClientSidePacket {
|
|||||||
public void readSelf(NetByteBuf netByteBuf) {
|
public void readSelf(NetByteBuf netByteBuf) {
|
||||||
float yaw = netByteBuf.readFloat();
|
float yaw = netByteBuf.readFloat();
|
||||||
float pitch = 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();
|
this.onGround = netByteBuf.readBoolean();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void passivate() {
|
public void passivate() {
|
||||||
|
this.look.set(0, 0);
|
||||||
ProtocolObjectPool.getLookPool().returnObject(this.look);
|
ProtocolObjectPool.getLookPool().returnObject(this.look);
|
||||||
this.look = null;
|
this.look = null;
|
||||||
|
|
||||||
this.onGround = false;
|
this.onGround = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,15 +39,18 @@ public class PlayerPositionPacket implements ClientSidePacket {
|
|||||||
double x = netByteBuf.readDouble();
|
double x = netByteBuf.readDouble();
|
||||||
double y = netByteBuf.readDouble();
|
double y = netByteBuf.readDouble();
|
||||||
double z = 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();
|
this.onGround = netByteBuf.readBoolean();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void passivate() {
|
public void passivate() {
|
||||||
|
this.position.set(0, 0, 0);
|
||||||
ProtocolObjectPool.getLocationPool().returnObject(this.position);
|
ProtocolObjectPool.getLocationPool().returnObject(this.position);
|
||||||
this.position = null;
|
this.position = null;
|
||||||
|
|
||||||
this.onGround = false;
|
this.onGround = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user