Re-enable streaming entities on connect
This commit is contained in:
parent
fedd5aaf87
commit
cd6f2cc6b4
@ -145,7 +145,9 @@ public class LoadingThread extends Thread {
|
|||||||
initCollisionEngine(Globals.RUN_SERVER);
|
initCollisionEngine(Globals.RUN_SERVER);
|
||||||
|
|
||||||
//initialize the "virtual" objects simulation
|
//initialize the "virtual" objects simulation
|
||||||
initMacroSimulation();
|
if(Globals.RUN_SERVER){
|
||||||
|
initMacroSimulation();
|
||||||
|
}
|
||||||
|
|
||||||
//initialize the "real" objects simulation
|
//initialize the "real" objects simulation
|
||||||
initMicroSimulation();
|
initMicroSimulation();
|
||||||
|
|||||||
@ -19,7 +19,7 @@ public class ClientFunctions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void updateSkyboxPos(){
|
static void updateSkyboxPos(){
|
||||||
if(Globals.skybox != null){
|
if(Globals.skybox != null && Globals.playerCharacter != null){
|
||||||
// Vector3f skyboxPos = EntityUtils.getPosition(Globals.skybox);
|
// Vector3f skyboxPos = EntityUtils.getPosition(Globals.skybox);
|
||||||
//
|
//
|
||||||
// Vector3f playerCameraPos = EntityUtils.getPosition(Globals.playerCamera);
|
// Vector3f playerCameraPos = EntityUtils.getPosition(Globals.playerCamera);
|
||||||
|
|||||||
@ -17,7 +17,7 @@ public class LoggerInterface {
|
|||||||
public static Logger loggerEngine;
|
public static Logger loggerEngine;
|
||||||
|
|
||||||
public static void initLoggers(){
|
public static void initLoggers(){
|
||||||
loggerNetworking = new Logger(LogLevel.WARNING);
|
loggerNetworking = new Logger(LogLevel.DEBUG);
|
||||||
loggerFileIO = new Logger(LogLevel.WARNING);
|
loggerFileIO = new Logger(LogLevel.WARNING);
|
||||||
loggerGameLogic = new Logger(LogLevel.WARNING);
|
loggerGameLogic = new Logger(LogLevel.WARNING);
|
||||||
loggerRenderer = new Logger(LogLevel.WARNING);
|
loggerRenderer = new Logger(LogLevel.WARNING);
|
||||||
|
|||||||
@ -23,9 +23,9 @@ public class EntityMessage extends NetworkMessage {
|
|||||||
int entityCategory;
|
int entityCategory;
|
||||||
String entitySubtype;
|
String entitySubtype;
|
||||||
int entityID;
|
int entityID;
|
||||||
float positionX;
|
double positionX;
|
||||||
float positionY;
|
double positionY;
|
||||||
float positionZ;
|
double positionZ;
|
||||||
float rotationW;
|
float rotationW;
|
||||||
float rotationX;
|
float rotationX;
|
||||||
float rotationY;
|
float rotationY;
|
||||||
@ -73,27 +73,27 @@ public class EntityMessage extends NetworkMessage {
|
|||||||
this.entityID = entityID;
|
this.entityID = entityID;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getpositionX() {
|
public double getpositionX() {
|
||||||
return positionX;
|
return positionX;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setpositionX(float positionX) {
|
public void setpositionX(double positionX) {
|
||||||
this.positionX = positionX;
|
this.positionX = positionX;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getpositionY() {
|
public double getpositionY() {
|
||||||
return positionY;
|
return positionY;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setpositionY(float positionY) {
|
public void setpositionY(double positionY) {
|
||||||
this.positionY = positionY;
|
this.positionY = positionY;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getpositionZ() {
|
public double getpositionZ() {
|
||||||
return positionZ;
|
return positionZ;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setpositionZ(float positionZ) {
|
public void setpositionZ(double positionZ) {
|
||||||
this.positionZ = positionZ;
|
this.positionZ = positionZ;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -286,13 +286,13 @@ public class EntityMessage extends NetworkMessage {
|
|||||||
if(currentStreamLength < 14 + entitySubtypeSize){
|
if(currentStreamLength < 14 + entitySubtypeSize){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(currentStreamLength < 14){
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if(currentStreamLength < 18){
|
if(currentStreamLength < 18){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(currentStreamLength < 22){
|
if(currentStreamLength < 26){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if(currentStreamLength < 34){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -304,13 +304,13 @@ public class EntityMessage extends NetworkMessage {
|
|||||||
rVal.setentityID(ByteStreamUtils.popIntFromByteQueue(byteStream));
|
rVal.setentityID(ByteStreamUtils.popIntFromByteQueue(byteStream));
|
||||||
rVal.setentityCategory(ByteStreamUtils.popIntFromByteQueue(byteStream));
|
rVal.setentityCategory(ByteStreamUtils.popIntFromByteQueue(byteStream));
|
||||||
rVal.setentitySubtype(ByteStreamUtils.popStringFromByteQueue(byteStream));
|
rVal.setentitySubtype(ByteStreamUtils.popStringFromByteQueue(byteStream));
|
||||||
rVal.setpositionX(ByteStreamUtils.popFloatFromByteQueue(byteStream));
|
rVal.setpositionX(ByteStreamUtils.popDoubleFromByteQueue(byteStream));
|
||||||
rVal.setpositionY(ByteStreamUtils.popFloatFromByteQueue(byteStream));
|
rVal.setpositionY(ByteStreamUtils.popDoubleFromByteQueue(byteStream));
|
||||||
rVal.setpositionZ(ByteStreamUtils.popFloatFromByteQueue(byteStream));
|
rVal.setpositionZ(ByteStreamUtils.popDoubleFromByteQueue(byteStream));
|
||||||
return rVal;
|
return rVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static EntityMessage constructCreateMessage(int entityID,int entityCategory,String entitySubtype,float positionX,float positionY,float positionZ){
|
public static EntityMessage constructCreateMessage(int entityID,int entityCategory,String entitySubtype,double positionX,double positionY,double positionZ){
|
||||||
EntityMessage rVal = new EntityMessage(EntityMessageType.CREATE);
|
EntityMessage rVal = new EntityMessage(EntityMessageType.CREATE);
|
||||||
rVal.setentityID(entityID);
|
rVal.setentityID(entityID);
|
||||||
rVal.setentityCategory(entityCategory);
|
rVal.setentityCategory(entityCategory);
|
||||||
@ -327,13 +327,13 @@ public class EntityMessage extends NetworkMessage {
|
|||||||
stripPacketHeader(byteStream);
|
stripPacketHeader(byteStream);
|
||||||
rVal.setentityID(ByteStreamUtils.popIntFromByteQueue(byteStream));
|
rVal.setentityID(ByteStreamUtils.popIntFromByteQueue(byteStream));
|
||||||
rVal.settime(ByteStreamUtils.popLongFromByteQueue(byteStream));
|
rVal.settime(ByteStreamUtils.popLongFromByteQueue(byteStream));
|
||||||
rVal.setpositionX(ByteStreamUtils.popFloatFromByteQueue(byteStream));
|
rVal.setpositionX(ByteStreamUtils.popDoubleFromByteQueue(byteStream));
|
||||||
rVal.setpositionY(ByteStreamUtils.popFloatFromByteQueue(byteStream));
|
rVal.setpositionY(ByteStreamUtils.popDoubleFromByteQueue(byteStream));
|
||||||
rVal.setpositionZ(ByteStreamUtils.popFloatFromByteQueue(byteStream));
|
rVal.setpositionZ(ByteStreamUtils.popDoubleFromByteQueue(byteStream));
|
||||||
return rVal;
|
return rVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static EntityMessage constructSetPositionMessage(int entityID,long time,float positionX,float positionY,float positionZ){
|
public static EntityMessage constructSetPositionMessage(int entityID,long time,double positionX,double positionY,double positionZ){
|
||||||
EntityMessage rVal = new EntityMessage(EntityMessageType.SETPOSITION);
|
EntityMessage rVal = new EntityMessage(EntityMessageType.SETPOSITION);
|
||||||
rVal.setentityID(entityID);
|
rVal.setentityID(entityID);
|
||||||
rVal.settime(time);
|
rVal.settime(time);
|
||||||
@ -371,9 +371,9 @@ public class EntityMessage extends NetworkMessage {
|
|||||||
stripPacketHeader(byteStream);
|
stripPacketHeader(byteStream);
|
||||||
rVal.setentityID(ByteStreamUtils.popIntFromByteQueue(byteStream));
|
rVal.setentityID(ByteStreamUtils.popIntFromByteQueue(byteStream));
|
||||||
rVal.settime(ByteStreamUtils.popLongFromByteQueue(byteStream));
|
rVal.settime(ByteStreamUtils.popLongFromByteQueue(byteStream));
|
||||||
rVal.setpositionX(ByteStreamUtils.popFloatFromByteQueue(byteStream));
|
rVal.setpositionX(ByteStreamUtils.popDoubleFromByteQueue(byteStream));
|
||||||
rVal.setpositionY(ByteStreamUtils.popFloatFromByteQueue(byteStream));
|
rVal.setpositionY(ByteStreamUtils.popDoubleFromByteQueue(byteStream));
|
||||||
rVal.setpositionZ(ByteStreamUtils.popFloatFromByteQueue(byteStream));
|
rVal.setpositionZ(ByteStreamUtils.popDoubleFromByteQueue(byteStream));
|
||||||
rVal.setrotationX(ByteStreamUtils.popFloatFromByteQueue(byteStream));
|
rVal.setrotationX(ByteStreamUtils.popFloatFromByteQueue(byteStream));
|
||||||
rVal.setrotationY(ByteStreamUtils.popFloatFromByteQueue(byteStream));
|
rVal.setrotationY(ByteStreamUtils.popFloatFromByteQueue(byteStream));
|
||||||
rVal.setrotationZ(ByteStreamUtils.popFloatFromByteQueue(byteStream));
|
rVal.setrotationZ(ByteStreamUtils.popFloatFromByteQueue(byteStream));
|
||||||
@ -382,7 +382,7 @@ public class EntityMessage extends NetworkMessage {
|
|||||||
return rVal;
|
return rVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static EntityMessage constructmoveUpdateMessage(int entityID,long time,float positionX,float positionY,float positionZ,float rotationX,float rotationY,float rotationZ,float velocity,int treeState){
|
public static EntityMessage constructmoveUpdateMessage(int entityID,long time,double positionX,double positionY,double positionZ,float rotationX,float rotationY,float rotationZ,float velocity,int treeState){
|
||||||
EntityMessage rVal = new EntityMessage(EntityMessageType.MOVEUPDATE);
|
EntityMessage rVal = new EntityMessage(EntityMessageType.MOVEUPDATE);
|
||||||
rVal.setentityID(entityID);
|
rVal.setentityID(entityID);
|
||||||
rVal.settime(time);
|
rVal.settime(time);
|
||||||
@ -403,9 +403,9 @@ public class EntityMessage extends NetworkMessage {
|
|||||||
stripPacketHeader(byteStream);
|
stripPacketHeader(byteStream);
|
||||||
rVal.setentityID(ByteStreamUtils.popIntFromByteQueue(byteStream));
|
rVal.setentityID(ByteStreamUtils.popIntFromByteQueue(byteStream));
|
||||||
rVal.settime(ByteStreamUtils.popLongFromByteQueue(byteStream));
|
rVal.settime(ByteStreamUtils.popLongFromByteQueue(byteStream));
|
||||||
rVal.setpositionX(ByteStreamUtils.popFloatFromByteQueue(byteStream));
|
rVal.setpositionX(ByteStreamUtils.popDoubleFromByteQueue(byteStream));
|
||||||
rVal.setpositionY(ByteStreamUtils.popFloatFromByteQueue(byteStream));
|
rVal.setpositionY(ByteStreamUtils.popDoubleFromByteQueue(byteStream));
|
||||||
rVal.setpositionZ(ByteStreamUtils.popFloatFromByteQueue(byteStream));
|
rVal.setpositionZ(ByteStreamUtils.popDoubleFromByteQueue(byteStream));
|
||||||
rVal.setrotationX(ByteStreamUtils.popFloatFromByteQueue(byteStream));
|
rVal.setrotationX(ByteStreamUtils.popFloatFromByteQueue(byteStream));
|
||||||
rVal.setrotationY(ByteStreamUtils.popFloatFromByteQueue(byteStream));
|
rVal.setrotationY(ByteStreamUtils.popFloatFromByteQueue(byteStream));
|
||||||
rVal.setrotationZ(ByteStreamUtils.popFloatFromByteQueue(byteStream));
|
rVal.setrotationZ(ByteStreamUtils.popFloatFromByteQueue(byteStream));
|
||||||
@ -414,7 +414,7 @@ public class EntityMessage extends NetworkMessage {
|
|||||||
return rVal;
|
return rVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static EntityMessage constructattackUpdateMessage(int entityID,long time,float positionX,float positionY,float positionZ,float rotationX,float rotationY,float rotationZ,float velocity,int treeState){
|
public static EntityMessage constructattackUpdateMessage(int entityID,long time,double positionX,double positionY,double positionZ,float rotationX,float rotationY,float rotationZ,float velocity,int treeState){
|
||||||
EntityMessage rVal = new EntityMessage(EntityMessageType.ATTACKUPDATE);
|
EntityMessage rVal = new EntityMessage(EntityMessageType.ATTACKUPDATE);
|
||||||
rVal.setentityID(entityID);
|
rVal.setentityID(entityID);
|
||||||
rVal.settime(time);
|
rVal.settime(time);
|
||||||
@ -435,13 +435,13 @@ public class EntityMessage extends NetworkMessage {
|
|||||||
stripPacketHeader(byteStream);
|
stripPacketHeader(byteStream);
|
||||||
rVal.setentityID(ByteStreamUtils.popIntFromByteQueue(byteStream));
|
rVal.setentityID(ByteStreamUtils.popIntFromByteQueue(byteStream));
|
||||||
rVal.settime(ByteStreamUtils.popLongFromByteQueue(byteStream));
|
rVal.settime(ByteStreamUtils.popLongFromByteQueue(byteStream));
|
||||||
rVal.setpositionX(ByteStreamUtils.popFloatFromByteQueue(byteStream));
|
rVal.setpositionX(ByteStreamUtils.popDoubleFromByteQueue(byteStream));
|
||||||
rVal.setpositionY(ByteStreamUtils.popFloatFromByteQueue(byteStream));
|
rVal.setpositionY(ByteStreamUtils.popDoubleFromByteQueue(byteStream));
|
||||||
rVal.setpositionZ(ByteStreamUtils.popFloatFromByteQueue(byteStream));
|
rVal.setpositionZ(ByteStreamUtils.popDoubleFromByteQueue(byteStream));
|
||||||
return rVal;
|
return rVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static EntityMessage constructMoveMessage(int entityID,long time,float positionX,float positionY,float positionZ){
|
public static EntityMessage constructMoveMessage(int entityID,long time,double positionX,double positionY,double positionZ){
|
||||||
EntityMessage rVal = new EntityMessage(EntityMessageType.MOVE);
|
EntityMessage rVal = new EntityMessage(EntityMessageType.MOVE);
|
||||||
rVal.setentityID(entityID);
|
rVal.setentityID(entityID);
|
||||||
rVal.settime(time);
|
rVal.settime(time);
|
||||||
@ -555,7 +555,7 @@ public class EntityMessage extends NetworkMessage {
|
|||||||
byte[] stringBytes;
|
byte[] stringBytes;
|
||||||
switch(this.messageType){
|
switch(this.messageType){
|
||||||
case CREATE:
|
case CREATE:
|
||||||
rawBytes = new byte[2+4+4+4+entitySubtype.length()+4+4+4];
|
rawBytes = new byte[2+4+4+4+entitySubtype.length()+8+8+8];
|
||||||
//message header
|
//message header
|
||||||
rawBytes[0] = TypeBytes.MESSAGE_TYPE_ENTITY;
|
rawBytes[0] = TypeBytes.MESSAGE_TYPE_ENTITY;
|
||||||
//entity messaage header
|
//entity messaage header
|
||||||
@ -576,18 +576,21 @@ public class EntityMessage extends NetworkMessage {
|
|||||||
for(int i = 0; i < entitySubtype.length(); i++){
|
for(int i = 0; i < entitySubtype.length(); i++){
|
||||||
rawBytes[14+i] = stringBytes[i];
|
rawBytes[14+i] = stringBytes[i];
|
||||||
}
|
}
|
||||||
intValues = ByteStreamUtils.serializeFloatToBytes(positionX);
|
intValues = ByteStreamUtils.serializeDoubleToBytes(positionX);
|
||||||
for(int i = 0; i < 4; i++){
|
for(int i = 0; i < 8; i++){
|
||||||
rawBytes[14+entitySubtype.length()+i] = intValues[i];
|
rawBytes[14+entitySubtype.length()+i] = intValues[i];
|
||||||
} intValues = ByteStreamUtils.serializeFloatToBytes(positionY);
|
}
|
||||||
for(int i = 0; i < 4; i++){
|
intValues = ByteStreamUtils.serializeDoubleToBytes(positionY);
|
||||||
rawBytes[18+entitySubtype.length()+i] = intValues[i];
|
for(int i = 0; i < 8; i++){
|
||||||
} intValues = ByteStreamUtils.serializeFloatToBytes(positionZ);
|
|
||||||
for(int i = 0; i < 4; i++){
|
|
||||||
rawBytes[22+entitySubtype.length()+i] = intValues[i];
|
rawBytes[22+entitySubtype.length()+i] = intValues[i];
|
||||||
} break;
|
}
|
||||||
|
intValues = ByteStreamUtils.serializeDoubleToBytes(positionZ);
|
||||||
|
for(int i = 0; i < 8; i++){
|
||||||
|
rawBytes[30+entitySubtype.length()+i] = intValues[i];
|
||||||
|
}
|
||||||
|
break;
|
||||||
case SETPOSITION:
|
case SETPOSITION:
|
||||||
rawBytes = new byte[2+4+8+4+4+4];
|
rawBytes = new byte[2+4+8+8+8+8];
|
||||||
//message header
|
//message header
|
||||||
rawBytes[0] = TypeBytes.MESSAGE_TYPE_ENTITY;
|
rawBytes[0] = TypeBytes.MESSAGE_TYPE_ENTITY;
|
||||||
//entity messaage header
|
//entity messaage header
|
||||||
@ -600,16 +603,19 @@ public class EntityMessage extends NetworkMessage {
|
|||||||
for(int i = 0; i < 8; i++){
|
for(int i = 0; i < 8; i++){
|
||||||
rawBytes[6+i] = intValues[i];
|
rawBytes[6+i] = intValues[i];
|
||||||
}
|
}
|
||||||
intValues = ByteStreamUtils.serializeFloatToBytes(positionX);
|
intValues = ByteStreamUtils.serializeDoubleToBytes(positionX);
|
||||||
for(int i = 0; i < 4; i++){
|
for(int i = 0; i < 8; i++){
|
||||||
rawBytes[14+i] = intValues[i];
|
rawBytes[14+i] = intValues[i];
|
||||||
} intValues = ByteStreamUtils.serializeFloatToBytes(positionY);
|
}
|
||||||
for(int i = 0; i < 4; i++){
|
intValues = ByteStreamUtils.serializeDoubleToBytes(positionY);
|
||||||
rawBytes[18+i] = intValues[i];
|
for(int i = 0; i < 8; i++){
|
||||||
} intValues = ByteStreamUtils.serializeFloatToBytes(positionZ);
|
|
||||||
for(int i = 0; i < 4; i++){
|
|
||||||
rawBytes[22+i] = intValues[i];
|
rawBytes[22+i] = intValues[i];
|
||||||
} break;
|
}
|
||||||
|
intValues = ByteStreamUtils.serializeDoubleToBytes(positionZ);
|
||||||
|
for(int i = 0; i < 8; i++){
|
||||||
|
rawBytes[30+i] = intValues[i];
|
||||||
|
}
|
||||||
|
break;
|
||||||
case SETFACING:
|
case SETFACING:
|
||||||
rawBytes = new byte[2+4+8+4+4+4];
|
rawBytes = new byte[2+4+8+4+4+4];
|
||||||
//message header
|
//message header
|
||||||
@ -635,7 +641,7 @@ public class EntityMessage extends NetworkMessage {
|
|||||||
rawBytes[22+i] = intValues[i];
|
rawBytes[22+i] = intValues[i];
|
||||||
} break;
|
} break;
|
||||||
case MOVEUPDATE:
|
case MOVEUPDATE:
|
||||||
rawBytes = new byte[2+4+8+4+4+4+4+4+4+4+4];
|
rawBytes = new byte[2+4+8+8+8+8+4+4+4+4+4];
|
||||||
//message header
|
//message header
|
||||||
rawBytes[0] = TypeBytes.MESSAGE_TYPE_ENTITY;
|
rawBytes[0] = TypeBytes.MESSAGE_TYPE_ENTITY;
|
||||||
//entity messaage header
|
//entity messaage header
|
||||||
@ -648,34 +654,37 @@ public class EntityMessage extends NetworkMessage {
|
|||||||
for(int i = 0; i < 8; i++){
|
for(int i = 0; i < 8; i++){
|
||||||
rawBytes[6+i] = intValues[i];
|
rawBytes[6+i] = intValues[i];
|
||||||
}
|
}
|
||||||
intValues = ByteStreamUtils.serializeFloatToBytes(positionX);
|
intValues = ByteStreamUtils.serializeDoubleToBytes(positionX);
|
||||||
for(int i = 0; i < 4; i++){
|
for(int i = 0; i < 8; i++){
|
||||||
rawBytes[14+i] = intValues[i];
|
rawBytes[14+i] = intValues[i];
|
||||||
} intValues = ByteStreamUtils.serializeFloatToBytes(positionY);
|
}
|
||||||
for(int i = 0; i < 4; i++){
|
intValues = ByteStreamUtils.serializeDoubleToBytes(positionY);
|
||||||
rawBytes[18+i] = intValues[i];
|
for(int i = 0; i < 8; i++){
|
||||||
} intValues = ByteStreamUtils.serializeFloatToBytes(positionZ);
|
|
||||||
for(int i = 0; i < 4; i++){
|
|
||||||
rawBytes[22+i] = intValues[i];
|
rawBytes[22+i] = intValues[i];
|
||||||
} intValues = ByteStreamUtils.serializeFloatToBytes(rotationX);
|
}
|
||||||
for(int i = 0; i < 4; i++){
|
intValues = ByteStreamUtils.serializeDoubleToBytes(positionZ);
|
||||||
rawBytes[26+i] = intValues[i];
|
for(int i = 0; i < 8; i++){
|
||||||
} intValues = ByteStreamUtils.serializeFloatToBytes(rotationY);
|
|
||||||
for(int i = 0; i < 4; i++){
|
|
||||||
rawBytes[30+i] = intValues[i];
|
rawBytes[30+i] = intValues[i];
|
||||||
} intValues = ByteStreamUtils.serializeFloatToBytes(rotationZ);
|
}
|
||||||
for(int i = 0; i < 4; i++){
|
intValues = ByteStreamUtils.serializeFloatToBytes(rotationX);
|
||||||
rawBytes[34+i] = intValues[i];
|
|
||||||
} intValues = ByteStreamUtils.serializeFloatToBytes(velocity);
|
|
||||||
for(int i = 0; i < 4; i++){
|
for(int i = 0; i < 4; i++){
|
||||||
rawBytes[38+i] = intValues[i];
|
rawBytes[38+i] = intValues[i];
|
||||||
} intValues = ByteStreamUtils.serializeIntToBytes(treeState);
|
} intValues = ByteStreamUtils.serializeFloatToBytes(rotationY);
|
||||||
for(int i = 0; i < 4; i++){
|
for(int i = 0; i < 4; i++){
|
||||||
rawBytes[42+i] = intValues[i];
|
rawBytes[42+i] = intValues[i];
|
||||||
|
} intValues = ByteStreamUtils.serializeFloatToBytes(rotationZ);
|
||||||
|
for(int i = 0; i < 4; i++){
|
||||||
|
rawBytes[46+i] = intValues[i];
|
||||||
|
} intValues = ByteStreamUtils.serializeFloatToBytes(velocity);
|
||||||
|
for(int i = 0; i < 4; i++){
|
||||||
|
rawBytes[50+i] = intValues[i];
|
||||||
|
} intValues = ByteStreamUtils.serializeIntToBytes(treeState);
|
||||||
|
for(int i = 0; i < 4; i++){
|
||||||
|
rawBytes[54+i] = intValues[i];
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ATTACKUPDATE:
|
case ATTACKUPDATE:
|
||||||
rawBytes = new byte[2+4+8+4+4+4+4+4+4+4+4];
|
rawBytes = new byte[2+4+8+8+8+8+4+4+4+4+4];
|
||||||
//message header
|
//message header
|
||||||
rawBytes[0] = TypeBytes.MESSAGE_TYPE_ENTITY;
|
rawBytes[0] = TypeBytes.MESSAGE_TYPE_ENTITY;
|
||||||
//entity messaage header
|
//entity messaage header
|
||||||
@ -688,34 +697,37 @@ public class EntityMessage extends NetworkMessage {
|
|||||||
for(int i = 0; i < 8; i++){
|
for(int i = 0; i < 8; i++){
|
||||||
rawBytes[6+i] = intValues[i];
|
rawBytes[6+i] = intValues[i];
|
||||||
}
|
}
|
||||||
intValues = ByteStreamUtils.serializeFloatToBytes(positionX);
|
intValues = ByteStreamUtils.serializeDoubleToBytes(positionX);
|
||||||
for(int i = 0; i < 4; i++){
|
for(int i = 0; i < 8; i++){
|
||||||
rawBytes[14+i] = intValues[i];
|
rawBytes[14+i] = intValues[i];
|
||||||
} intValues = ByteStreamUtils.serializeFloatToBytes(positionY);
|
}
|
||||||
for(int i = 0; i < 4; i++){
|
intValues = ByteStreamUtils.serializeDoubleToBytes(positionY);
|
||||||
rawBytes[18+i] = intValues[i];
|
for(int i = 0; i < 8; i++){
|
||||||
} intValues = ByteStreamUtils.serializeFloatToBytes(positionZ);
|
|
||||||
for(int i = 0; i < 4; i++){
|
|
||||||
rawBytes[22+i] = intValues[i];
|
rawBytes[22+i] = intValues[i];
|
||||||
} intValues = ByteStreamUtils.serializeFloatToBytes(rotationX);
|
}
|
||||||
for(int i = 0; i < 4; i++){
|
intValues = ByteStreamUtils.serializeDoubleToBytes(positionZ);
|
||||||
rawBytes[26+i] = intValues[i];
|
for(int i = 0; i < 8; i++){
|
||||||
} intValues = ByteStreamUtils.serializeFloatToBytes(rotationY);
|
|
||||||
for(int i = 0; i < 4; i++){
|
|
||||||
rawBytes[30+i] = intValues[i];
|
rawBytes[30+i] = intValues[i];
|
||||||
} intValues = ByteStreamUtils.serializeFloatToBytes(rotationZ);
|
}
|
||||||
for(int i = 0; i < 4; i++){
|
intValues = ByteStreamUtils.serializeFloatToBytes(rotationX);
|
||||||
rawBytes[34+i] = intValues[i];
|
|
||||||
} intValues = ByteStreamUtils.serializeFloatToBytes(velocity);
|
|
||||||
for(int i = 0; i < 4; i++){
|
for(int i = 0; i < 4; i++){
|
||||||
rawBytes[38+i] = intValues[i];
|
rawBytes[38+i] = intValues[i];
|
||||||
} intValues = ByteStreamUtils.serializeIntToBytes(treeState);
|
} intValues = ByteStreamUtils.serializeFloatToBytes(rotationY);
|
||||||
for(int i = 0; i < 4; i++){
|
for(int i = 0; i < 4; i++){
|
||||||
rawBytes[42+i] = intValues[i];
|
rawBytes[42+i] = intValues[i];
|
||||||
|
} intValues = ByteStreamUtils.serializeFloatToBytes(rotationZ);
|
||||||
|
for(int i = 0; i < 4; i++){
|
||||||
|
rawBytes[46+i] = intValues[i];
|
||||||
|
} intValues = ByteStreamUtils.serializeFloatToBytes(velocity);
|
||||||
|
for(int i = 0; i < 4; i++){
|
||||||
|
rawBytes[50+i] = intValues[i];
|
||||||
|
} intValues = ByteStreamUtils.serializeIntToBytes(treeState);
|
||||||
|
for(int i = 0; i < 4; i++){
|
||||||
|
rawBytes[54+i] = intValues[i];
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case MOVE:
|
case MOVE:
|
||||||
rawBytes = new byte[2+4+8+4+4+4];
|
rawBytes = new byte[2+4+8+8+8+8];
|
||||||
//message header
|
//message header
|
||||||
rawBytes[0] = TypeBytes.MESSAGE_TYPE_ENTITY;
|
rawBytes[0] = TypeBytes.MESSAGE_TYPE_ENTITY;
|
||||||
//entity messaage header
|
//entity messaage header
|
||||||
@ -728,16 +740,19 @@ public class EntityMessage extends NetworkMessage {
|
|||||||
for(int i = 0; i < 8; i++){
|
for(int i = 0; i < 8; i++){
|
||||||
rawBytes[6+i] = intValues[i];
|
rawBytes[6+i] = intValues[i];
|
||||||
}
|
}
|
||||||
intValues = ByteStreamUtils.serializeFloatToBytes(positionX);
|
intValues = ByteStreamUtils.serializeDoubleToBytes(positionX);
|
||||||
for(int i = 0; i < 4; i++){
|
for(int i = 0; i < 8; i++){
|
||||||
rawBytes[14+i] = intValues[i];
|
rawBytes[14+i] = intValues[i];
|
||||||
} intValues = ByteStreamUtils.serializeFloatToBytes(positionY);
|
}
|
||||||
for(int i = 0; i < 4; i++){
|
intValues = ByteStreamUtils.serializeDoubleToBytes(positionY);
|
||||||
rawBytes[18+i] = intValues[i];
|
for(int i = 0; i < 8; i++){
|
||||||
} intValues = ByteStreamUtils.serializeFloatToBytes(positionZ);
|
|
||||||
for(int i = 0; i < 4; i++){
|
|
||||||
rawBytes[22+i] = intValues[i];
|
rawBytes[22+i] = intValues[i];
|
||||||
} break;
|
}
|
||||||
|
intValues = ByteStreamUtils.serializeDoubleToBytes(positionZ);
|
||||||
|
for(int i = 0; i < 8; i++){
|
||||||
|
rawBytes[30+i] = intValues[i];
|
||||||
|
}
|
||||||
|
break;
|
||||||
case DESTROY:
|
case DESTROY:
|
||||||
rawBytes = new byte[2+4];
|
rawBytes = new byte[2+4];
|
||||||
//message header
|
//message header
|
||||||
|
|||||||
@ -34,7 +34,7 @@ Message categories
|
|||||||
public static final byte WORLD_MESSAGE_TYPE_REQUESTCHUNK_SIZE = 10;
|
public static final byte WORLD_MESSAGE_TYPE_REQUESTCHUNK_SIZE = 10;
|
||||||
public static final byte WORLD_MESSAGE_TYPE_UPDATE_SIZE = 10;
|
public static final byte WORLD_MESSAGE_TYPE_UPDATE_SIZE = 10;
|
||||||
public static final byte WORLD_MESSAGE_TYPE_CHUNKLOADSTART_SIZE = 14;
|
public static final byte WORLD_MESSAGE_TYPE_CHUNKLOADSTART_SIZE = 14;
|
||||||
public static final int WORLD_MESSAGE_TYPE_MACROVALUE_SIZE = 310;
|
public static final short WORLD_MESSAGE_TYPE_MACROVALUE_SIZE = 310;
|
||||||
public static final byte WORLD_MESSAGE_TYPE_HEIGHTMAPMODIFICATION_SIZE = 22;
|
public static final byte WORLD_MESSAGE_TYPE_HEIGHTMAPMODIFICATION_SIZE = 22;
|
||||||
public static final byte WORLD_MESSAGE_TYPE_SPAWNPOSITION_SIZE = 10;
|
public static final byte WORLD_MESSAGE_TYPE_SPAWNPOSITION_SIZE = 10;
|
||||||
/*
|
/*
|
||||||
@ -63,11 +63,11 @@ Message categories
|
|||||||
/*
|
/*
|
||||||
Entity packet sizes
|
Entity packet sizes
|
||||||
*/
|
*/
|
||||||
public static final byte ENTITY_MESSAGE_TYPE_SETPOSITION_SIZE = 26;
|
public static final byte ENTITY_MESSAGE_TYPE_SETPOSITION_SIZE = 38;
|
||||||
public static final byte ENTITY_MESSAGE_TYPE_SETFACING_SIZE = 26;
|
public static final byte ENTITY_MESSAGE_TYPE_SETFACING_SIZE = 26;
|
||||||
public static final byte ENTITY_MESSAGE_TYPE_MOVEUPDATE_SIZE = 46;
|
public static final byte ENTITY_MESSAGE_TYPE_MOVEUPDATE_SIZE = 58;
|
||||||
public static final byte ENTITY_MESSAGE_TYPE_ATTACKUPDATE_SIZE = 46;
|
public static final byte ENTITY_MESSAGE_TYPE_ATTACKUPDATE_SIZE = 58;
|
||||||
public static final byte ENTITY_MESSAGE_TYPE_MOVE_SIZE = 26;
|
public static final byte ENTITY_MESSAGE_TYPE_MOVE_SIZE = 38;
|
||||||
public static final byte ENTITY_MESSAGE_TYPE_DESTROY_SIZE = 6;
|
public static final byte ENTITY_MESSAGE_TYPE_DESTROY_SIZE = 6;
|
||||||
public static final byte ENTITY_MESSAGE_TYPE_SETBEHAVIORTREE_SIZE = 22;
|
public static final byte ENTITY_MESSAGE_TYPE_SETBEHAVIORTREE_SIZE = 22;
|
||||||
public static final byte ENTITY_MESSAGE_TYPE_SETPROPERTY_SIZE = 22;
|
public static final byte ENTITY_MESSAGE_TYPE_SETPROPERTY_SIZE = 22;
|
||||||
|
|||||||
@ -6,12 +6,12 @@ import java.util.concurrent.Semaphore;
|
|||||||
|
|
||||||
public class ByteStreamUtils {
|
public class ByteStreamUtils {
|
||||||
|
|
||||||
static ByteBuffer integerCompactor = ByteBuffer.allocate(8);
|
static ByteBuffer integerCompactor;
|
||||||
static Semaphore bufferLock = new Semaphore(1);
|
static Semaphore bufferLock = new Semaphore(1);
|
||||||
|
|
||||||
// static {
|
static {
|
||||||
// integerCompactor = ByteBuffer.allocate(8);
|
integerCompactor = ByteBuffer.allocate(8);
|
||||||
// }
|
}
|
||||||
|
|
||||||
public static int popIntFromByteQueue(List<Byte> queue){
|
public static int popIntFromByteQueue(List<Byte> queue){
|
||||||
int rVal = -1;
|
int rVal = -1;
|
||||||
@ -77,6 +77,27 @@ public class ByteStreamUtils {
|
|||||||
String rVal = new String(stringBytes);
|
String rVal = new String(stringBytes);
|
||||||
return rVal;
|
return rVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static double popDoubleFromByteQueue(List<Byte> queue){
|
||||||
|
double rVal = -1;
|
||||||
|
bufferLock.acquireUninterruptibly();
|
||||||
|
integerCompactor.clear();
|
||||||
|
integerCompactor.position(0);
|
||||||
|
integerCompactor.limit(8);
|
||||||
|
integerCompactor.put(0,queue.remove(0));
|
||||||
|
integerCompactor.put(1,queue.remove(0));
|
||||||
|
integerCompactor.put(2,queue.remove(0));
|
||||||
|
integerCompactor.put(3,queue.remove(0));
|
||||||
|
integerCompactor.put(4,queue.remove(0));
|
||||||
|
integerCompactor.put(5,queue.remove(0));
|
||||||
|
integerCompactor.put(6,queue.remove(0));
|
||||||
|
integerCompactor.put(7,queue.remove(0));
|
||||||
|
integerCompactor.position(0);
|
||||||
|
integerCompactor.limit(8);
|
||||||
|
rVal = integerCompactor.getDouble();
|
||||||
|
bufferLock.release();
|
||||||
|
return rVal;
|
||||||
|
}
|
||||||
|
|
||||||
public static byte[] serializeIntToBytes(int i){
|
public static byte[] serializeIntToBytes(int i){
|
||||||
byte[] rVal = new byte[4];
|
byte[] rVal = new byte[4];
|
||||||
@ -147,5 +168,26 @@ public class ByteStreamUtils {
|
|||||||
}
|
}
|
||||||
return rVal;
|
return rVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static byte[] serializeDoubleToBytes(double i){
|
||||||
|
byte[] rVal = new byte[8];
|
||||||
|
bufferLock.acquireUninterruptibly();
|
||||||
|
integerCompactor.clear();
|
||||||
|
integerCompactor.position(0);
|
||||||
|
integerCompactor.limit(8);
|
||||||
|
integerCompactor.putDouble(i);
|
||||||
|
integerCompactor.position(0);
|
||||||
|
integerCompactor.limit(8);
|
||||||
|
rVal[0] = integerCompactor.get(0);
|
||||||
|
rVal[1] = integerCompactor.get(1);
|
||||||
|
rVal[2] = integerCompactor.get(2);
|
||||||
|
rVal[3] = integerCompactor.get(3);
|
||||||
|
rVal[4] = integerCompactor.get(4);
|
||||||
|
rVal[5] = integerCompactor.get(5);
|
||||||
|
rVal[6] = integerCompactor.get(6);
|
||||||
|
rVal[7] = integerCompactor.get(7);
|
||||||
|
bufferLock.release();
|
||||||
|
return rVal;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -143,49 +143,49 @@ public class ServerConnectionHandler implements Runnable {
|
|||||||
//figure out what chunk they're in
|
//figure out what chunk they're in
|
||||||
|
|
||||||
//queue messages for that chunk
|
//queue messages for that chunk
|
||||||
// if(Globals.RUN_SERVER && Main.playerId == -1){
|
if(Globals.RUN_SERVER && Main.playerId == -1){
|
||||||
//
|
|
||||||
// } else {
|
} else {
|
||||||
// for(Entity currentEntity : Globals.entityManager.getMoveable()){
|
for(Entity currentEntity : Globals.entityManager.getMoveable()){
|
||||||
// networkParser.addOutgoingMessage(
|
networkParser.addOutgoingMessage(
|
||||||
// EntityMessage.constructCreateMessage(
|
EntityMessage.constructCreateMessage(
|
||||||
// currentEntity.getId(),
|
currentEntity.getId(),
|
||||||
// 0, //0 for creatures
|
0, //0 for creatures
|
||||||
// CreatureUtils.getType(currentEntity),
|
CreatureUtils.getType(currentEntity),
|
||||||
// EntityUtils.getPosition(currentEntity).x,
|
EntityUtils.getPosition(currentEntity).x,
|
||||||
// EntityUtils.getPosition(currentEntity).y,
|
EntityUtils.getPosition(currentEntity).y,
|
||||||
// EntityUtils.getPosition(currentEntity).z
|
EntityUtils.getPosition(currentEntity).z
|
||||||
// )
|
)
|
||||||
// );
|
);
|
||||||
// if(CreatureUtils.isCreature(currentEntity)){
|
if(CreatureUtils.isCreature(currentEntity)){
|
||||||
// if(CreatureUtils.hasControllerPlayerId(currentEntity)){
|
if(CreatureUtils.hasControllerPlayerId(currentEntity)){
|
||||||
// LoggerInterface.loggerNetworking.INFO("Sending controller packets");
|
LoggerInterface.loggerNetworking.INFO("Sending controller packets");
|
||||||
// networkParser.addOutgoingMessage(NetUtils.createSetCreatureControllerIdEntityMessage(currentEntity));
|
networkParser.addOutgoingMessage(NetUtils.createSetCreatureControllerIdEntityMessage(currentEntity));
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// for(Entity currentEntity : Globals.entityManager.getItemEntities()){
|
for(Entity currentEntity : Globals.entityManager.getItemEntities()){
|
||||||
// networkParser.addOutgoingMessage(
|
networkParser.addOutgoingMessage(
|
||||||
// EntityMessage.constructCreateMessage(
|
EntityMessage.constructCreateMessage(
|
||||||
// currentEntity.getId(),
|
currentEntity.getId(),
|
||||||
// 1, //1 for items
|
1, //1 for items
|
||||||
// ItemUtils.getType(currentEntity),
|
ItemUtils.getType(currentEntity),
|
||||||
// EntityUtils.getPosition(currentEntity).x,
|
EntityUtils.getPosition(currentEntity).x,
|
||||||
// EntityUtils.getPosition(currentEntity).y,
|
EntityUtils.getPosition(currentEntity).y,
|
||||||
// EntityUtils.getPosition(currentEntity).z
|
EntityUtils.getPosition(currentEntity).z
|
||||||
// )
|
)
|
||||||
// );
|
);
|
||||||
// if(AttachUtils.isAttached(currentEntity)){
|
if(AttachUtils.isAttached(currentEntity)){
|
||||||
// networkParser.addOutgoingMessage(
|
networkParser.addOutgoingMessage(
|
||||||
// EntityMessage.constructattachEntityToEntityMessage(
|
EntityMessage.constructattachEntityToEntityMessage(
|
||||||
// currentEntity.getId(),
|
currentEntity.getId(),
|
||||||
// AttachUtils.getTargetBone(currentEntity),
|
AttachUtils.getTargetBone(currentEntity),
|
||||||
// AttachUtils.getParent(currentEntity).getId()
|
AttachUtils.getParent(currentEntity).getId()
|
||||||
// )
|
)
|
||||||
// );
|
);
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
//let client know it's ready
|
//let client know it's ready
|
||||||
networkParser.addOutgoingMessage(StatusMessage.constructReadyMessage(1));
|
networkParser.addOutgoingMessage(StatusMessage.constructReadyMessage(1));
|
||||||
|
|||||||
@ -479,15 +479,15 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name" : "positionX",
|
"name" : "positionX",
|
||||||
"type" : "FIXED_FLOAT"
|
"type" : "FIXED_DOUBLE"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name" : "positionY",
|
"name" : "positionY",
|
||||||
"type" : "FIXED_FLOAT"
|
"type" : "FIXED_DOUBLE"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name" : "positionZ",
|
"name" : "positionZ",
|
||||||
"type" : "FIXED_FLOAT"
|
"type" : "FIXED_DOUBLE"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name" : "rotationW",
|
"name" : "rotationW",
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user