synchronization rotation fix
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good

This commit is contained in:
austin 2024-08-16 18:11:59 -04:00
parent b37ee6c45f
commit d41f3f2b16
16 changed files with 241 additions and 37 deletions

View File

@ -1,3 +1,3 @@
#maven.buildNumber.plugin properties file #maven.buildNumber.plugin properties file
#Fri Aug 16 16:31:44 EDT 2024 #Fri Aug 16 18:09:29 EDT 2024
buildNumber=256 buildNumber=257

View File

@ -8,7 +8,6 @@
Script engine ability to spawn entities Script engine ability to spawn entities
+ rearchitecture + rearchitecture
Netconf file that pre-populates address, ip, username, password
Quad tree implementation to support grass placement and eventually chunk LOD management Quad tree implementation to support grass placement and eventually chunk LOD management
+ fix the vibes + fix the vibes
@ -21,7 +20,6 @@
Fix AI tracking deleted entity Fix AI tracking deleted entity
Fix server ground movement tree playing animation over falling animation Fix server ground movement tree playing animation over falling animation
Fix F2 menu not regaining controls when Xing menu instead of hitting F2 to close Fix F2 menu not regaining controls when Xing menu instead of hitting F2 to close
Fix rotation not sending correctly on initialization of creatures on client
Fix empty item slot not showing underneath dragged item Fix empty item slot not showing underneath dragged item
Fix grass rendering distance Fix grass rendering distance

View File

@ -599,6 +599,7 @@ Fix AI components not resetting on turning off ai manager
Fix broken rendering pipeline when creating new level Fix broken rendering pipeline when creating new level
Fix ui alignment for item panels in inventory menus (ie dont have to place in corner) Fix ui alignment for item panels in inventory menus (ie dont have to place in corner)
Netconfig file support Netconfig file support
Fix rotation not sending correctly on initialization of creatures on client
# TODO # TODO

View File

@ -191,7 +191,11 @@
"creatureTemplate", "creatureTemplate",
"positionX", "positionX",
"positionY", "positionY",
"positionZ" "positionZ",
"rotationX",
"rotationY",
"rotationZ",
"rotationW"
] ]
}, },
{ {
@ -202,7 +206,11 @@
"creatureTemplate", "creatureTemplate",
"positionX", "positionX",
"positionY", "positionY",
"positionZ" "positionZ",
"rotationX",
"rotationY",
"rotationZ",
"rotationW"
] ]
}, },
{ {
@ -213,7 +221,11 @@
"creatureTemplate", "creatureTemplate",
"positionX", "positionX",
"positionY", "positionY",
"positionZ" "positionZ",
"rotationX",
"rotationY",
"rotationZ",
"rotationW"
] ]
}, },
{ {
@ -236,7 +248,7 @@
}, },
{ {
"messageName" : "attackUpdate", "messageName" : "attackUpdate",
"description" : "Updates the client on the status of a given attack", "description" : "(Deprecated) Updates the client on the status of a given attack",
"data" : [ "data" : [
"entityID", "entityID",
"time", "time",
@ -298,7 +310,11 @@
"foliageSeed", "foliageSeed",
"positionX", "positionX",
"positionY", "positionY",
"positionZ" "positionZ",
"rotationX",
"rotationY",
"rotationZ",
"rotationW"
] ]
}, },
{ {

View File

@ -1,5 +1,6 @@
package electrosphere.client.fluid.cells; package electrosphere.client.fluid.cells;
import org.joml.Quaterniond;
import org.joml.Vector3d; import org.joml.Vector3d;
import org.joml.Vector3i; import org.joml.Vector3i;
import org.ode4j.ode.DBody; import org.ode4j.ode.DBody;
@ -68,7 +69,7 @@ public class FluidCell {
modelEntity = FluidChunk.clientCreateFluidChunkEntity(weights); modelEntity = FluidChunk.clientCreateFluidChunkEntity(weights);
ClientEntityUtils.initiallyPositionEntity(modelEntity, getRealPos()); ClientEntityUtils.initiallyPositionEntity(modelEntity, getRealPos(), new Quaterniond());
} }
protected Vector3d getRealPos(){ protected Vector3d getRealPos(){

View File

@ -1,5 +1,6 @@
package electrosphere.client.terrain.cells; package electrosphere.client.terrain.cells;
import org.joml.Quaterniond;
import org.joml.Vector3d; import org.joml.Vector3d;
import org.joml.Vector3i; import org.joml.Vector3i;
import org.ode4j.ode.DBody; import org.ode4j.ode.DBody;
@ -81,7 +82,7 @@ public class DrawCell {
} }
modelEntity = TerrainChunk.clientCreateTerrainChunkEntity(chunkData, lod, atlas); modelEntity = TerrainChunk.clientCreateTerrainChunkEntity(chunkData, lod, atlas);
ClientEntityUtils.initiallyPositionEntity(modelEntity, getRealPos()); ClientEntityUtils.initiallyPositionEntity(modelEntity, getRealPos(), new Quaterniond());
} }
/** /**

View File

@ -1,5 +1,6 @@
package electrosphere.entity; package electrosphere.entity;
import org.joml.Quaterniond;
import org.joml.Vector3d; import org.joml.Vector3d;
import electrosphere.entity.types.collision.CollisionObjUtils; import electrosphere.entity.types.collision.CollisionObjUtils;
@ -16,9 +17,9 @@ public class ClientEntityUtils {
* @param entity * @param entity
* @param position * @param position
*/ */
public static void initiallyPositionEntity(Entity entity, Vector3d position){ public static void initiallyPositionEntity(Entity entity, Vector3d position, Quaterniond rotation){
//reposition entity //reposition entity
CollisionObjUtils.clientPositionCharacter(entity, position); CollisionObjUtils.clientPositionCharacter(entity, position, rotation);
} }
/** /**

View File

@ -280,7 +280,7 @@ public class ClientGroundMovementTree implements BehaviorTree {
} }
//we want to always update the server facing vector with where the client says they're facing //we want to always update the server facing vector with where the client says they're facing
EntityUtils.getRotation(parent).set(message.getrotationX(),message.getrotationY(),message.getrotationZ(),message.getrotationW()); EntityUtils.getRotation(parent).set(message.getrotationX(),message.getrotationY(),message.getrotationZ(),message.getrotationW());
CollisionObjUtils.clientPositionCharacter(parent, position); CollisionObjUtils.clientPositionCharacter(parent, position, rotation);
// CreatureUtils.setFacingVector(parent, new Vector3d(message.getrotationX(),message.getrotationY(),message.getrotationZ())); // CreatureUtils.setFacingVector(parent, new Vector3d(message.getrotationX(),message.getrotationY(),message.getrotationZ()));
break; break;
} }

View File

@ -232,6 +232,7 @@ public class CollisionObjUtils {
*/ */
public static void clientAttachCollisionObjectToEntity(Entity entity, DBody collisionObject, float mass, String collidableType){ public static void clientAttachCollisionObjectToEntity(Entity entity, DBody collisionObject, float mass, String collidableType){
Vector3d position = EntityUtils.getPosition(entity); Vector3d position = EntityUtils.getPosition(entity);
Quaterniond rotation = EntityUtils.getRotation(entity);
Vector3f scale = EntityUtils.getScale(entity); Vector3f scale = EntityUtils.getScale(entity);
Collidable collidable = new Collidable(entity, collidableType, true); Collidable collidable = new Collidable(entity, collidableType, true);
Globals.clientSceneWrapper.getCollisionEngine().registerCollisionObject(collisionObject, collidable); Globals.clientSceneWrapper.getCollisionEngine().registerCollisionObject(collisionObject, collidable);
@ -239,7 +240,7 @@ public class CollisionObjUtils {
entity.putData(EntityDataStrings.PHYSICS_COLLISION_BODY, collisionObject); entity.putData(EntityDataStrings.PHYSICS_COLLISION_BODY, collisionObject);
//update world transform of collision object //update world transform of collision object
clientPositionCharacter(entity,position); clientPositionCharacter(entity,position,rotation);
entity.putData(EntityDataStrings.COLLISION_ENTITY_COLLISION_OBJECT, collisionObject); entity.putData(EntityDataStrings.COLLISION_ENTITY_COLLISION_OBJECT, collisionObject);
entity.putData(EntityDataStrings.COLLISION_ENTITY_COLLIDABLE, collidable); entity.putData(EntityDataStrings.COLLISION_ENTITY_COLLIDABLE, collidable);
@ -284,9 +285,8 @@ public class CollisionObjUtils {
} }
} }
public static void clientPositionCharacter(Entity e, Vector3d position){ public static void clientPositionCharacter(Entity e, Vector3d position, Quaterniond rotation){
EntityUtils.getPosition(e).set(position); EntityUtils.getPosition(e).set(position);
Quaterniond rotation = EntityUtils.getRotation(e);
DBody body = getCollisionBody(e); DBody body = getCollisionBody(e);
if(body != null){ if(body != null){
PhysicsUtils.setRigidBodyTransform(Globals.clientSceneWrapper.getCollisionEngine(), position, rotation, body); PhysicsUtils.setRigidBodyTransform(Globals.clientSceneWrapper.getCollisionEngine(), position, rotation, body);

View File

@ -1,5 +1,6 @@
package electrosphere.entity.types.creature; package electrosphere.entity.types.creature;
import org.joml.Quaterniond;
import org.joml.Vector3d; import org.joml.Vector3d;
import org.ode4j.ode.DBody; import org.ode4j.ode.DBody;
@ -720,13 +721,19 @@ public class CreatureUtils {
public static void sendEntityToPlayer(Player player, Entity creature){ public static void sendEntityToPlayer(Player player, Entity creature){
int id = creature.getId(); int id = creature.getId();
Vector3d position = EntityUtils.getPosition(creature); Vector3d position = EntityUtils.getPosition(creature);
Quaterniond rotation = EntityUtils.getRotation(creature);
String template = Utilities.stringify(CreatureUtils.getCreatureTemplate(creature)); String template = Utilities.stringify(CreatureUtils.getCreatureTemplate(creature));
NetworkMessage message = EntityMessage.constructSpawnCreatureMessage( NetworkMessage message = EntityMessage.constructSpawnCreatureMessage(
id, id,
template, template,
position.x, position.x,
position.y, position.y,
position.z); position.z,
rotation.x,
rotation.y,
rotation.z,
rotation.w
);
player.addMessage(message); player.addMessage(message);
if(CreatureUtils.hasControllerPlayerId(creature)){ if(CreatureUtils.hasControllerPlayerId(creature)){
LoggerInterface.loggerNetworking.INFO("Sending controller packets"); LoggerInterface.loggerNetworking.INFO("Sending controller packets");

View File

@ -18,6 +18,7 @@ import electrosphere.renderer.actor.ActorUtils;
import electrosphere.server.datacell.Realm; import electrosphere.server.datacell.Realm;
import electrosphere.server.datacell.utils.ServerEntityTagUtils; import electrosphere.server.datacell.utils.ServerEntityTagUtils;
import org.joml.Quaterniond;
import org.joml.Vector3d; import org.joml.Vector3d;
/** /**
@ -153,6 +154,7 @@ public class FoliageUtils {
int id = foliage.getId(); int id = foliage.getId();
FoliageType type = FoliageUtils.getFoliageType(foliage); FoliageType type = FoliageUtils.getFoliageType(foliage);
Vector3d position = EntityUtils.getPosition(foliage); Vector3d position = EntityUtils.getPosition(foliage);
Quaterniond rotation = EntityUtils.getRotation(foliage);
if(FoliageUtils.hasSeed(foliage)){ if(FoliageUtils.hasSeed(foliage)){
long seed = FoliageUtils.getFoliageSeed(foliage); long seed = FoliageUtils.getFoliageSeed(foliage);
NetworkMessage message = EntityMessage.constructSpawnFoliageSeedMessage( NetworkMessage message = EntityMessage.constructSpawnFoliageSeedMessage(
@ -161,7 +163,11 @@ public class FoliageUtils {
seed, seed,
position.x, position.x,
position.y, position.y,
position.z position.z,
rotation.x,
rotation.y,
rotation.z,
rotation.w
); );
player.addMessage(message); player.addMessage(message);
} else { } else {

View File

@ -2,6 +2,7 @@ package electrosphere.entity.types.item;
import java.util.List; import java.util.List;
import org.joml.Quaterniond;
import org.joml.Vector3d; import org.joml.Vector3d;
import org.ode4j.ode.DBody; import org.ode4j.ode.DBody;
@ -266,13 +267,19 @@ public class ItemUtils {
int id = item.getId(); int id = item.getId();
String type = ItemUtils.getType(item); String type = ItemUtils.getType(item);
Vector3d position = EntityUtils.getPosition(item); Vector3d position = EntityUtils.getPosition(item);
Quaterniond rotation = EntityUtils.getRotation(item);
//construct the spawn message and attach to player //construct the spawn message and attach to player
NetworkMessage message = EntityMessage.constructSpawnItemMessage( NetworkMessage message = EntityMessage.constructSpawnItemMessage(
id, id,
type, type,
position.x, position.x,
position.y, position.y,
position.z); position.z,
rotation.x,
rotation.y,
rotation.z,
rotation.w
);
player.addMessage(message); player.addMessage(message);
} }

View File

@ -1,5 +1,6 @@
package electrosphere.entity.types.object; package electrosphere.entity.types.object;
import org.joml.Quaterniond;
import org.joml.Vector3d; import org.joml.Vector3d;
import org.ode4j.ode.DBody; import org.ode4j.ode.DBody;
@ -245,13 +246,18 @@ public class ObjectUtils {
int id = object.getId(); int id = object.getId();
String type = ObjectUtils.getType(object); String type = ObjectUtils.getType(object);
Vector3d position = EntityUtils.getPosition(object); Vector3d position = EntityUtils.getPosition(object);
Quaterniond rotation = EntityUtils.getRotation(object);
//construct the spawn message and attach to player //construct the spawn message and attach to player
NetworkMessage message = EntityMessage.constructSpawnObjectMessage( NetworkMessage message = EntityMessage.constructSpawnObjectMessage(
id, id,
type, type,
position.x, position.x,
position.y, position.y,
position.z position.z,
rotation.x,
rotation.y,
rotation.z,
rotation.w
); );
player.addMessage(message); player.addMessage(message);
} }

View File

@ -94,7 +94,11 @@ public class EntityProtocol implements ClientProtocolTemplate<EntityMessage> {
LoggerInterface.loggerNetworking.DEBUG("Spawn Creature " + message.getentityID() + " at " + message.getpositionX() + " " + message.getpositionY() + " " + message.getpositionZ()); LoggerInterface.loggerNetworking.DEBUG("Spawn Creature " + message.getentityID() + " at " + message.getpositionX() + " " + message.getpositionY() + " " + message.getpositionZ());
CreatureTemplate template = Utilities.deserialize(message.getcreatureTemplate(), CreatureTemplate.class); CreatureTemplate template = Utilities.deserialize(message.getcreatureTemplate(), CreatureTemplate.class);
newlySpawnedEntity = CreatureUtils.clientSpawnBasicCreature(template.getCreatureType(),template); newlySpawnedEntity = CreatureUtils.clientSpawnBasicCreature(template.getCreatureType(),template);
ClientEntityUtils.initiallyPositionEntity(newlySpawnedEntity, new Vector3d(message.getpositionX(),message.getpositionY(),message.getpositionZ())); ClientEntityUtils.initiallyPositionEntity(
newlySpawnedEntity,
new Vector3d(message.getpositionX(),message.getpositionY(),message.getpositionZ()),
new Quaterniond(message.getrotationX(),message.getrotationY(),message.getrotationZ(),message.getrotationW())
);
Globals.clientSceneWrapper.mapIdToId(newlySpawnedEntity.getId(), message.getentityID()); Globals.clientSceneWrapper.mapIdToId(newlySpawnedEntity.getId(), message.getentityID());
//if the creature template includes an equip section, spawn all the equipped items //if the creature template includes an equip section, spawn all the equipped items
if(template != null && template.getCreatureEquipData() != null && template.getCreatureEquipData().getSlots() != null){ if(template != null && template.getCreatureEquipData() != null && template.getCreatureEquipData().getSlots() != null){
@ -123,14 +127,22 @@ public class EntityProtocol implements ClientProtocolTemplate<EntityMessage> {
String itemType = message.getcreatureTemplate(); String itemType = message.getcreatureTemplate();
newlySpawnedEntity = ItemUtils.clientSpawnBasicItem(itemType); newlySpawnedEntity = ItemUtils.clientSpawnBasicItem(itemType);
//position //position
ClientEntityUtils.initiallyPositionEntity(newlySpawnedEntity, new Vector3d(message.getpositionX(),message.getpositionY(),message.getpositionZ())); ClientEntityUtils.initiallyPositionEntity(
newlySpawnedEntity,
new Vector3d(message.getpositionX(),message.getpositionY(),message.getpositionZ()),
new Quaterniond(message.getrotationX(),message.getrotationY(),message.getrotationZ(),message.getrotationW())
);
Globals.clientSceneWrapper.mapIdToId(newlySpawnedEntity.getId(), message.getentityID()); Globals.clientSceneWrapper.mapIdToId(newlySpawnedEntity.getId(), message.getentityID());
} break; } break;
case SPAWNFOLIAGESEED: { case SPAWNFOLIAGESEED: {
LoggerInterface.loggerNetworking.DEBUG("Spawn foliage " + message.getentityID() + " at " + message.getpositionX() + " " + message.getpositionY() + " " + message.getpositionZ()); LoggerInterface.loggerNetworking.DEBUG("Spawn foliage " + message.getentityID() + " at " + message.getpositionX() + " " + message.getpositionY() + " " + message.getpositionZ());
String type = message.getcreatureTemplate(); String type = message.getcreatureTemplate();
newlySpawnedEntity = FoliageUtils.spawnBasicFoliage(type,message.getfoliageSeed()); newlySpawnedEntity = FoliageUtils.spawnBasicFoliage(type,message.getfoliageSeed());
ClientEntityUtils.initiallyPositionEntity(newlySpawnedEntity, new Vector3d(message.getpositionX(),message.getpositionY(),message.getpositionZ())); ClientEntityUtils.initiallyPositionEntity(
newlySpawnedEntity,
new Vector3d(message.getpositionX(),message.getpositionY(),message.getpositionZ()),
new Quaterniond(message.getrotationX(),message.getrotationY(),message.getrotationZ(),message.getrotationW())
);
Globals.clientSceneWrapper.mapIdToId(newlySpawnedEntity.getId(), message.getentityID()); Globals.clientSceneWrapper.mapIdToId(newlySpawnedEntity.getId(), message.getentityID());
} break; } break;
case SPAWNOBJECT: { case SPAWNOBJECT: {
@ -139,7 +151,11 @@ public class EntityProtocol implements ClientProtocolTemplate<EntityMessage> {
String objectType = message.getcreatureTemplate(); String objectType = message.getcreatureTemplate();
newlySpawnedEntity = ObjectUtils.clientSpawnBasicObject(objectType); newlySpawnedEntity = ObjectUtils.clientSpawnBasicObject(objectType);
//position //position
ClientEntityUtils.initiallyPositionEntity(newlySpawnedEntity, new Vector3d(message.getpositionX(),message.getpositionY(),message.getpositionZ())); ClientEntityUtils.initiallyPositionEntity(
newlySpawnedEntity,
new Vector3d(message.getpositionX(),message.getpositionY(),message.getpositionZ()),
new Quaterniond(message.getrotationX(),message.getrotationY(),message.getrotationZ(),message.getrotationW())
);
Globals.clientSceneWrapper.mapIdToId(newlySpawnedEntity.getId(), message.getentityID()); Globals.clientSceneWrapper.mapIdToId(newlySpawnedEntity.getId(), message.getentityID());
} break; } break;

View File

@ -560,6 +560,18 @@ public class EntityMessage extends NetworkMessage {
if(currentStreamLength < 34 + creatureTemplateSize){ if(currentStreamLength < 34 + creatureTemplateSize){
return false; return false;
} }
if(currentStreamLength < 42 + creatureTemplateSize){
return false;
}
if(currentStreamLength < 50 + creatureTemplateSize){
return false;
}
if(currentStreamLength < 58 + creatureTemplateSize){
return false;
}
if(currentStreamLength < 66 + creatureTemplateSize){
return false;
}
return true; return true;
} }
@ -571,16 +583,24 @@ public class EntityMessage extends NetworkMessage {
rVal.setpositionX(ByteStreamUtils.popDoubleFromByteQueue(byteBuffer)); rVal.setpositionX(ByteStreamUtils.popDoubleFromByteQueue(byteBuffer));
rVal.setpositionY(ByteStreamUtils.popDoubleFromByteQueue(byteBuffer)); rVal.setpositionY(ByteStreamUtils.popDoubleFromByteQueue(byteBuffer));
rVal.setpositionZ(ByteStreamUtils.popDoubleFromByteQueue(byteBuffer)); rVal.setpositionZ(ByteStreamUtils.popDoubleFromByteQueue(byteBuffer));
rVal.setrotationX(ByteStreamUtils.popDoubleFromByteQueue(byteBuffer));
rVal.setrotationY(ByteStreamUtils.popDoubleFromByteQueue(byteBuffer));
rVal.setrotationZ(ByteStreamUtils.popDoubleFromByteQueue(byteBuffer));
rVal.setrotationW(ByteStreamUtils.popDoubleFromByteQueue(byteBuffer));
return rVal; return rVal;
} }
public static EntityMessage constructSpawnCreatureMessage(int entityID,String creatureTemplate,double positionX,double positionY,double positionZ){ public static EntityMessage constructSpawnCreatureMessage(int entityID,String creatureTemplate,double positionX,double positionY,double positionZ,double rotationX,double rotationY,double rotationZ,double rotationW){
EntityMessage rVal = new EntityMessage(EntityMessageType.SPAWNCREATURE); EntityMessage rVal = new EntityMessage(EntityMessageType.SPAWNCREATURE);
rVal.setentityID(entityID); rVal.setentityID(entityID);
rVal.setcreatureTemplate(creatureTemplate); rVal.setcreatureTemplate(creatureTemplate);
rVal.setpositionX(positionX); rVal.setpositionX(positionX);
rVal.setpositionY(positionY); rVal.setpositionY(positionY);
rVal.setpositionZ(positionZ); rVal.setpositionZ(positionZ);
rVal.setrotationX(rotationX);
rVal.setrotationY(rotationY);
rVal.setrotationZ(rotationZ);
rVal.setrotationW(rotationW);
rVal.serialize(); rVal.serialize();
return rVal; return rVal;
} }
@ -613,6 +633,18 @@ public class EntityMessage extends NetworkMessage {
if(currentStreamLength < 34 + creatureTemplateSize){ if(currentStreamLength < 34 + creatureTemplateSize){
return false; return false;
} }
if(currentStreamLength < 42 + creatureTemplateSize){
return false;
}
if(currentStreamLength < 50 + creatureTemplateSize){
return false;
}
if(currentStreamLength < 58 + creatureTemplateSize){
return false;
}
if(currentStreamLength < 66 + creatureTemplateSize){
return false;
}
return true; return true;
} }
@ -624,16 +656,24 @@ public class EntityMessage extends NetworkMessage {
rVal.setpositionX(ByteStreamUtils.popDoubleFromByteQueue(byteBuffer)); rVal.setpositionX(ByteStreamUtils.popDoubleFromByteQueue(byteBuffer));
rVal.setpositionY(ByteStreamUtils.popDoubleFromByteQueue(byteBuffer)); rVal.setpositionY(ByteStreamUtils.popDoubleFromByteQueue(byteBuffer));
rVal.setpositionZ(ByteStreamUtils.popDoubleFromByteQueue(byteBuffer)); rVal.setpositionZ(ByteStreamUtils.popDoubleFromByteQueue(byteBuffer));
rVal.setrotationX(ByteStreamUtils.popDoubleFromByteQueue(byteBuffer));
rVal.setrotationY(ByteStreamUtils.popDoubleFromByteQueue(byteBuffer));
rVal.setrotationZ(ByteStreamUtils.popDoubleFromByteQueue(byteBuffer));
rVal.setrotationW(ByteStreamUtils.popDoubleFromByteQueue(byteBuffer));
return rVal; return rVal;
} }
public static EntityMessage constructSpawnItemMessage(int entityID,String creatureTemplate,double positionX,double positionY,double positionZ){ public static EntityMessage constructSpawnItemMessage(int entityID,String creatureTemplate,double positionX,double positionY,double positionZ,double rotationX,double rotationY,double rotationZ,double rotationW){
EntityMessage rVal = new EntityMessage(EntityMessageType.SPAWNITEM); EntityMessage rVal = new EntityMessage(EntityMessageType.SPAWNITEM);
rVal.setentityID(entityID); rVal.setentityID(entityID);
rVal.setcreatureTemplate(creatureTemplate); rVal.setcreatureTemplate(creatureTemplate);
rVal.setpositionX(positionX); rVal.setpositionX(positionX);
rVal.setpositionY(positionY); rVal.setpositionY(positionY);
rVal.setpositionZ(positionZ); rVal.setpositionZ(positionZ);
rVal.setrotationX(rotationX);
rVal.setrotationY(rotationY);
rVal.setrotationZ(rotationZ);
rVal.setrotationW(rotationW);
rVal.serialize(); rVal.serialize();
return rVal; return rVal;
} }
@ -666,6 +706,18 @@ public class EntityMessage extends NetworkMessage {
if(currentStreamLength < 34 + creatureTemplateSize){ if(currentStreamLength < 34 + creatureTemplateSize){
return false; return false;
} }
if(currentStreamLength < 42 + creatureTemplateSize){
return false;
}
if(currentStreamLength < 50 + creatureTemplateSize){
return false;
}
if(currentStreamLength < 58 + creatureTemplateSize){
return false;
}
if(currentStreamLength < 66 + creatureTemplateSize){
return false;
}
return true; return true;
} }
@ -677,16 +729,24 @@ public class EntityMessage extends NetworkMessage {
rVal.setpositionX(ByteStreamUtils.popDoubleFromByteQueue(byteBuffer)); rVal.setpositionX(ByteStreamUtils.popDoubleFromByteQueue(byteBuffer));
rVal.setpositionY(ByteStreamUtils.popDoubleFromByteQueue(byteBuffer)); rVal.setpositionY(ByteStreamUtils.popDoubleFromByteQueue(byteBuffer));
rVal.setpositionZ(ByteStreamUtils.popDoubleFromByteQueue(byteBuffer)); rVal.setpositionZ(ByteStreamUtils.popDoubleFromByteQueue(byteBuffer));
rVal.setrotationX(ByteStreamUtils.popDoubleFromByteQueue(byteBuffer));
rVal.setrotationY(ByteStreamUtils.popDoubleFromByteQueue(byteBuffer));
rVal.setrotationZ(ByteStreamUtils.popDoubleFromByteQueue(byteBuffer));
rVal.setrotationW(ByteStreamUtils.popDoubleFromByteQueue(byteBuffer));
return rVal; return rVal;
} }
public static EntityMessage constructSpawnObjectMessage(int entityID,String creatureTemplate,double positionX,double positionY,double positionZ){ public static EntityMessage constructSpawnObjectMessage(int entityID,String creatureTemplate,double positionX,double positionY,double positionZ,double rotationX,double rotationY,double rotationZ,double rotationW){
EntityMessage rVal = new EntityMessage(EntityMessageType.SPAWNOBJECT); EntityMessage rVal = new EntityMessage(EntityMessageType.SPAWNOBJECT);
rVal.setentityID(entityID); rVal.setentityID(entityID);
rVal.setcreatureTemplate(creatureTemplate); rVal.setcreatureTemplate(creatureTemplate);
rVal.setpositionX(positionX); rVal.setpositionX(positionX);
rVal.setpositionY(positionY); rVal.setpositionY(positionY);
rVal.setpositionZ(positionZ); rVal.setpositionZ(positionZ);
rVal.setrotationX(rotationX);
rVal.setrotationY(rotationY);
rVal.setrotationZ(rotationZ);
rVal.setrotationW(rotationW);
rVal.serialize(); rVal.serialize();
return rVal; return rVal;
} }
@ -895,6 +955,18 @@ public class EntityMessage extends NetworkMessage {
if(currentStreamLength < 42 + creatureTemplateSize){ if(currentStreamLength < 42 + creatureTemplateSize){
return false; return false;
} }
if(currentStreamLength < 50 + creatureTemplateSize){
return false;
}
if(currentStreamLength < 58 + creatureTemplateSize){
return false;
}
if(currentStreamLength < 66 + creatureTemplateSize){
return false;
}
if(currentStreamLength < 74 + creatureTemplateSize){
return false;
}
return true; return true;
} }
@ -907,10 +979,14 @@ public class EntityMessage extends NetworkMessage {
rVal.setpositionX(ByteStreamUtils.popDoubleFromByteQueue(byteBuffer)); rVal.setpositionX(ByteStreamUtils.popDoubleFromByteQueue(byteBuffer));
rVal.setpositionY(ByteStreamUtils.popDoubleFromByteQueue(byteBuffer)); rVal.setpositionY(ByteStreamUtils.popDoubleFromByteQueue(byteBuffer));
rVal.setpositionZ(ByteStreamUtils.popDoubleFromByteQueue(byteBuffer)); rVal.setpositionZ(ByteStreamUtils.popDoubleFromByteQueue(byteBuffer));
rVal.setrotationX(ByteStreamUtils.popDoubleFromByteQueue(byteBuffer));
rVal.setrotationY(ByteStreamUtils.popDoubleFromByteQueue(byteBuffer));
rVal.setrotationZ(ByteStreamUtils.popDoubleFromByteQueue(byteBuffer));
rVal.setrotationW(ByteStreamUtils.popDoubleFromByteQueue(byteBuffer));
return rVal; return rVal;
} }
public static EntityMessage constructSpawnFoliageSeedMessage(int entityID,String creatureTemplate,long foliageSeed,double positionX,double positionY,double positionZ){ public static EntityMessage constructSpawnFoliageSeedMessage(int entityID,String creatureTemplate,long foliageSeed,double positionX,double positionY,double positionZ,double rotationX,double rotationY,double rotationZ,double rotationW){
EntityMessage rVal = new EntityMessage(EntityMessageType.SPAWNFOLIAGESEED); EntityMessage rVal = new EntityMessage(EntityMessageType.SPAWNFOLIAGESEED);
rVal.setentityID(entityID); rVal.setentityID(entityID);
rVal.setcreatureTemplate(creatureTemplate); rVal.setcreatureTemplate(creatureTemplate);
@ -918,6 +994,10 @@ public class EntityMessage extends NetworkMessage {
rVal.setpositionX(positionX); rVal.setpositionX(positionX);
rVal.setpositionY(positionY); rVal.setpositionY(positionY);
rVal.setpositionZ(positionZ); rVal.setpositionZ(positionZ);
rVal.setrotationX(rotationX);
rVal.setrotationY(rotationY);
rVal.setrotationZ(rotationZ);
rVal.setrotationW(rotationW);
rVal.serialize(); rVal.serialize();
return rVal; return rVal;
} }
@ -1039,7 +1119,7 @@ public class EntityMessage extends NetworkMessage {
} }
break; break;
case SPAWNCREATURE: case SPAWNCREATURE:
rawBytes = new byte[2+4+4+creatureTemplate.length()+8+8+8]; rawBytes = new byte[2+4+4+creatureTemplate.length()+8+8+8+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
@ -1068,9 +1148,25 @@ public class EntityMessage extends NetworkMessage {
for(int i = 0; i < 8; i++){ for(int i = 0; i < 8; i++){
rawBytes[26+creatureTemplate.length()+i] = intValues[i]; rawBytes[26+creatureTemplate.length()+i] = intValues[i];
} }
intValues = ByteStreamUtils.serializeDoubleToBytes(rotationX);
for(int i = 0; i < 8; i++){
rawBytes[34+creatureTemplate.length()+i] = intValues[i];
}
intValues = ByteStreamUtils.serializeDoubleToBytes(rotationY);
for(int i = 0; i < 8; i++){
rawBytes[42+creatureTemplate.length()+i] = intValues[i];
}
intValues = ByteStreamUtils.serializeDoubleToBytes(rotationZ);
for(int i = 0; i < 8; i++){
rawBytes[50+creatureTemplate.length()+i] = intValues[i];
}
intValues = ByteStreamUtils.serializeDoubleToBytes(rotationW);
for(int i = 0; i < 8; i++){
rawBytes[58+creatureTemplate.length()+i] = intValues[i];
}
break; break;
case SPAWNITEM: case SPAWNITEM:
rawBytes = new byte[2+4+4+creatureTemplate.length()+8+8+8]; rawBytes = new byte[2+4+4+creatureTemplate.length()+8+8+8+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
@ -1099,9 +1195,25 @@ public class EntityMessage extends NetworkMessage {
for(int i = 0; i < 8; i++){ for(int i = 0; i < 8; i++){
rawBytes[26+creatureTemplate.length()+i] = intValues[i]; rawBytes[26+creatureTemplate.length()+i] = intValues[i];
} }
intValues = ByteStreamUtils.serializeDoubleToBytes(rotationX);
for(int i = 0; i < 8; i++){
rawBytes[34+creatureTemplate.length()+i] = intValues[i];
}
intValues = ByteStreamUtils.serializeDoubleToBytes(rotationY);
for(int i = 0; i < 8; i++){
rawBytes[42+creatureTemplate.length()+i] = intValues[i];
}
intValues = ByteStreamUtils.serializeDoubleToBytes(rotationZ);
for(int i = 0; i < 8; i++){
rawBytes[50+creatureTemplate.length()+i] = intValues[i];
}
intValues = ByteStreamUtils.serializeDoubleToBytes(rotationW);
for(int i = 0; i < 8; i++){
rawBytes[58+creatureTemplate.length()+i] = intValues[i];
}
break; break;
case SPAWNOBJECT: case SPAWNOBJECT:
rawBytes = new byte[2+4+4+creatureTemplate.length()+8+8+8]; rawBytes = new byte[2+4+4+creatureTemplate.length()+8+8+8+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
@ -1130,6 +1242,22 @@ public class EntityMessage extends NetworkMessage {
for(int i = 0; i < 8; i++){ for(int i = 0; i < 8; i++){
rawBytes[26+creatureTemplate.length()+i] = intValues[i]; rawBytes[26+creatureTemplate.length()+i] = intValues[i];
} }
intValues = ByteStreamUtils.serializeDoubleToBytes(rotationX);
for(int i = 0; i < 8; i++){
rawBytes[34+creatureTemplate.length()+i] = intValues[i];
}
intValues = ByteStreamUtils.serializeDoubleToBytes(rotationY);
for(int i = 0; i < 8; i++){
rawBytes[42+creatureTemplate.length()+i] = intValues[i];
}
intValues = ByteStreamUtils.serializeDoubleToBytes(rotationZ);
for(int i = 0; i < 8; i++){
rawBytes[50+creatureTemplate.length()+i] = intValues[i];
}
intValues = ByteStreamUtils.serializeDoubleToBytes(rotationW);
for(int i = 0; i < 8; i++){
rawBytes[58+creatureTemplate.length()+i] = intValues[i];
}
break; break;
case MOVEUPDATE: case MOVEUPDATE:
rawBytes = new byte[2+4+8+8+8+8+8+8+8+8+8+4+4]; rawBytes = new byte[2+4+8+8+8+8+8+8+8+8+8+4+4];
@ -1313,7 +1441,7 @@ public class EntityMessage extends NetworkMessage {
} }
break; break;
case SPAWNFOLIAGESEED: case SPAWNFOLIAGESEED:
rawBytes = new byte[2+4+4+creatureTemplate.length()+8+8+8+8]; rawBytes = new byte[2+4+4+creatureTemplate.length()+8+8+8+8+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
@ -1346,6 +1474,22 @@ public class EntityMessage extends NetworkMessage {
for(int i = 0; i < 8; i++){ for(int i = 0; i < 8; i++){
rawBytes[34+creatureTemplate.length()+i] = intValues[i]; rawBytes[34+creatureTemplate.length()+i] = intValues[i];
} }
intValues = ByteStreamUtils.serializeDoubleToBytes(rotationX);
for(int i = 0; i < 8; i++){
rawBytes[42+creatureTemplate.length()+i] = intValues[i];
}
intValues = ByteStreamUtils.serializeDoubleToBytes(rotationY);
for(int i = 0; i < 8; i++){
rawBytes[50+creatureTemplate.length()+i] = intValues[i];
}
intValues = ByteStreamUtils.serializeDoubleToBytes(rotationZ);
for(int i = 0; i < 8; i++){
rawBytes[58+creatureTemplate.length()+i] = intValues[i];
}
intValues = ByteStreamUtils.serializeDoubleToBytes(rotationW);
for(int i = 0; i < 8; i++){
rawBytes[66+creatureTemplate.length()+i] = intValues[i];
}
break; break;
case UPDATEENTITYVIEWDIR: case UPDATEENTITYVIEWDIR:
rawBytes = new byte[2+4+8+4+8+8]; rawBytes = new byte[2+4+8+4+8+8];

View File

@ -1,6 +1,6 @@
package electrosphere.net.parser.net.raw; package electrosphere.net.parser.net.raw;
import electrosphere.net.parser.net.message.NetworkMessage; import electrosphere.net.parser.net.message.NetworkMessage;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
@ -59,7 +59,7 @@ public class NetworkParser {
for(NetworkMessage message : outgoingMessageQueue){ for(NetworkMessage message : outgoingMessageQueue){
outgoingMessageQueue.remove(message); outgoingMessageQueue.remove(message);
// System.out.println("Write message of type " + message.getType()); // System.out.println("Write message of type " + message.getType());
outgoingStream.write(message.getRawBytes()); outgoingStream.write(message.getRawBytes());
} }
} }