network fixes, documentation, etc

This commit is contained in:
austin 2024-06-07 19:42:48 -04:00
parent a30ac75573
commit 4ae09e7afb
32 changed files with 346 additions and 1262 deletions

View File

@ -13,34 +13,41 @@
"messageTypes" : [
{
"messageName" : "RequestCharacterList",
"description" : "Requests the list of characters from the server for the logged in user account",
"data" : []
},
{
"messageName" : "ResponseCharacterList",
"description" : "Gives the client the list of characters available to it",
"data" : [
"data"
]
},
{
"messageName" : "RequestCreateCharacter",
"description" : "Requests that the server create a new character with the data provided",
"data" : [
"data"
]
},
{
"messageName" : "ResponseCreateCharacterSuccess",
"description" : "Tells the client that it successfully created a character",
"data" : []
},
{
"messageName" : "ResponseCreateCharacterFailure",
"description" : "Tells the client that it failed to create a character",
"data" : []
},
{
"messageName" : "RequestSpawnCharacter",
"description" : "Requests that the server spawn the client in as a given character",
"data" : []
},
{
"messageName" : "ResponseSpawnCharacter",
"description" : "Deprecated - Unused",
"data" : [
"data"
]

View File

@ -117,6 +117,7 @@
"messageTypes" : [
{
"messageName" : "Create",
"description" : "Spawns an empty entity on the client",
"data" : [
"entityID",
"entityCategory",
@ -128,6 +129,7 @@
},
{
"messageName" : "SpawnCreature",
"description" : "Spawns a creature on the client",
"data" : [
"entityID",
"creatureTemplate",
@ -138,6 +140,7 @@
},
{
"messageName" : "SpawnItem",
"description" : "Spawns an item on the client",
"data" : [
"entityID",
"creatureTemplate",
@ -146,28 +149,9 @@
"positionZ"
]
},
{
"messageName" : "SetPosition",
"data" : [
"entityID",
"time",
"positionX",
"positionY",
"positionZ"
]
},
{
"messageName" : "setFacing",
"data" : [
"entityID",
"time",
"rotationX",
"rotationY",
"rotationZ"
]
},
{
"messageName" : "moveUpdate",
"description" : "Updates a client on the move state of an entity",
"data" : [
"entityID",
"time",
@ -179,11 +163,13 @@
"rotationZ",
"rotationW",
"velocity",
"propertyValueInt",
"treeState"
]
},
{
"messageName" : "attackUpdate",
"description" : "Updates the client on the status of a given attack",
"data" : [
"entityID",
"time",
@ -199,20 +185,12 @@
},
{
"messageName" : "startAttack",
"description" : "Alerts the server that the client wants to start attacking",
"data" : []
},
{
"messageName" : "Move",
"data" : [
"entityID",
"time",
"positionX",
"positionY",
"positionZ"
]
},
{
"messageName" : "Kill",
"description" : "Kills an entity (ie plays death animation, creates effects, etc -- does not actually delete the entity from data/scene)",
"data" : [
"time",
"entityID"
@ -220,21 +198,14 @@
},
{
"messageName" : "Destroy",
"description" : "Destroys an entity, clearing it from the client scene",
"data" : [
"entityID"
]
},
{
"messageName" : "SetBehaviorTree",
"data" : [
"entityID",
"time",
"treeType",
"treeStatus"
]
},
{
"messageName" : "setProperty",
"description" : "Sets a property on an entity (old method user to set the player's entity)",
"data" : [
"entityID",
"time",
@ -242,58 +213,9 @@
"propertyValue"
]
},
{
"messageName": "setBTreePropertyInt",
"data" : [
"entityID",
"time",
"bTreeID",
"propertyID",
"propertyValueInt"
]
},
{
"messageName": "setBTreePropertyFloat",
"data" : [
"entityID",
"time",
"bTreeID",
"propertyID",
"propertyValueFloat"
]
},
{
"messageName": "setBTreePropertyDouble",
"data" : [
"entityID",
"time",
"bTreeID",
"propertyID",
"propertyValueDouble"
]
},
{
"messageName": "setBTreePropertyString",
"data" : [
"entityID",
"time",
"bTreeID",
"propertyID",
"propertyValueString"
]
},
{
"messageName": "setBTreePropertyEnum",
"data" : [
"entityID",
"time",
"bTreeID",
"propertyID",
"propertyValueInt"
]
},
{
"messageName" : "attachEntityToEntity",
"description" : "Tells the client to attach an entity to another entity",
"data" : [
"entityID",
"bone",
@ -302,6 +224,7 @@
},
{
"messageName" : "SpawnFoliageSeed",
"description" : "Spawns a foliage object on the client with a given seed value",
"data" : [
"entityID",
"creatureTemplate",
@ -313,13 +236,13 @@
},
{
"messageName" : "updateEntityViewDir",
"description" : "Updates the server's value for where the player is looking",
"data" : [
"entityID",
"time",
"positionX",
"positionY",
"positionZ",
"propertyValueInt"
"positionZ"
]
}

View File

@ -42,6 +42,7 @@
},
{
"messageName" : "clientRequestEquipItem",
"description" : "Requests that the server equip an item to the player's entity",
"data" : [
"equipPointId",
"entityId"
@ -49,6 +50,7 @@
},
{
"messageName" : "serverCommandMoveItemContainer",
"description" : "Instructs the client to move an item to a container",
"data" : [
"entityId",
"containerType",
@ -57,6 +59,7 @@
},
{
"messageName" : "serverCommandEquipItem",
"description" : "Instructs the client to equip an item to an entity",
"data" : [
"equipperId",
"equipPointId",
@ -66,6 +69,7 @@
},
{
"messageName" : "serverCommandUnequipItem",
"description" : "Instructs the client to unequip an item",
"data" : [
"equipperId",
"equipPointId"
@ -73,6 +77,7 @@
},
{
"messageName" : "clientRequestUnequipItem",
"description" : "Requests that the server unequip an item from the client's entity",
"data" : [
"equipPointId"
]

View File

@ -13,32 +13,12 @@
"messageTypes" : [
{
"messageName" : "RequestRaces",
"description" : "Requests the data for all races available to the character to play",
"data" : []
},
{
"messageName" : "ResponseRaces",
"data" : [
"data"
]
},
{
"messageName" : "RequestRaceData",
"data" : []
},
{
"messageName" : "ResponseRaceData",
"data" : [
"data"
]
},
{
"messageName" : "RequestData",
"data" : [
"data"
]
},
{
"messageName" : "ResponseData",
"description" : "Responds with the data on all races available for play",
"data" : [
"data"
]

View File

@ -25,12 +25,14 @@
"messageTypes" : [
{
"messageName" : "Set_ID",
"description" : "Provides the server's id for the player",
"data" : [
"playerID"
]
},
{
"messageName" : "SetInitialDiscretePosition",
"description" : "Tells the client the initial position of the player entity",
"data" : [
"initialDiscretePositionX",
"initialDiscretePositionY",

View File

@ -10,10 +10,12 @@
"messageTypes" : [
{
"messageName" : "Ping",
"description" : "Pings the other side of the socket",
"data" : []
},
{
"messageName" : "Pong",
"description" : "Replies to a ping from the other side of the socket",
"data" : []
}
]
@ -35,10 +37,12 @@
"messageTypes" : [
{
"messageName" : "AuthRequest",
"description" : "Requests authorization from the client",
"data" : []
},
{
"messageName" : "AuthDetails",
"description" : "Tells the server the auth details of this client",
"data" : [
"user",
"pass"
@ -46,10 +50,12 @@
},
{
"messageName" : "AuthSuccess",
"description" : "Tells the client it successfully logged in",
"data" : []
},
{
"messageName" : "AuthFailure",
"description" : "Tells the client it failed to log in",
"data" : []
}
]

View File

@ -30,6 +30,7 @@
"messageTypes" : [
{
"messageName" : "UpdateClientState",
"description" : "Updates an integer on the client",
"data" : [
"entityId",
"bTreeId",
@ -39,6 +40,7 @@
},
{
"messageName" : "UpdateClientStringState",
"description" : "Updates a string on the client",
"data" : [
"entityId",
"bTreeId",
@ -48,6 +50,7 @@
},
{
"messageName" : "AttachTree",
"description" : "Attaches a btree to an entity on the client",
"data" : [
"entityId",
"bTreeId"
@ -55,6 +58,7 @@
},
{
"messageName" : "DetatchTree",
"description" : "Detatches a btree from an entity on the client",
"data" : [
"entityId",
"bTreeId"

View File

@ -102,10 +102,12 @@
"messageTypes" : [
{
"messageName" : "RequestMetadata",
"description" : "Requests terrain metadata from the server",
"data" : []
},
{
"messageName" : "ResponseMetadata",
"description" : "Tell the client the terrain metadata",
"data" : [
"worldSizeDiscrete",
"dynamicInterpolationRatio",
@ -116,15 +118,9 @@
"worldMaxY"
]
},
{
"messageName" : "RequestChunk",
"data" : [
"worldX",
"worldY"
]
},
{
"messageName" : "RequestEditVoxel",
"description" : "Requests that a voxel be edited on the server",
"data" : [
"worldX",
"worldY",
@ -138,6 +134,7 @@
},
{
"messageName" : "UpdateVoxel",
"description" : "Tells the client to update a voxel's value",
"data" : [
"worldX",
"worldY",
@ -151,6 +148,7 @@
},
{
"messageName" : "RequestUseTerrainPalette",
"description" : "Requests that the current player entity use a given terrain palette",
"data" : [
"realLocationX",
"realLocationY",
@ -162,6 +160,7 @@
},
{
"messageName" : "SpawnPosition",
"description" : "Sets the spawn position of the client",
"data" : [
"realLocationX",
"realLocationY",
@ -170,6 +169,7 @@
},
{
"messageName" : "RequestChunkData",
"description" : "Requests chunk data from the server",
"data" : [
"worldX",
"worldY",
@ -178,6 +178,7 @@
},
{
"messageName" : "sendChunkData",
"description" : "Sends chunk data to the client",
"data" : [
"worldX",
"worldY",
@ -187,6 +188,7 @@
},
{
"messageName" : "RequestFluidData",
"description" : "Requests a fluid data from the server",
"data" : [
"worldX",
"worldY",
@ -195,6 +197,7 @@
},
{
"messageName" : "sendFluidData",
"description" : "Sends fluid data to the client",
"data" : [
"worldX",
"worldY",
@ -204,6 +207,7 @@
},
{
"messageName" : "updateFluidData",
"description" : "Updates fluid data on the client",
"data" : [
"worldX",
"worldY",

View File

@ -10,6 +10,7 @@ import electrosphere.server.datacell.Realm;
import electrosphere.server.datacell.ServerDataCell;
import electrosphere.server.datacell.utils.EntityLookupUtils;
import electrosphere.server.datacell.utils.ServerBehaviorTreeUtils;
import electrosphere.server.datacell.utils.ServerEntityTagUtils;
import electrosphere.server.poseactor.PoseActorUtils;
public class EntityCreationUtils {
@ -86,6 +87,7 @@ public class EntityCreationUtils {
entity.putData(EntityDataStrings.DATA_STRING_SCALE, new Vector3f(1,1,1));
entity.putData(EntityDataStrings.DATA_STRING_DRAW, true);
entity.putData(EntityDataStrings.DRAW_SOLID_PASS, true);
ServerEntityTagUtils.attachTagToEntity(entity, EntityTags.POSEABLE);
}
@ -101,7 +103,6 @@ public class EntityCreationUtils {
entity.putData(EntityDataStrings.DATA_STRING_SCALE, new Vector3f(1,1,1));
entity.putData(EntityDataStrings.DATA_STRING_DRAW, true);
entity.putData(EntityDataStrings.DRAW_SOLID_PASS, true);
Globals.clientScene.registerEntity(entity);
Globals.clientScene.registerEntityToTag(entity, EntityTags.DRAWABLE);
}
@ -117,7 +118,6 @@ public class EntityCreationUtils {
entity.putData(EntityDataStrings.DATA_STRING_SCALE, new Vector3f(1,1,1));
entity.putData(EntityDataStrings.DATA_STRING_DRAW, true);
entity.putData(EntityDataStrings.DRAW_SOLID_PASS, true);
Globals.clientScene.registerEntity(entity);
Globals.clientScene.registerEntityToTag(entity, EntityTags.DRAWABLE);
}

View File

@ -19,6 +19,7 @@ public class EntityTags {
public static final String DRAWABLE = "drawable"; //is it drawable
public static final String DRAW_INSTANCED = "drawInstanced"; //if it's instanced, but not necessarily managed by a service (ie a tree branch)
public static final String DRAW_INSTANCED_MANAGED = "drawInstancedManaged"; //if it's managed by a service (ie foliage manager)
public static final String POSEABLE = "poseable"; //is it poseable on server
public static final String LIGHT = "light";
public static final String ITEM = "item";
public static final String GRAVITY = "gravity";

View File

@ -17,9 +17,7 @@ import electrosphere.entity.types.attach.AttachUtils;
import electrosphere.entity.types.collision.CollisionObjUtils;
import electrosphere.entity.types.creature.CreatureUtils;
import electrosphere.entity.types.item.ItemUtils;
import electrosphere.entity.types.projectile.ProjectileUtils;
import electrosphere.game.data.creature.type.attack.AttackMove;
import electrosphere.game.data.creature.type.equip.EquipPoint;
import electrosphere.net.parser.net.message.EntityMessage;
import electrosphere.net.synchronization.annotation.SyncedField;
import electrosphere.net.synchronization.annotation.SynchronizableEnum;
@ -29,9 +27,7 @@ import electrosphere.renderer.actor.Actor;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import org.joml.Quaterniond;
import org.joml.Vector3d;
import org.joml.Vector3f;
@SynchronizedBehaviorTree(name = "clientAttackTree", isServer = false, correspondingTree="serverAttackTree")
/**
@ -152,16 +148,20 @@ public class ClientAttackTree implements BehaviorTree {
@Override
public void simulate(float deltaTime){
frameCurrent = frameCurrent + (float)Globals.timekeeper.getDeltaFrames();
float velocity = CreatureUtils.getVelocity(parent);
Actor entityActor = EntityUtils.getActor(parent);
Vector3d position = EntityUtils.getPosition(parent);
Vector3d movementVector = CreatureUtils.getFacingVector(parent);
//
//synchronize move from server
if(this.currentMoveset == null){
this.currentMoveset = getMoveset(getAttackType());
}
if(this.currentMove == null && this.currentMoveId != null && this.currentMoveset != null){
if(
this.currentMoveset != null &&
(this.currentMove == null && this.currentMoveId != null)
||
(this.currentMove != null && this.currentMove.getAttackMoveId() != this.currentMoveId)
){
for(AttackMove move : currentMoveset){
if(move.getAttackMoveId().equals(currentMoveId)){
currentMove = move;
@ -169,6 +169,7 @@ public class ClientAttackTree implements BehaviorTree {
}
}
//
//parse attached network messages
for(EntityMessage message : networkMessageQueue){
networkMessageQueue.remove(message);
@ -204,17 +205,7 @@ public class ClientAttackTree implements BehaviorTree {
EntityUtils.getPosition(parent).set(message.getpositionX(),message.getpositionY(),message.getpositionZ());
CreatureUtils.setFacingVector(parent, new Vector3d(message.getrotationX(),message.getrotationY(),message.getrotationZ()));
break;
case ATTACHENTITYTOENTITY:
case CREATE:
case DESTROY:
case MOVE:
case MOVEUPDATE:
case SETBEHAVIORTREE:
case SETFACING:
case SETPOSITION:
case SETPROPERTY:
case KILL:
case SPAWNCREATURE:
default:
//silently ignore
break;
}
@ -246,7 +237,7 @@ public class ClientAttackTree implements BehaviorTree {
if(parent.containsKey(EntityDataStrings.CLIENT_ROTATOR_TREE)){
RotatorTree.getClientRotatorTree(parent).setActive(true);
}
if(currentMove != null && frameCurrent > currentMove.getWindupFrames()){
if(currentMove != null){
if(entityActor != null){
if(!entityActor.isPlayingAnimation() || !entityActor.isPlayingAnimation(currentMove.getWindupAnimationName())){
entityActor.playAnimation(currentMove.getWindupAnimationName(),1);
@ -281,39 +272,6 @@ public class ClientAttackTree implements BehaviorTree {
currentState.setActive(true);
}
}
if(firesProjectile && projectileToFire != null){
//spawn projectile
//TODO: solve spawnPosition, initialVector
Vector3d spawnPosition = new Vector3d(0,0,0);
Quaterniond arrowRotation = new Quaterniond();
String targetBone = null;
ClientEquipState equipState = ClientEquipState.getEquipState(parent);
EquipPoint weaponPoint = null;
if((weaponPoint = equipState.getEquipPoint(attackingPoint)) != null){
targetBone = weaponPoint.getBone();
}
if(targetBone != null){
Actor parentActor = EntityUtils.getActor(parent);
//transform bone space
spawnPosition = new Vector3d(parentActor.getBonePosition(targetBone));
spawnPosition = spawnPosition.mul(((Vector3f)EntityUtils.getScale(parent)));
Quaterniond rotation = EntityUtils.getRotation(parent);
spawnPosition = spawnPosition.rotate(new Quaterniond(rotation.x,rotation.y,rotation.z,rotation.w));
//transform worldspace
spawnPosition.add(new Vector3d(EntityUtils.getPosition(parent)));
//set
// EntityUtils.getPosition(currentEntity).set(position);
//set rotation
// Quaternionf rotation = parentActor.getBoneRotation(targetBone);
// EntityUtils.getRotation(currentEntity).set(rotation).normalize();
// Vector3d facingAngle = CreatureUtils.getFacingVector(parent);
arrowRotation = parentActor.getBoneRotation(targetBone);
// EntityUtils.getRotation(currentEntity).rotationTo(new Vector3f(0,0,1), new Vector3f((float)facingAngle.x,(float)facingAngle.y,(float)facingAngle.z)).mul(parentActor.getBoneRotation(targetBone)).normalize();
}
Vector3f initialVector = new Vector3f((float)movementVector.x,(float)movementVector.y,(float)movementVector.z).normalize();
ProjectileUtils.clientSpawnBasicProjectile(projectileToFire, spawnPosition, arrowRotation, 750, initialVector, 0.03f);
projectileToFire = null;
}
} break;
case COOLDOWN: {
//deactive hitboxes
@ -385,7 +343,7 @@ public class ClientAttackTree implements BehaviorTree {
}
} else {
if(ClientEquipState.hasEquipState(parent)){
ClientEquipState equipState = ClientEquipState.getEquipState(parent);
// ClientEquipState equipState = ClientEquipState.getEquipState(parent);
// if(equipState.hasEquipPrimary()){
// switch(attackType){
// case EntityDataStrings.ATTACK_MOVE_TYPE_MELEE_SWING_ONE_HAND:
@ -409,6 +367,12 @@ public class ClientAttackTree implements BehaviorTree {
return rVal;
}
/**
* Gets the object for next move in the current attack chain
* @param moveset The moveset to search
* @param nextMoveId The id of the next move
* @return The object that corresponds to the id if it exists, otherwise false
*/
AttackMove getNextMove(List<AttackMove> moveset, String nextMoveId){
AttackMove rVal = null;
for(AttackMove move : moveset){

View File

@ -9,7 +9,6 @@ import electrosphere.net.parser.net.message.SynchronizationMessage;
import electrosphere.server.datacell.utils.DataCellSearchUtils;
import electrosphere.collision.hitbox.HitboxUtils;
import electrosphere.engine.Globals;
import electrosphere.entity.Entity;
import electrosphere.entity.EntityDataStrings;
@ -72,8 +71,8 @@ public class ServerAttackTree implements BehaviorTree {
List<AttackMove> currentMoveset = null;
@SyncedField
String currentMoveId = null;
AttackMove currentMove = null;
String currentMoveId = null; //the id of the current move -- used to synchronize the move to client
AttackMove currentMove = null; //the actual current move object
Entity currentWeapon = null;
boolean currentMoveHasWindup;
boolean currentMoveCanHold;
@ -141,7 +140,7 @@ public class ServerAttackTree implements BehaviorTree {
}
Vector3d movementVector = CreatureUtils.getFacingVector(parent);
EntityUtils.getRotation(parent).rotationTo(new Vector3d(0,0,1), new Vector3d(movementVector.x,movementVector.y,movementVector.z));
//set initial stuff
//set initial stuff (this alerts the client as well)
setCurrentMoveId(currentMove.getAttackMoveId());
setState(AttackTreeState.WINDUP);
frameCurrent = 0;
@ -175,37 +174,9 @@ public class ServerAttackTree implements BehaviorTree {
//parse attached network messages
for(EntityMessage message : networkMessageQueue){
networkMessageQueue.remove(message);
// System.out.println("MOVE to " + message.getX() + " " + message.getY() + " " + message.getZ());
long updateTime = message.gettime();
switch(message.getMessageSubtype()){
case ATTACKUPDATE:
if(updateTime > lastUpdateTime){
lastUpdateTime = updateTime;
switch(message.gettreeState()){
case 0:
setState(AttackTreeState.WINDUP);
frameCurrent = 0;
// System.out.println("Set state STARTUP");
break;
case 1:
frameCurrent = currentMove.getWindupFrames()+1;
setState(AttackTreeState.ATTACK);
// System.out.println("Set state MOVE");
break;
case 2:
frameCurrent = currentMove.getWindupFrames()+currentMove.getAttackFrames()+1;
setState(AttackTreeState.COOLDOWN);
// System.out.println("Set state SLOWDOWN");
break;
case 3:
frameCurrent = 60;
setState(AttackTreeState.IDLE);
// System.out.println("Set state IDLE");
break;
}
}
EntityUtils.getPosition(parent).set(message.getpositionX(),message.getpositionY(),message.getpositionZ());
CreatureUtils.setFacingVector(parent, new Vector3d(message.getrotationX(),message.getrotationY(),message.getrotationZ()));
break;
case STARTATTACK: {
start();
@ -418,6 +389,11 @@ public class ServerAttackTree implements BehaviorTree {
return rVal;
}
/**
* Checks whether the entity can attack or not
* @param attackType The type of attack to perform
* @return true if it can attack, false otherwise
*/
boolean canAttack(String attackType){
boolean rVal = true;
if(attackType == null){
@ -433,7 +409,7 @@ public class ServerAttackTree implements BehaviorTree {
}
} else {
if(ServerEquipState.hasEquipState(parent)){
ServerEquipState equipState = ServerEquipState.getEquipState(parent);
// ServerEquipState equipState = ServerEquipState.getEquipState(parent);
// if(equipState.hasEquipPrimary()){
// switch(attackType){
// case EntityDataStrings.ATTACK_MOVE_TYPE_MELEE_SWING_ONE_HAND:

View File

@ -148,16 +148,7 @@ public class LifeState implements BehaviorTree {
deathFrameCurrent = frameskip;
}
break;
case ATTACHENTITYTOENTITY:
case ATTACKUPDATE:
case CREATE:
case DESTROY:
case SETBEHAVIORTREE:
case SETPOSITION:
case SETPROPERTY:
case MOVE:
case SETFACING:
case MOVEUPDATE:
default:
//silently ignore
break;
}

View File

@ -21,6 +21,7 @@ import electrosphere.renderer.actor.Actor;
import electrosphere.renderer.anim.Animation;
import electrosphere.server.datacell.utils.DataCellSearchUtils;
@Deprecated
public class AirplaneMovementTree implements BehaviorTree {
public static enum AirplaneMovementTreeState {
@ -91,11 +92,6 @@ public class AirplaneMovementTree implements BehaviorTree {
networkMessageQueue.remove(message);
long updateTime = message.gettime();
switch(message.getMessageSubtype()){
case MOVE: {
if(Globals.RUN_CLIENT){
position.set(message.getpositionX(), message.getpositionY(), message.getpositionZ());
}
} break;
//received a message to update the tree
case MOVEUPDATE: {
if(updateTime > lastUpdateTime){
@ -120,15 +116,6 @@ public class AirplaneMovementTree implements BehaviorTree {
//we want to always update the server facing vector with where the client says they're facing
CreatureUtils.setFacingVector(parent, new Vector3d(message.getrotationX(),message.getrotationY(),message.getrotationZ()));
}
} break;
case SETBEHAVIORTREE: {
} break;
case SETFACING: {
} break;
case SETPOSITION: {
} break;
case ATTACHENTITYTOENTITY:
case ATTACKUPDATE:
@ -257,6 +244,7 @@ public class AirplaneMovementTree implements BehaviorTree {
rotation.z,
rotation.w,
velocity,
0,
stateNumber
)
);

View File

@ -68,8 +68,10 @@ public class ClientGroundMovementTree implements BehaviorTree {
}
static final double STATE_DIFFERENCE_HARD_UPDATE_THRESHOLD = 1.0;
static final double STATE_DIFFERENCE_SOFT_UPDATE_THRESHOLD = 0.2;
static final double SOFT_UPDATE_MULTIPLIER = 0.1;
static final double STATE_DIFFERENCE_SOFT_UPDATE_THRESHOLD = 0.1;
static final double SOFT_UPDATE_MULTIPLIER = 0.3;
static final double STATE_DIFFERENCE_CREEP_MULTIPLIER = 0.001; //while the movement tree is idle, slowly creep the position of the entity towards the true server position by this amount
static final double STATE_DIFFERENCE_CREEP_CUTOFF = 0.01; //the cutoff for creep when we say it's "close enough"
String animationStartUp = Animation.ANIMATION_MOVEMENT_STARTUP;
String animationMain = Animation.ANIMATION_MOVEMENT_MOVE;
@ -94,18 +96,32 @@ public class ClientGroundMovementTree implements BehaviorTree {
CopyOnWriteArrayList<EntityMessage> networkMessageQueue = new CopyOnWriteArrayList<EntityMessage>();
//the last frame we got an update on true position from the server
long lastUpdateTime = 0;
//the last position reported by the server
Vector3d lastServerPosition = null;
/**
* Constructor
* @param e The parent entity
*/
private ClientGroundMovementTree(Entity e){
state = MovementTreeState.IDLE;
parent = e;
}
/**
* Gets the state of the tree
* @return The state
*/
public MovementTreeState getState(){
return state;
}
/**
* Requests to the server that the entity start moving
* @param facing The facing relative to the view direction that the entity should move in (ie strafe right vs walk straight forward)
*/
public void start(MovementRelativeFacing facing){
if(canStartMoving()){
setFacing(facing);
@ -126,17 +142,16 @@ public class ClientGroundMovementTree implements BehaviorTree {
rotation.z,
rotation.w,
velocity,
ClientGroundMovementTree.getMovementRelativeFacingEnumAsShort(facing),
0 //magic number corresponding to state startup
)
);
}
}
public void interrupt(){
state = MovementTreeState.IDLE;
CreatureUtils.setVelocity(parent, 0);
}
/**
* Requests to the server that the movetree stop
*/
public void slowdown(){
state = MovementTreeState.SLOWDOWN;
//if we aren't the server, alert the server we intend to slow down
@ -155,11 +170,13 @@ public class ClientGroundMovementTree implements BehaviorTree {
rotation.z,
rotation.w,
velocity,
ClientGroundMovementTree.getMovementRelativeFacingEnumAsShort(facing),
2 //magic number corresponding to state slowdown
)
);
}
@Override
public void simulate(float deltaTime){
float velocity = CreatureUtils.getVelocity(parent);
float acceleration = CreatureUtils.getAcceleration(parent);
@ -214,11 +231,6 @@ public class ClientGroundMovementTree implements BehaviorTree {
long updateTime = message.gettime();
// System.out.println("MOVE to " + message.getX() + " " + message.getY() + " " + message.getZ());
switch(message.getMessageSubtype()){
case MOVE:
position.set(message.getpositionX(), message.getpositionY(), message.getpositionZ());
break;
case SETFACING:
break;
case MOVEUPDATE:
if(updateTime > lastUpdateTime){
lastUpdateTime = updateTime;
@ -243,14 +255,14 @@ public class ClientGroundMovementTree implements BehaviorTree {
// System.out.println("Set state IDLE");
break;
}
// System.out.println(EntityUtils.getEntityPosition(parent));
// System.out.println(message.getpositionX() + " " + message.getpositionY() + " " + message.getpositionZ());
//this should only fire on the client, we don't want the server snap updating due to client position reporting
// if(position.distance(message.getpositionX(),message.getpositionY(),message.getpositionZ()) > STATE_DIFFERENCE_HARD_UPDATE_THRESHOLD){
// EntityUtils.getPosition(parent).set(message.getpositionX(),message.getpositionY(),message.getpositionZ());
// } else if(position.distance(message.getpositionX(),message.getpositionY(),message.getpositionZ()) > STATE_DIFFERENCE_SOFT_UPDATE_THRESHOLD){
// EntityUtils.getPosition(parent).add(new Vector3d(message.getpositionX(),message.getpositionY(),message.getpositionZ()).mul(SOFT_UPDATE_MULTIPLIER));
// }
lastServerPosition = new Vector3d(message.getpositionX(),message.getpositionY(),message.getpositionZ());
if(position.distance(lastServerPosition) > STATE_DIFFERENCE_HARD_UPDATE_THRESHOLD){
System.out.println(position + " - " + lastServerPosition);
EntityUtils.getPosition(parent).set(lastServerPosition);
} else if(position.distance(lastServerPosition) > STATE_DIFFERENCE_SOFT_UPDATE_THRESHOLD){
EntityUtils.getPosition(parent).lerp(lastServerPosition,SOFT_UPDATE_MULTIPLIER);
}
//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());
CollisionObjUtils.clientPositionCharacter(parent, position);
@ -267,7 +279,7 @@ public class ClientGroundMovementTree implements BehaviorTree {
//state machine
switch(state){
case STARTUP:
case STARTUP: {
if(entityActor != null){
String animationToPlay = determineCorrectAnimation();
if(
@ -298,9 +310,8 @@ public class ClientGroundMovementTree implements BehaviorTree {
rotation.set(movementQuaternion);
GravityUtils.clientAttemptActivateGravity(parent);
break;
case MOVE:
} break;
case MOVE: {
//check if can restart animation
//if yes, restart animation
if(entityActor != null){
@ -328,9 +339,8 @@ public class ClientGroundMovementTree implements BehaviorTree {
rotation.set(movementQuaternion);
GravityUtils.clientAttemptActivateGravity(parent);
break;
case SLOWDOWN:
} break;
case SLOWDOWN: {
//run slowdown code
if(entityActor != null){
String animationToPlay = determineCorrectAnimation();
@ -367,10 +377,13 @@ public class ClientGroundMovementTree implements BehaviorTree {
rotation.set(movementQuaternion);
GravityUtils.clientAttemptActivateGravity(parent);
break;
case IDLE:
break;
} break;
case IDLE: {
Vector3d playerPos = EntityUtils.getPosition(parent);
if(lastServerPosition != null && lastServerPosition.distance(playerPos) > STATE_DIFFERENCE_CREEP_CUTOFF){
playerPos.lerp(lastServerPosition,STATE_DIFFERENCE_CREEP_MULTIPLIER);
}
} break;
}
}
@ -695,4 +708,74 @@ public class ClientGroundMovementTree implements BehaviorTree {
return (ClientGroundMovementTree)entity.getData(EntityDataStrings.TREE_CLIENTGROUNDMOVEMENTTREE);
}
/**
* <p>
* Gets the ClientGroundMovementTree of the entity
* </p>
* @param entity the entity
* @return The ClientGroundMovementTree
*/
public static ClientGroundMovementTree getClientGroundMovementTree(Entity entity){
return (ClientGroundMovementTree)entity.getData(EntityDataStrings.TREE_CLIENTGROUNDMOVEMENTTREE);
}
/**
* <p> Automatically generated </p>
* <p>
* Converts this enum type to an equivalent short value
* </p>
* @param enumVal The enum value
* @return The short value
*/
public static short getMovementRelativeFacingEnumAsShort(MovementRelativeFacing enumVal){
switch(enumVal){
case FORWARD:
return 0;
case LEFT:
return 1;
case RIGHT:
return 2;
case BACKWARD:
return 3;
case FORWARD_LEFT:
return 4;
case FORWARD_RIGHT:
return 5;
case BACKWARD_LEFT:
return 6;
case BACKWARD_RIGHT:
return 7;
default:
return 0;
}
}
/**
* <p> Automatically generated </p>
* <p>
* Converts a short to the equivalent enum value
* </p>
* @param shortVal The short value
* @return The enum value
*/
public static MovementRelativeFacing getMovementRelativeFacingShortAsEnum(short shortVal){
switch(shortVal){
case 0:
return MovementRelativeFacing.FORWARD;
case 1:
return MovementRelativeFacing.LEFT;
case 2:
return MovementRelativeFacing.RIGHT;
case 3:
return MovementRelativeFacing.BACKWARD;
case 4:
return MovementRelativeFacing.FORWARD_LEFT;
case 5:
return MovementRelativeFacing.FORWARD_RIGHT;
case 6:
return MovementRelativeFacing.BACKWARD_LEFT;
case 7:
return MovementRelativeFacing.BACKWARD_RIGHT;
default:
return MovementRelativeFacing.FORWARD;
}
}
}

View File

@ -1,6 +1,8 @@
package electrosphere.entity.state.movement.groundmove;
import electrosphere.net.parser.net.message.SynchronizationMessage;
import electrosphere.net.synchronization.BehaviorTreeIdEnums;
import electrosphere.entity.state.gravity.GravityUtils;
@ -41,10 +43,6 @@ Behavior tree for movement in an entity
public class ServerGroundMovementTree implements BehaviorTree {
static final double STATE_DIFFERENCE_HARD_UPDATE_THRESHOLD = 1.0;
static final double STATE_DIFFERENCE_SOFT_UPDATE_THRESHOLD = 0.2;
static final double SOFT_UPDATE_MULTIPLIER = 0.1;
String animationStartUp = Animation.ANIMATION_MOVEMENT_STARTUP;
String animationMain = Animation.ANIMATION_MOVEMENT_MOVE;
String animationSlowDown = Animation.ANIMATION_MOVEMENT_MOVE;
@ -69,7 +67,7 @@ public class ServerGroundMovementTree implements BehaviorTree {
long lastUpdateTime = 0;
public ServerGroundMovementTree(Entity e){
private ServerGroundMovementTree(Entity e){
state = MovementTreeState.IDLE;
facing = MovementRelativeFacing.FORWARD;
parent = e;
@ -103,17 +101,24 @@ public class ServerGroundMovementTree implements BehaviorTree {
rotation.z,
rotation.w,
velocity,
ClientGroundMovementTree.getMovementRelativeFacingEnumAsShort(facing),
0 //magic number corresponding to state startup
)
);
}
}
/**
* Interrupts the tree
*/
public void interrupt(){
state = MovementTreeState.IDLE;
CreatureUtils.setVelocity(parent, 0);
}
/**
* Triggers the move tree to slow down
*/
public void slowdown(){
state = MovementTreeState.SLOWDOWN;
//if we aren't the server, alert the server we intend to slow down
@ -132,11 +137,13 @@ public class ServerGroundMovementTree implements BehaviorTree {
rotation.z,
rotation.w,
velocity,
ClientGroundMovementTree.getMovementRelativeFacingEnumAsShort(facing),
2 //magic number corresponding to state slowdown
)
);
}
@Override
public void simulate(float deltaTime){
float velocity = 0;
float acceleration = 0;
@ -196,17 +203,13 @@ public class ServerGroundMovementTree implements BehaviorTree {
long updateTime = message.gettime();
// System.out.println("MOVE to " + message.getX() + " " + message.getY() + " " + message.getZ());
switch(message.getMessageSubtype()){
case MOVE: {
} break;
case SETFACING:
break;
case MOVEUPDATE: {
if(updateTime >= lastUpdateTime){
lastUpdateTime = updateTime;
switch(message.gettreeState()){
//0 is startup
case 0: {
start(MovementRelativeFacing.FORWARD);
start(ClientGroundMovementTree.getMovementRelativeFacingShortAsEnum((short)message.getpropertyValueInt()));
} break;
case 2: {
slowdown();
@ -229,7 +232,7 @@ public class ServerGroundMovementTree implements BehaviorTree {
//state machine
switch(state){
case STARTUP:
case STARTUP: {
if(entityPoseActor != null){
String animationToPlay = determineCorrectAnimation();
if(
@ -267,22 +270,23 @@ public class ServerGroundMovementTree implements BehaviorTree {
GravityUtils.serverAttemptActivateGravity(parent);
DataCellSearchUtils.getEntityDataCell(parent).broadcastNetworkMessage(
EntityMessage.constructmoveUpdateMessage(
parent.getId(),
Globals.timekeeper.getNumberOfSimFramesElapsed(),
position.x,
position.y,
position.z,
rotation.x,
rotation.y,
rotation.z,
rotation.w,
velocity,
0
)
EntityMessage.constructmoveUpdateMessage(
parent.getId(),
Globals.timekeeper.getNumberOfSimFramesElapsed(),
position.x,
position.y,
position.z,
rotation.x,
rotation.y,
rotation.z,
rotation.w,
velocity,
ClientGroundMovementTree.getMovementRelativeFacingEnumAsShort(facing),
0
)
);
break;
case MOVE:
} break;
case MOVE: {
//check if can restart animation
//if yes, restart animation
if(entityPoseActor != null){
@ -317,22 +321,23 @@ public class ServerGroundMovementTree implements BehaviorTree {
GravityUtils.serverAttemptActivateGravity(parent);
DataCellSearchUtils.getEntityDataCell(parent).broadcastNetworkMessage(
EntityMessage.constructmoveUpdateMessage(
parent.getId(),
Globals.timekeeper.getNumberOfSimFramesElapsed(),
position.x,
position.y,
position.z,
rotation.x,
rotation.y,
rotation.z,
rotation.w,
velocity,
1
)
EntityMessage.constructmoveUpdateMessage(
parent.getId(),
Globals.timekeeper.getNumberOfSimFramesElapsed(),
position.x,
position.y,
position.z,
rotation.x,
rotation.y,
rotation.z,
rotation.w,
velocity,
ClientGroundMovementTree.getMovementRelativeFacingEnumAsShort(facing),
1
)
);
break;
case SLOWDOWN:
} break;
case SLOWDOWN: {
//run slowdown code
if(entityPoseActor != null){
String animationToPlay = determineCorrectAnimation();
@ -376,23 +381,24 @@ public class ServerGroundMovementTree implements BehaviorTree {
GravityUtils.serverAttemptActivateGravity(parent);
DataCellSearchUtils.getEntityDataCell(parent).broadcastNetworkMessage(
EntityMessage.constructmoveUpdateMessage(
parent.getId(),
Globals.timekeeper.getNumberOfSimFramesElapsed(),
position.x,
position.y,
position.z,
rotation.x,
rotation.y,
rotation.z,
rotation.w,
velocity,
2
)
EntityMessage.constructmoveUpdateMessage(
parent.getId(),
Globals.timekeeper.getNumberOfSimFramesElapsed(),
position.x,
position.y,
position.z,
rotation.x,
rotation.y,
rotation.z,
rotation.w,
velocity,
ClientGroundMovementTree.getMovementRelativeFacingEnumAsShort(facing),
2
)
);
break;
case IDLE:
break;
} break;
case IDLE: {
} break;
}
}
@ -668,6 +674,8 @@ public class ServerGroundMovementTree implements BehaviorTree {
*/
public void setFacing(MovementRelativeFacing facing){
this.facing = facing;
int value = ClientGroundMovementTree.getMovementRelativeFacingEnumAsShort(facing);
DataCellSearchUtils.getEntityDataCell(parent).broadcastNetworkMessage(SynchronizationMessage.constructUpdateClientStateMessage(parent.getId(), 9, 11, value));
}
/**

View File

@ -40,6 +40,7 @@ import electrosphere.renderer.actor.ActorUtils;
import electrosphere.server.datacell.Realm;
import electrosphere.server.datacell.utils.ServerBehaviorTreeUtils;
import electrosphere.server.datacell.utils.ServerEntityTagUtils;
import electrosphere.server.poseactor.PoseActor;
/**
* Utilities for working with items
@ -222,6 +223,10 @@ public class ItemUtils {
}
}
/**
* Updates an item to play its idle animation
* @param item THe item entity
*/
public static void updateItemActorAnimation(Entity item){
Actor actor = EntityUtils.getActor(item);
if(actor != null && item.getData(EntityDataStrings.ANIM_IDLE) != null){
@ -232,6 +237,20 @@ public class ItemUtils {
}
}
/**
* Updates the item's pose actor to play its idle animation on the server
* @param item The item entity
*/
public static void updateItemPoseActorAnimation(Entity item){
PoseActor actor = EntityUtils.getPoseActor(item);
if(actor != null && item.getData(EntityDataStrings.ANIM_IDLE) != null){
String idleAnim = (String)item.getData(EntityDataStrings.ANIM_IDLE);
if(!actor.isPlayingAnimation(idleAnim)){
actor.playAnimation(idleAnim,1);
}
}
}
public static void sendEntityToPlayer(Player player, Entity item){
int id = item.getId();
String type = ItemUtils.getType(item);

View File

@ -11,7 +11,6 @@ import electrosphere.entity.EntityDataStrings;
import electrosphere.entity.EntityTags;
import electrosphere.entity.EntityUtils;
import electrosphere.entity.state.attack.ClientAttackTree;
import electrosphere.entity.state.attack.ServerAttackTree;
import electrosphere.entity.state.client.firstPerson.FirstPersonTree;
import electrosphere.entity.types.attach.AttachUtils;
import electrosphere.entity.types.creature.CreatureTemplate;
@ -96,13 +95,6 @@ public class EntityProtocol {
// UPDATING PROPERTIES
//
//
case MOVE: {
Entity target = Globals.clientSceneWrapper.getEntityFromServerId(message.getentityID());
LoggerInterface.loggerNetworking.DEBUG("ID: " + message.getentityID());
if(target != null){
EntityUtils.getPosition(target).set(message.getpositionX(),message.getpositionY(),message.getpositionZ());
}
} break;
case SETPROPERTY: {
if(Globals.clientSceneWrapper.serverToClientMapContainsId(message.getentityID())){
if(message.getpropertyType() == 0){
@ -145,17 +137,9 @@ public class EntityProtocol {
//
case UPDATEENTITYVIEWDIR:
case KILL:
case SETPOSITION:
case SETFACING:
//to be implemented
throw new UnsupportedOperationException();
case SETBEHAVIORTREE:
case SETBTREEPROPERTYDOUBLE:
case SETBTREEPROPERTYENUM:
case SETBTREEPROPERTYFLOAT:
case SETBTREEPROPERTYINT:
case SETBTREEPROPERTYSTRING:
default:
//unused
break;
}

View File

@ -11,18 +11,11 @@ public class LoreProtocol {
protected static void handleLoreMessage(LoreMessage message){
switch(message.getMessageSubtype()){
case RESPONSEDATA:
break;
case RESPONSERACES:
//we get back the race list as a json array, deserialize, and push into type loader
List<String> playableRaces = new Gson().fromJson(message.getdata(), List.class);
Globals.gameConfigCurrent.getCreatureTypeLoader().loadPlayableRaces(playableRaces);
break;
case RESPONSERACEDATA:
break;
case REQUESTDATA:
case REQUESTRACEDATA:
case REQUESTRACES:
//silently ignore
break;

View File

@ -11,21 +11,12 @@ public class EntityMessage extends NetworkMessage {
CREATE,
SPAWNCREATURE,
SPAWNITEM,
SETPOSITION,
SETFACING,
MOVEUPDATE,
ATTACKUPDATE,
STARTATTACK,
MOVE,
KILL,
DESTROY,
SETBEHAVIORTREE,
SETPROPERTY,
SETBTREEPROPERTYINT,
SETBTREEPROPERTYFLOAT,
SETBTREEPROPERTYDOUBLE,
SETBTREEPROPERTYSTRING,
SETBTREEPROPERTYENUM,
ATTACHENTITYTOENTITY,
SPAWNFOLIAGESEED,
UPDATEENTITYVIEWDIR,
@ -297,18 +288,6 @@ public class EntityMessage extends NetworkMessage {
return EntityMessage.canParseSpawnCreatureMessage(byteBuffer);
case TypeBytes.ENTITY_MESSAGE_TYPE_SPAWNITEM:
return EntityMessage.canParseSpawnItemMessage(byteBuffer);
case TypeBytes.ENTITY_MESSAGE_TYPE_SETPOSITION:
if(byteBuffer.getRemaining() >= TypeBytes.ENTITY_MESSAGE_TYPE_SETPOSITION_SIZE){
return true;
} else {
return false;
}
case TypeBytes.ENTITY_MESSAGE_TYPE_SETFACING:
if(byteBuffer.getRemaining() >= TypeBytes.ENTITY_MESSAGE_TYPE_SETFACING_SIZE){
return true;
} else {
return false;
}
case TypeBytes.ENTITY_MESSAGE_TYPE_MOVEUPDATE:
if(byteBuffer.getRemaining() >= TypeBytes.ENTITY_MESSAGE_TYPE_MOVEUPDATE_SIZE){
return true;
@ -327,12 +306,6 @@ public class EntityMessage extends NetworkMessage {
} else {
return false;
}
case TypeBytes.ENTITY_MESSAGE_TYPE_MOVE:
if(byteBuffer.getRemaining() >= TypeBytes.ENTITY_MESSAGE_TYPE_MOVE_SIZE){
return true;
} else {
return false;
}
case TypeBytes.ENTITY_MESSAGE_TYPE_KILL:
if(byteBuffer.getRemaining() >= TypeBytes.ENTITY_MESSAGE_TYPE_KILL_SIZE){
return true;
@ -345,44 +318,12 @@ public class EntityMessage extends NetworkMessage {
} else {
return false;
}
case TypeBytes.ENTITY_MESSAGE_TYPE_SETBEHAVIORTREE:
if(byteBuffer.getRemaining() >= TypeBytes.ENTITY_MESSAGE_TYPE_SETBEHAVIORTREE_SIZE){
return true;
} else {
return false;
}
case TypeBytes.ENTITY_MESSAGE_TYPE_SETPROPERTY:
if(byteBuffer.getRemaining() >= TypeBytes.ENTITY_MESSAGE_TYPE_SETPROPERTY_SIZE){
return true;
} else {
return false;
}
case TypeBytes.ENTITY_MESSAGE_TYPE_SETBTREEPROPERTYINT:
if(byteBuffer.getRemaining() >= TypeBytes.ENTITY_MESSAGE_TYPE_SETBTREEPROPERTYINT_SIZE){
return true;
} else {
return false;
}
case TypeBytes.ENTITY_MESSAGE_TYPE_SETBTREEPROPERTYFLOAT:
if(byteBuffer.getRemaining() >= TypeBytes.ENTITY_MESSAGE_TYPE_SETBTREEPROPERTYFLOAT_SIZE){
return true;
} else {
return false;
}
case TypeBytes.ENTITY_MESSAGE_TYPE_SETBTREEPROPERTYDOUBLE:
if(byteBuffer.getRemaining() >= TypeBytes.ENTITY_MESSAGE_TYPE_SETBTREEPROPERTYDOUBLE_SIZE){
return true;
} else {
return false;
}
case TypeBytes.ENTITY_MESSAGE_TYPE_SETBTREEPROPERTYSTRING:
return EntityMessage.canParsesetBTreePropertyStringMessage(byteBuffer);
case TypeBytes.ENTITY_MESSAGE_TYPE_SETBTREEPROPERTYENUM:
if(byteBuffer.getRemaining() >= TypeBytes.ENTITY_MESSAGE_TYPE_SETBTREEPROPERTYENUM_SIZE){
return true;
} else {
return false;
}
case TypeBytes.ENTITY_MESSAGE_TYPE_ATTACHENTITYTOENTITY:
return EntityMessage.canParseattachEntityToEntityMessage(byteBuffer);
case TypeBytes.ENTITY_MESSAGE_TYPE_SPAWNFOLIAGESEED:
@ -561,50 +502,6 @@ public class EntityMessage extends NetworkMessage {
return rVal;
}
public static EntityMessage parseSetPositionMessage(CircularByteBuffer byteBuffer){
EntityMessage rVal = new EntityMessage(EntityMessageType.SETPOSITION);
stripPacketHeader(byteBuffer);
rVal.setentityID(ByteStreamUtils.popIntFromByteQueue(byteBuffer));
rVal.settime(ByteStreamUtils.popLongFromByteQueue(byteBuffer));
rVal.setpositionX(ByteStreamUtils.popDoubleFromByteQueue(byteBuffer));
rVal.setpositionY(ByteStreamUtils.popDoubleFromByteQueue(byteBuffer));
rVal.setpositionZ(ByteStreamUtils.popDoubleFromByteQueue(byteBuffer));
return rVal;
}
public static EntityMessage constructSetPositionMessage(int entityID,long time,double positionX,double positionY,double positionZ){
EntityMessage rVal = new EntityMessage(EntityMessageType.SETPOSITION);
rVal.setentityID(entityID);
rVal.settime(time);
rVal.setpositionX(positionX);
rVal.setpositionY(positionY);
rVal.setpositionZ(positionZ);
rVal.serialize();
return rVal;
}
public static EntityMessage parsesetFacingMessage(CircularByteBuffer byteBuffer){
EntityMessage rVal = new EntityMessage(EntityMessageType.SETFACING);
stripPacketHeader(byteBuffer);
rVal.setentityID(ByteStreamUtils.popIntFromByteQueue(byteBuffer));
rVal.settime(ByteStreamUtils.popLongFromByteQueue(byteBuffer));
rVal.setrotationX(ByteStreamUtils.popDoubleFromByteQueue(byteBuffer));
rVal.setrotationY(ByteStreamUtils.popDoubleFromByteQueue(byteBuffer));
rVal.setrotationZ(ByteStreamUtils.popDoubleFromByteQueue(byteBuffer));
return rVal;
}
public static EntityMessage constructsetFacingMessage(int entityID,long time,double rotationX,double rotationY,double rotationZ){
EntityMessage rVal = new EntityMessage(EntityMessageType.SETFACING);
rVal.setentityID(entityID);
rVal.settime(time);
rVal.setrotationX(rotationX);
rVal.setrotationY(rotationY);
rVal.setrotationZ(rotationZ);
rVal.serialize();
return rVal;
}
public static EntityMessage parsemoveUpdateMessage(CircularByteBuffer byteBuffer){
EntityMessage rVal = new EntityMessage(EntityMessageType.MOVEUPDATE);
stripPacketHeader(byteBuffer);
@ -618,11 +515,12 @@ public class EntityMessage extends NetworkMessage {
rVal.setrotationZ(ByteStreamUtils.popDoubleFromByteQueue(byteBuffer));
rVal.setrotationW(ByteStreamUtils.popDoubleFromByteQueue(byteBuffer));
rVal.setvelocity(ByteStreamUtils.popDoubleFromByteQueue(byteBuffer));
rVal.setpropertyValueInt(ByteStreamUtils.popIntFromByteQueue(byteBuffer));
rVal.settreeState(ByteStreamUtils.popIntFromByteQueue(byteBuffer));
return rVal;
}
public static EntityMessage constructmoveUpdateMessage(int entityID,long time,double positionX,double positionY,double positionZ,double rotationX,double rotationY,double rotationZ,double rotationW,double velocity,int treeState){
public static EntityMessage constructmoveUpdateMessage(int entityID,long time,double positionX,double positionY,double positionZ,double rotationX,double rotationY,double rotationZ,double rotationW,double velocity,int propertyValueInt,int treeState){
EntityMessage rVal = new EntityMessage(EntityMessageType.MOVEUPDATE);
rVal.setentityID(entityID);
rVal.settime(time);
@ -634,6 +532,7 @@ public class EntityMessage extends NetworkMessage {
rVal.setrotationZ(rotationZ);
rVal.setrotationW(rotationW);
rVal.setvelocity(velocity);
rVal.setpropertyValueInt(propertyValueInt);
rVal.settreeState(treeState);
rVal.serialize();
return rVal;
@ -683,28 +582,6 @@ public class EntityMessage extends NetworkMessage {
return rVal;
}
public static EntityMessage parseMoveMessage(CircularByteBuffer byteBuffer){
EntityMessage rVal = new EntityMessage(EntityMessageType.MOVE);
stripPacketHeader(byteBuffer);
rVal.setentityID(ByteStreamUtils.popIntFromByteQueue(byteBuffer));
rVal.settime(ByteStreamUtils.popLongFromByteQueue(byteBuffer));
rVal.setpositionX(ByteStreamUtils.popDoubleFromByteQueue(byteBuffer));
rVal.setpositionY(ByteStreamUtils.popDoubleFromByteQueue(byteBuffer));
rVal.setpositionZ(ByteStreamUtils.popDoubleFromByteQueue(byteBuffer));
return rVal;
}
public static EntityMessage constructMoveMessage(int entityID,long time,double positionX,double positionY,double positionZ){
EntityMessage rVal = new EntityMessage(EntityMessageType.MOVE);
rVal.setentityID(entityID);
rVal.settime(time);
rVal.setpositionX(positionX);
rVal.setpositionY(positionY);
rVal.setpositionZ(positionZ);
rVal.serialize();
return rVal;
}
public static EntityMessage parseKillMessage(CircularByteBuffer byteBuffer){
EntityMessage rVal = new EntityMessage(EntityMessageType.KILL);
stripPacketHeader(byteBuffer);
@ -735,26 +612,6 @@ public class EntityMessage extends NetworkMessage {
return rVal;
}
public static EntityMessage parseSetBehaviorTreeMessage(CircularByteBuffer byteBuffer){
EntityMessage rVal = new EntityMessage(EntityMessageType.SETBEHAVIORTREE);
stripPacketHeader(byteBuffer);
rVal.setentityID(ByteStreamUtils.popIntFromByteQueue(byteBuffer));
rVal.settime(ByteStreamUtils.popLongFromByteQueue(byteBuffer));
rVal.settreeType(ByteStreamUtils.popIntFromByteQueue(byteBuffer));
rVal.settreeStatus(ByteStreamUtils.popIntFromByteQueue(byteBuffer));
return rVal;
}
public static EntityMessage constructSetBehaviorTreeMessage(int entityID,long time,int treeType,int treeStatus){
EntityMessage rVal = new EntityMessage(EntityMessageType.SETBEHAVIORTREE);
rVal.setentityID(entityID);
rVal.settime(time);
rVal.settreeType(treeType);
rVal.settreeStatus(treeStatus);
rVal.serialize();
return rVal;
}
public static EntityMessage parsesetPropertyMessage(CircularByteBuffer byteBuffer){
EntityMessage rVal = new EntityMessage(EntityMessageType.SETPROPERTY);
stripPacketHeader(byteBuffer);
@ -775,147 +632,6 @@ public class EntityMessage extends NetworkMessage {
return rVal;
}
public static EntityMessage parsesetBTreePropertyIntMessage(CircularByteBuffer byteBuffer){
EntityMessage rVal = new EntityMessage(EntityMessageType.SETBTREEPROPERTYINT);
stripPacketHeader(byteBuffer);
rVal.setentityID(ByteStreamUtils.popIntFromByteQueue(byteBuffer));
rVal.settime(ByteStreamUtils.popLongFromByteQueue(byteBuffer));
rVal.setbTreeID(ByteStreamUtils.popIntFromByteQueue(byteBuffer));
rVal.setpropertyID(ByteStreamUtils.popIntFromByteQueue(byteBuffer));
rVal.setpropertyValueInt(ByteStreamUtils.popIntFromByteQueue(byteBuffer));
return rVal;
}
public static EntityMessage constructsetBTreePropertyIntMessage(int entityID,long time,int bTreeID,int propertyID,int propertyValueInt){
EntityMessage rVal = new EntityMessage(EntityMessageType.SETBTREEPROPERTYINT);
rVal.setentityID(entityID);
rVal.settime(time);
rVal.setbTreeID(bTreeID);
rVal.setpropertyID(propertyID);
rVal.setpropertyValueInt(propertyValueInt);
rVal.serialize();
return rVal;
}
public static EntityMessage parsesetBTreePropertyFloatMessage(CircularByteBuffer byteBuffer){
EntityMessage rVal = new EntityMessage(EntityMessageType.SETBTREEPROPERTYFLOAT);
stripPacketHeader(byteBuffer);
rVal.setentityID(ByteStreamUtils.popIntFromByteQueue(byteBuffer));
rVal.settime(ByteStreamUtils.popLongFromByteQueue(byteBuffer));
rVal.setbTreeID(ByteStreamUtils.popIntFromByteQueue(byteBuffer));
rVal.setpropertyID(ByteStreamUtils.popIntFromByteQueue(byteBuffer));
rVal.setpropertyValueFloat(ByteStreamUtils.popFloatFromByteQueue(byteBuffer));
return rVal;
}
public static EntityMessage constructsetBTreePropertyFloatMessage(int entityID,long time,int bTreeID,int propertyID,float propertyValueFloat){
EntityMessage rVal = new EntityMessage(EntityMessageType.SETBTREEPROPERTYFLOAT);
rVal.setentityID(entityID);
rVal.settime(time);
rVal.setbTreeID(bTreeID);
rVal.setpropertyID(propertyID);
rVal.setpropertyValueFloat(propertyValueFloat);
rVal.serialize();
return rVal;
}
public static EntityMessage parsesetBTreePropertyDoubleMessage(CircularByteBuffer byteBuffer){
EntityMessage rVal = new EntityMessage(EntityMessageType.SETBTREEPROPERTYDOUBLE);
stripPacketHeader(byteBuffer);
rVal.setentityID(ByteStreamUtils.popIntFromByteQueue(byteBuffer));
rVal.settime(ByteStreamUtils.popLongFromByteQueue(byteBuffer));
rVal.setbTreeID(ByteStreamUtils.popIntFromByteQueue(byteBuffer));
rVal.setpropertyID(ByteStreamUtils.popIntFromByteQueue(byteBuffer));
rVal.setpropertyValueDouble(ByteStreamUtils.popDoubleFromByteQueue(byteBuffer));
return rVal;
}
public static EntityMessage constructsetBTreePropertyDoubleMessage(int entityID,long time,int bTreeID,int propertyID,double propertyValueDouble){
EntityMessage rVal = new EntityMessage(EntityMessageType.SETBTREEPROPERTYDOUBLE);
rVal.setentityID(entityID);
rVal.settime(time);
rVal.setbTreeID(bTreeID);
rVal.setpropertyID(propertyID);
rVal.setpropertyValueDouble(propertyValueDouble);
rVal.serialize();
return rVal;
}
public static boolean canParsesetBTreePropertyStringMessage(CircularByteBuffer byteBuffer){
int currentStreamLength = byteBuffer.getRemaining();
List<Byte> temporaryByteQueue = new LinkedList();
if(currentStreamLength < 6){
return false;
}
if(currentStreamLength < 14){
return false;
}
if(currentStreamLength < 18){
return false;
}
if(currentStreamLength < 22){
return false;
}
int propertyValueStringSize = 0;
if(currentStreamLength < 26){
return false;
} else {
temporaryByteQueue.add(byteBuffer.peek(22 + 0));
temporaryByteQueue.add(byteBuffer.peek(22 + 1));
temporaryByteQueue.add(byteBuffer.peek(22 + 2));
temporaryByteQueue.add(byteBuffer.peek(22 + 3));
propertyValueStringSize = ByteStreamUtils.popIntFromByteQueue(temporaryByteQueue);
}
if(currentStreamLength < 26 + propertyValueStringSize){
return false;
}
return true;
}
public static EntityMessage parsesetBTreePropertyStringMessage(CircularByteBuffer byteBuffer){
EntityMessage rVal = new EntityMessage(EntityMessageType.SETBTREEPROPERTYSTRING);
stripPacketHeader(byteBuffer);
rVal.setentityID(ByteStreamUtils.popIntFromByteQueue(byteBuffer));
rVal.settime(ByteStreamUtils.popLongFromByteQueue(byteBuffer));
rVal.setbTreeID(ByteStreamUtils.popIntFromByteQueue(byteBuffer));
rVal.setpropertyID(ByteStreamUtils.popIntFromByteQueue(byteBuffer));
rVal.setpropertyValueString(ByteStreamUtils.popStringFromByteQueue(byteBuffer));
return rVal;
}
public static EntityMessage constructsetBTreePropertyStringMessage(int entityID,long time,int bTreeID,int propertyID,String propertyValueString){
EntityMessage rVal = new EntityMessage(EntityMessageType.SETBTREEPROPERTYSTRING);
rVal.setentityID(entityID);
rVal.settime(time);
rVal.setbTreeID(bTreeID);
rVal.setpropertyID(propertyID);
rVal.setpropertyValueString(propertyValueString);
rVal.serialize();
return rVal;
}
public static EntityMessage parsesetBTreePropertyEnumMessage(CircularByteBuffer byteBuffer){
EntityMessage rVal = new EntityMessage(EntityMessageType.SETBTREEPROPERTYENUM);
stripPacketHeader(byteBuffer);
rVal.setentityID(ByteStreamUtils.popIntFromByteQueue(byteBuffer));
rVal.settime(ByteStreamUtils.popLongFromByteQueue(byteBuffer));
rVal.setbTreeID(ByteStreamUtils.popIntFromByteQueue(byteBuffer));
rVal.setpropertyID(ByteStreamUtils.popIntFromByteQueue(byteBuffer));
rVal.setpropertyValueInt(ByteStreamUtils.popIntFromByteQueue(byteBuffer));
return rVal;
}
public static EntityMessage constructsetBTreePropertyEnumMessage(int entityID,long time,int bTreeID,int propertyID,int propertyValueInt){
EntityMessage rVal = new EntityMessage(EntityMessageType.SETBTREEPROPERTYENUM);
rVal.setentityID(entityID);
rVal.settime(time);
rVal.setbTreeID(bTreeID);
rVal.setpropertyID(propertyID);
rVal.setpropertyValueInt(propertyValueInt);
rVal.serialize();
return rVal;
}
public static boolean canParseattachEntityToEntityMessage(CircularByteBuffer byteBuffer){
int currentStreamLength = byteBuffer.getRemaining();
List<Byte> temporaryByteQueue = new LinkedList();
@ -1141,62 +857,8 @@ public class EntityMessage extends NetworkMessage {
rawBytes[26+creatureTemplate.length()+i] = intValues[i];
}
break;
case SETPOSITION:
rawBytes = new byte[2+4+8+8+8+8];
//message header
rawBytes[0] = TypeBytes.MESSAGE_TYPE_ENTITY;
//entity messaage header
rawBytes[1] = TypeBytes.ENTITY_MESSAGE_TYPE_SETPOSITION;
intValues = ByteStreamUtils.serializeIntToBytes(entityID);
for(int i = 0; i < 4; i++){
rawBytes[2+i] = intValues[i];
}
intValues = ByteStreamUtils.serializeLongToBytes(time);
for(int i = 0; i < 8; i++){
rawBytes[6+i] = intValues[i];
}
intValues = ByteStreamUtils.serializeDoubleToBytes(positionX);
for(int i = 0; i < 8; i++){
rawBytes[14+i] = intValues[i];
}
intValues = ByteStreamUtils.serializeDoubleToBytes(positionY);
for(int i = 0; i < 8; i++){
rawBytes[22+i] = intValues[i];
}
intValues = ByteStreamUtils.serializeDoubleToBytes(positionZ);
for(int i = 0; i < 8; i++){
rawBytes[30+i] = intValues[i];
}
break;
case SETFACING:
rawBytes = new byte[2+4+8+8+8+8];
//message header
rawBytes[0] = TypeBytes.MESSAGE_TYPE_ENTITY;
//entity messaage header
rawBytes[1] = TypeBytes.ENTITY_MESSAGE_TYPE_SETFACING;
intValues = ByteStreamUtils.serializeIntToBytes(entityID);
for(int i = 0; i < 4; i++){
rawBytes[2+i] = intValues[i];
}
intValues = ByteStreamUtils.serializeLongToBytes(time);
for(int i = 0; i < 8; i++){
rawBytes[6+i] = intValues[i];
}
intValues = ByteStreamUtils.serializeDoubleToBytes(rotationX);
for(int i = 0; i < 8; i++){
rawBytes[14+i] = intValues[i];
}
intValues = ByteStreamUtils.serializeDoubleToBytes(rotationY);
for(int i = 0; i < 8; i++){
rawBytes[22+i] = intValues[i];
}
intValues = ByteStreamUtils.serializeDoubleToBytes(rotationZ);
for(int i = 0; i < 8; i++){
rawBytes[30+i] = intValues[i];
}
break;
case MOVEUPDATE:
rawBytes = new byte[2+4+8+8+8+8+8+8+8+8+8+4];
rawBytes = new byte[2+4+8+8+8+8+8+8+8+8+8+4+4];
//message header
rawBytes[0] = TypeBytes.MESSAGE_TYPE_ENTITY;
//entity messaage header
@ -1241,10 +903,14 @@ public class EntityMessage extends NetworkMessage {
for(int i = 0; i < 8; i++){
rawBytes[70+i] = intValues[i];
}
intValues = ByteStreamUtils.serializeIntToBytes(treeState);
intValues = ByteStreamUtils.serializeIntToBytes(propertyValueInt);
for(int i = 0; i < 4; i++){
rawBytes[78+i] = intValues[i];
}
intValues = ByteStreamUtils.serializeIntToBytes(treeState);
for(int i = 0; i < 4; i++){
rawBytes[82+i] = intValues[i];
}
break;
case ATTACKUPDATE:
rawBytes = new byte[2+4+8+8+8+8+8+8+8+8+4];
@ -1300,33 +966,6 @@ public class EntityMessage extends NetworkMessage {
//entity messaage header
rawBytes[1] = TypeBytes.ENTITY_MESSAGE_TYPE_STARTATTACK;
break;
case MOVE:
rawBytes = new byte[2+4+8+8+8+8];
//message header
rawBytes[0] = TypeBytes.MESSAGE_TYPE_ENTITY;
//entity messaage header
rawBytes[1] = TypeBytes.ENTITY_MESSAGE_TYPE_MOVE;
intValues = ByteStreamUtils.serializeIntToBytes(entityID);
for(int i = 0; i < 4; i++){
rawBytes[2+i] = intValues[i];
}
intValues = ByteStreamUtils.serializeLongToBytes(time);
for(int i = 0; i < 8; i++){
rawBytes[6+i] = intValues[i];
}
intValues = ByteStreamUtils.serializeDoubleToBytes(positionX);
for(int i = 0; i < 8; i++){
rawBytes[14+i] = intValues[i];
}
intValues = ByteStreamUtils.serializeDoubleToBytes(positionY);
for(int i = 0; i < 8; i++){
rawBytes[22+i] = intValues[i];
}
intValues = ByteStreamUtils.serializeDoubleToBytes(positionZ);
for(int i = 0; i < 8; i++){
rawBytes[30+i] = intValues[i];
}
break;
case KILL:
rawBytes = new byte[2+8+4];
//message header
@ -1353,29 +992,6 @@ public class EntityMessage extends NetworkMessage {
rawBytes[2+i] = intValues[i];
}
break;
case SETBEHAVIORTREE:
rawBytes = new byte[2+4+8+4+4];
//message header
rawBytes[0] = TypeBytes.MESSAGE_TYPE_ENTITY;
//entity messaage header
rawBytes[1] = TypeBytes.ENTITY_MESSAGE_TYPE_SETBEHAVIORTREE;
intValues = ByteStreamUtils.serializeIntToBytes(entityID);
for(int i = 0; i < 4; i++){
rawBytes[2+i] = intValues[i];
}
intValues = ByteStreamUtils.serializeLongToBytes(time);
for(int i = 0; i < 8; i++){
rawBytes[6+i] = intValues[i];
}
intValues = ByteStreamUtils.serializeIntToBytes(treeType);
for(int i = 0; i < 4; i++){
rawBytes[14+i] = intValues[i];
}
intValues = ByteStreamUtils.serializeIntToBytes(treeStatus);
for(int i = 0; i < 4; i++){
rawBytes[18+i] = intValues[i];
}
break;
case SETPROPERTY:
rawBytes = new byte[2+4+8+4+4];
//message header
@ -1399,144 +1015,6 @@ public class EntityMessage extends NetworkMessage {
rawBytes[18+i] = intValues[i];
}
break;
case SETBTREEPROPERTYINT:
rawBytes = new byte[2+4+8+4+4+4];
//message header
rawBytes[0] = TypeBytes.MESSAGE_TYPE_ENTITY;
//entity messaage header
rawBytes[1] = TypeBytes.ENTITY_MESSAGE_TYPE_SETBTREEPROPERTYINT;
intValues = ByteStreamUtils.serializeIntToBytes(entityID);
for(int i = 0; i < 4; i++){
rawBytes[2+i] = intValues[i];
}
intValues = ByteStreamUtils.serializeLongToBytes(time);
for(int i = 0; i < 8; i++){
rawBytes[6+i] = intValues[i];
}
intValues = ByteStreamUtils.serializeIntToBytes(bTreeID);
for(int i = 0; i < 4; i++){
rawBytes[14+i] = intValues[i];
}
intValues = ByteStreamUtils.serializeIntToBytes(propertyID);
for(int i = 0; i < 4; i++){
rawBytes[18+i] = intValues[i];
}
intValues = ByteStreamUtils.serializeIntToBytes(propertyValueInt);
for(int i = 0; i < 4; i++){
rawBytes[22+i] = intValues[i];
}
break;
case SETBTREEPROPERTYFLOAT:
rawBytes = new byte[2+4+8+4+4+4];
//message header
rawBytes[0] = TypeBytes.MESSAGE_TYPE_ENTITY;
//entity messaage header
rawBytes[1] = TypeBytes.ENTITY_MESSAGE_TYPE_SETBTREEPROPERTYFLOAT;
intValues = ByteStreamUtils.serializeIntToBytes(entityID);
for(int i = 0; i < 4; i++){
rawBytes[2+i] = intValues[i];
}
intValues = ByteStreamUtils.serializeLongToBytes(time);
for(int i = 0; i < 8; i++){
rawBytes[6+i] = intValues[i];
}
intValues = ByteStreamUtils.serializeIntToBytes(bTreeID);
for(int i = 0; i < 4; i++){
rawBytes[14+i] = intValues[i];
}
intValues = ByteStreamUtils.serializeIntToBytes(propertyID);
for(int i = 0; i < 4; i++){
rawBytes[18+i] = intValues[i];
}
intValues = ByteStreamUtils.serializeFloatToBytes(propertyValueFloat);
for(int i = 0; i < 4; i++){
rawBytes[22+i] = intValues[i];
} break;
case SETBTREEPROPERTYDOUBLE:
rawBytes = new byte[2+4+8+4+4+8];
//message header
rawBytes[0] = TypeBytes.MESSAGE_TYPE_ENTITY;
//entity messaage header
rawBytes[1] = TypeBytes.ENTITY_MESSAGE_TYPE_SETBTREEPROPERTYDOUBLE;
intValues = ByteStreamUtils.serializeIntToBytes(entityID);
for(int i = 0; i < 4; i++){
rawBytes[2+i] = intValues[i];
}
intValues = ByteStreamUtils.serializeLongToBytes(time);
for(int i = 0; i < 8; i++){
rawBytes[6+i] = intValues[i];
}
intValues = ByteStreamUtils.serializeIntToBytes(bTreeID);
for(int i = 0; i < 4; i++){
rawBytes[14+i] = intValues[i];
}
intValues = ByteStreamUtils.serializeIntToBytes(propertyID);
for(int i = 0; i < 4; i++){
rawBytes[18+i] = intValues[i];
}
intValues = ByteStreamUtils.serializeDoubleToBytes(propertyValueDouble);
for(int i = 0; i < 8; i++){
rawBytes[22+i] = intValues[i];
}
break;
case SETBTREEPROPERTYSTRING:
rawBytes = new byte[2+4+8+4+4+4+propertyValueString.length()];
//message header
rawBytes[0] = TypeBytes.MESSAGE_TYPE_ENTITY;
//entity messaage header
rawBytes[1] = TypeBytes.ENTITY_MESSAGE_TYPE_SETBTREEPROPERTYSTRING;
intValues = ByteStreamUtils.serializeIntToBytes(entityID);
for(int i = 0; i < 4; i++){
rawBytes[2+i] = intValues[i];
}
intValues = ByteStreamUtils.serializeLongToBytes(time);
for(int i = 0; i < 8; i++){
rawBytes[6+i] = intValues[i];
}
intValues = ByteStreamUtils.serializeIntToBytes(bTreeID);
for(int i = 0; i < 4; i++){
rawBytes[14+i] = intValues[i];
}
intValues = ByteStreamUtils.serializeIntToBytes(propertyID);
for(int i = 0; i < 4; i++){
rawBytes[18+i] = intValues[i];
}
intValues = ByteStreamUtils.serializeIntToBytes(propertyValueString.length());
for(int i = 0; i < 4; i++){
rawBytes[22+i] = intValues[i];
}
stringBytes = propertyValueString.getBytes();
for(int i = 0; i < propertyValueString.length(); i++){
rawBytes[26+i] = stringBytes[i];
}
break;
case SETBTREEPROPERTYENUM:
rawBytes = new byte[2+4+8+4+4+4];
//message header
rawBytes[0] = TypeBytes.MESSAGE_TYPE_ENTITY;
//entity messaage header
rawBytes[1] = TypeBytes.ENTITY_MESSAGE_TYPE_SETBTREEPROPERTYENUM;
intValues = ByteStreamUtils.serializeIntToBytes(entityID);
for(int i = 0; i < 4; i++){
rawBytes[2+i] = intValues[i];
}
intValues = ByteStreamUtils.serializeLongToBytes(time);
for(int i = 0; i < 8; i++){
rawBytes[6+i] = intValues[i];
}
intValues = ByteStreamUtils.serializeIntToBytes(bTreeID);
for(int i = 0; i < 4; i++){
rawBytes[14+i] = intValues[i];
}
intValues = ByteStreamUtils.serializeIntToBytes(propertyID);
for(int i = 0; i < 4; i++){
rawBytes[18+i] = intValues[i];
}
intValues = ByteStreamUtils.serializeIntToBytes(propertyValueInt);
for(int i = 0; i < 4; i++){
rawBytes[22+i] = intValues[i];
}
break;
case ATTACHENTITYTOENTITY:
rawBytes = new byte[2+4+4+bone.length()+4];
//message header

View File

@ -10,10 +10,6 @@ public class LoreMessage extends NetworkMessage {
public enum LoreMessageType {
REQUESTRACES,
RESPONSERACES,
REQUESTRACEDATA,
RESPONSERACEDATA,
REQUESTDATA,
RESPONSEDATA,
}
LoreMessageType messageType;
@ -50,18 +46,6 @@ public class LoreMessage extends NetworkMessage {
}
case TypeBytes.LORE_MESSAGE_TYPE_RESPONSERACES:
return LoreMessage.canParseResponseRacesMessage(byteBuffer);
case TypeBytes.LORE_MESSAGE_TYPE_REQUESTRACEDATA:
if(byteBuffer.getRemaining() >= TypeBytes.LORE_MESSAGE_TYPE_REQUESTRACEDATA_SIZE){
return true;
} else {
return false;
}
case TypeBytes.LORE_MESSAGE_TYPE_RESPONSERACEDATA:
return LoreMessage.canParseResponseRaceDataMessage(byteBuffer);
case TypeBytes.LORE_MESSAGE_TYPE_REQUESTDATA:
return LoreMessage.canParseRequestDataMessage(byteBuffer);
case TypeBytes.LORE_MESSAGE_TYPE_RESPONSEDATA:
return LoreMessage.canParseResponseDataMessage(byteBuffer);
}
return false;
}
@ -111,117 +95,6 @@ public class LoreMessage extends NetworkMessage {
return rVal;
}
public static LoreMessage parseRequestRaceDataMessage(CircularByteBuffer byteBuffer){
LoreMessage rVal = new LoreMessage(LoreMessageType.REQUESTRACEDATA);
stripPacketHeader(byteBuffer);
return rVal;
}
public static LoreMessage constructRequestRaceDataMessage(){
LoreMessage rVal = new LoreMessage(LoreMessageType.REQUESTRACEDATA);
rVal.serialize();
return rVal;
}
public static boolean canParseResponseRaceDataMessage(CircularByteBuffer byteBuffer){
int currentStreamLength = byteBuffer.getRemaining();
List<Byte> temporaryByteQueue = new LinkedList();
int dataSize = 0;
if(currentStreamLength < 6){
return false;
} else {
temporaryByteQueue.add(byteBuffer.peek(2 + 0));
temporaryByteQueue.add(byteBuffer.peek(2 + 1));
temporaryByteQueue.add(byteBuffer.peek(2 + 2));
temporaryByteQueue.add(byteBuffer.peek(2 + 3));
dataSize = ByteStreamUtils.popIntFromByteQueue(temporaryByteQueue);
}
if(currentStreamLength < 6 + dataSize){
return false;
}
return true;
}
public static LoreMessage parseResponseRaceDataMessage(CircularByteBuffer byteBuffer){
LoreMessage rVal = new LoreMessage(LoreMessageType.RESPONSERACEDATA);
stripPacketHeader(byteBuffer);
rVal.setdata(ByteStreamUtils.popStringFromByteQueue(byteBuffer));
return rVal;
}
public static LoreMessage constructResponseRaceDataMessage(String data){
LoreMessage rVal = new LoreMessage(LoreMessageType.RESPONSERACEDATA);
rVal.setdata(data);
rVal.serialize();
return rVal;
}
public static boolean canParseRequestDataMessage(CircularByteBuffer byteBuffer){
int currentStreamLength = byteBuffer.getRemaining();
List<Byte> temporaryByteQueue = new LinkedList();
int dataSize = 0;
if(currentStreamLength < 6){
return false;
} else {
temporaryByteQueue.add(byteBuffer.peek(2 + 0));
temporaryByteQueue.add(byteBuffer.peek(2 + 1));
temporaryByteQueue.add(byteBuffer.peek(2 + 2));
temporaryByteQueue.add(byteBuffer.peek(2 + 3));
dataSize = ByteStreamUtils.popIntFromByteQueue(temporaryByteQueue);
}
if(currentStreamLength < 6 + dataSize){
return false;
}
return true;
}
public static LoreMessage parseRequestDataMessage(CircularByteBuffer byteBuffer){
LoreMessage rVal = new LoreMessage(LoreMessageType.REQUESTDATA);
stripPacketHeader(byteBuffer);
rVal.setdata(ByteStreamUtils.popStringFromByteQueue(byteBuffer));
return rVal;
}
public static LoreMessage constructRequestDataMessage(String data){
LoreMessage rVal = new LoreMessage(LoreMessageType.REQUESTDATA);
rVal.setdata(data);
rVal.serialize();
return rVal;
}
public static boolean canParseResponseDataMessage(CircularByteBuffer byteBuffer){
int currentStreamLength = byteBuffer.getRemaining();
List<Byte> temporaryByteQueue = new LinkedList();
int dataSize = 0;
if(currentStreamLength < 6){
return false;
} else {
temporaryByteQueue.add(byteBuffer.peek(2 + 0));
temporaryByteQueue.add(byteBuffer.peek(2 + 1));
temporaryByteQueue.add(byteBuffer.peek(2 + 2));
temporaryByteQueue.add(byteBuffer.peek(2 + 3));
dataSize = ByteStreamUtils.popIntFromByteQueue(temporaryByteQueue);
}
if(currentStreamLength < 6 + dataSize){
return false;
}
return true;
}
public static LoreMessage parseResponseDataMessage(CircularByteBuffer byteBuffer){
LoreMessage rVal = new LoreMessage(LoreMessageType.RESPONSEDATA);
stripPacketHeader(byteBuffer);
rVal.setdata(ByteStreamUtils.popStringFromByteQueue(byteBuffer));
return rVal;
}
public static LoreMessage constructResponseDataMessage(String data){
LoreMessage rVal = new LoreMessage(LoreMessageType.RESPONSEDATA);
rVal.setdata(data);
rVal.serialize();
return rVal;
}
@Override
void serialize(){
byte[] intValues = new byte[8];
@ -249,58 +122,6 @@ public class LoreMessage extends NetworkMessage {
rawBytes[6+i] = stringBytes[i];
}
break;
case REQUESTRACEDATA:
rawBytes = new byte[2];
//message header
rawBytes[0] = TypeBytes.MESSAGE_TYPE_LORE;
//entity messaage header
rawBytes[1] = TypeBytes.LORE_MESSAGE_TYPE_REQUESTRACEDATA;
break;
case RESPONSERACEDATA:
rawBytes = new byte[2+4+data.length()];
//message header
rawBytes[0] = TypeBytes.MESSAGE_TYPE_LORE;
//entity messaage header
rawBytes[1] = TypeBytes.LORE_MESSAGE_TYPE_RESPONSERACEDATA;
intValues = ByteStreamUtils.serializeIntToBytes(data.length());
for(int i = 0; i < 4; i++){
rawBytes[2+i] = intValues[i];
}
stringBytes = data.getBytes();
for(int i = 0; i < data.length(); i++){
rawBytes[6+i] = stringBytes[i];
}
break;
case REQUESTDATA:
rawBytes = new byte[2+4+data.length()];
//message header
rawBytes[0] = TypeBytes.MESSAGE_TYPE_LORE;
//entity messaage header
rawBytes[1] = TypeBytes.LORE_MESSAGE_TYPE_REQUESTDATA;
intValues = ByteStreamUtils.serializeIntToBytes(data.length());
for(int i = 0; i < 4; i++){
rawBytes[2+i] = intValues[i];
}
stringBytes = data.getBytes();
for(int i = 0; i < data.length(); i++){
rawBytes[6+i] = stringBytes[i];
}
break;
case RESPONSEDATA:
rawBytes = new byte[2+4+data.length()];
//message header
rawBytes[0] = TypeBytes.MESSAGE_TYPE_LORE;
//entity messaage header
rawBytes[1] = TypeBytes.LORE_MESSAGE_TYPE_RESPONSEDATA;
intValues = ByteStreamUtils.serializeIntToBytes(data.length());
for(int i = 0; i < 4; i++){
rawBytes[2+i] = intValues[i];
}
stringBytes = data.getBytes();
for(int i = 0; i < data.length(); i++){
rawBytes[6+i] = stringBytes[i];
}
break;
}
serialized = true;
}

View File

@ -56,16 +56,6 @@ SYNCHRONIZATION_MESSAGE,
rVal = EntityMessage.parseSpawnItemMessage(byteBuffer);
}
break;
case TypeBytes.ENTITY_MESSAGE_TYPE_SETPOSITION:
if(EntityMessage.canParseMessage(byteBuffer,secondByte)){
rVal = EntityMessage.parseSetPositionMessage(byteBuffer);
}
break;
case TypeBytes.ENTITY_MESSAGE_TYPE_SETFACING:
if(EntityMessage.canParseMessage(byteBuffer,secondByte)){
rVal = EntityMessage.parsesetFacingMessage(byteBuffer);
}
break;
case TypeBytes.ENTITY_MESSAGE_TYPE_MOVEUPDATE:
if(EntityMessage.canParseMessage(byteBuffer,secondByte)){
rVal = EntityMessage.parsemoveUpdateMessage(byteBuffer);
@ -81,11 +71,6 @@ SYNCHRONIZATION_MESSAGE,
rVal = EntityMessage.parsestartAttackMessage(byteBuffer);
}
break;
case TypeBytes.ENTITY_MESSAGE_TYPE_MOVE:
if(EntityMessage.canParseMessage(byteBuffer,secondByte)){
rVal = EntityMessage.parseMoveMessage(byteBuffer);
}
break;
case TypeBytes.ENTITY_MESSAGE_TYPE_KILL:
if(EntityMessage.canParseMessage(byteBuffer,secondByte)){
rVal = EntityMessage.parseKillMessage(byteBuffer);
@ -96,41 +81,11 @@ SYNCHRONIZATION_MESSAGE,
rVal = EntityMessage.parseDestroyMessage(byteBuffer);
}
break;
case TypeBytes.ENTITY_MESSAGE_TYPE_SETBEHAVIORTREE:
if(EntityMessage.canParseMessage(byteBuffer,secondByte)){
rVal = EntityMessage.parseSetBehaviorTreeMessage(byteBuffer);
}
break;
case TypeBytes.ENTITY_MESSAGE_TYPE_SETPROPERTY:
if(EntityMessage.canParseMessage(byteBuffer,secondByte)){
rVal = EntityMessage.parsesetPropertyMessage(byteBuffer);
}
break;
case TypeBytes.ENTITY_MESSAGE_TYPE_SETBTREEPROPERTYINT:
if(EntityMessage.canParseMessage(byteBuffer,secondByte)){
rVal = EntityMessage.parsesetBTreePropertyIntMessage(byteBuffer);
}
break;
case TypeBytes.ENTITY_MESSAGE_TYPE_SETBTREEPROPERTYFLOAT:
if(EntityMessage.canParseMessage(byteBuffer,secondByte)){
rVal = EntityMessage.parsesetBTreePropertyFloatMessage(byteBuffer);
}
break;
case TypeBytes.ENTITY_MESSAGE_TYPE_SETBTREEPROPERTYDOUBLE:
if(EntityMessage.canParseMessage(byteBuffer,secondByte)){
rVal = EntityMessage.parsesetBTreePropertyDoubleMessage(byteBuffer);
}
break;
case TypeBytes.ENTITY_MESSAGE_TYPE_SETBTREEPROPERTYSTRING:
if(EntityMessage.canParseMessage(byteBuffer,secondByte)){
rVal = EntityMessage.parsesetBTreePropertyStringMessage(byteBuffer);
}
break;
case TypeBytes.ENTITY_MESSAGE_TYPE_SETBTREEPROPERTYENUM:
if(EntityMessage.canParseMessage(byteBuffer,secondByte)){
rVal = EntityMessage.parsesetBTreePropertyEnumMessage(byteBuffer);
}
break;
case TypeBytes.ENTITY_MESSAGE_TYPE_ATTACHENTITYTOENTITY:
if(EntityMessage.canParseMessage(byteBuffer,secondByte)){
rVal = EntityMessage.parseattachEntityToEntityMessage(byteBuffer);
@ -161,26 +116,6 @@ SYNCHRONIZATION_MESSAGE,
rVal = LoreMessage.parseResponseRacesMessage(byteBuffer);
}
break;
case TypeBytes.LORE_MESSAGE_TYPE_REQUESTRACEDATA:
if(LoreMessage.canParseMessage(byteBuffer,secondByte)){
rVal = LoreMessage.parseRequestRaceDataMessage(byteBuffer);
}
break;
case TypeBytes.LORE_MESSAGE_TYPE_RESPONSERACEDATA:
if(LoreMessage.canParseMessage(byteBuffer,secondByte)){
rVal = LoreMessage.parseResponseRaceDataMessage(byteBuffer);
}
break;
case TypeBytes.LORE_MESSAGE_TYPE_REQUESTDATA:
if(LoreMessage.canParseMessage(byteBuffer,secondByte)){
rVal = LoreMessage.parseRequestDataMessage(byteBuffer);
}
break;
case TypeBytes.LORE_MESSAGE_TYPE_RESPONSEDATA:
if(LoreMessage.canParseMessage(byteBuffer,secondByte)){
rVal = LoreMessage.parseResponseDataMessage(byteBuffer);
}
break;
}
break;
case TypeBytes.MESSAGE_TYPE_PLAYER:
@ -211,11 +146,6 @@ SYNCHRONIZATION_MESSAGE,
rVal = TerrainMessage.parseResponseMetadataMessage(byteBuffer);
}
break;
case TypeBytes.TERRAIN_MESSAGE_TYPE_REQUESTCHUNK:
if(TerrainMessage.canParseMessage(byteBuffer,secondByte)){
rVal = TerrainMessage.parseRequestChunkMessage(byteBuffer);
}
break;
case TypeBytes.TERRAIN_MESSAGE_TYPE_REQUESTEDITVOXEL:
if(TerrainMessage.canParseMessage(byteBuffer,secondByte)){
rVal = TerrainMessage.parseRequestEditVoxelMessage(byteBuffer);

View File

@ -10,7 +10,6 @@ public class TerrainMessage extends NetworkMessage {
public enum TerrainMessageType {
REQUESTMETADATA,
RESPONSEMETADATA,
REQUESTCHUNK,
REQUESTEDITVOXEL,
UPDATEVOXEL,
REQUESTUSETERRAINPALETTE,
@ -231,12 +230,6 @@ public class TerrainMessage extends NetworkMessage {
} else {
return false;
}
case TypeBytes.TERRAIN_MESSAGE_TYPE_REQUESTCHUNK:
if(byteBuffer.getRemaining() >= TypeBytes.TERRAIN_MESSAGE_TYPE_REQUESTCHUNK_SIZE){
return true;
} else {
return false;
}
case TypeBytes.TERRAIN_MESSAGE_TYPE_REQUESTEDITVOXEL:
if(byteBuffer.getRemaining() >= TypeBytes.TERRAIN_MESSAGE_TYPE_REQUESTEDITVOXEL_SIZE){
return true;
@ -321,22 +314,6 @@ public class TerrainMessage extends NetworkMessage {
return rVal;
}
public static TerrainMessage parseRequestChunkMessage(CircularByteBuffer byteBuffer){
TerrainMessage rVal = new TerrainMessage(TerrainMessageType.REQUESTCHUNK);
stripPacketHeader(byteBuffer);
rVal.setworldX(ByteStreamUtils.popIntFromByteQueue(byteBuffer));
rVal.setworldY(ByteStreamUtils.popIntFromByteQueue(byteBuffer));
return rVal;
}
public static TerrainMessage constructRequestChunkMessage(int worldX,int worldY){
TerrainMessage rVal = new TerrainMessage(TerrainMessageType.REQUESTCHUNK);
rVal.setworldX(worldX);
rVal.setworldY(worldY);
rVal.serialize();
return rVal;
}
public static TerrainMessage parseRequestEditVoxelMessage(CircularByteBuffer byteBuffer){
TerrainMessage rVal = new TerrainMessage(TerrainMessageType.REQUESTEDITVOXEL);
stripPacketHeader(byteBuffer);
@ -661,21 +638,6 @@ public class TerrainMessage extends NetworkMessage {
rawBytes[26+i] = intValues[i];
}
break;
case REQUESTCHUNK:
rawBytes = new byte[2+4+4];
//message header
rawBytes[0] = TypeBytes.MESSAGE_TYPE_TERRAIN;
//entity messaage header
rawBytes[1] = TypeBytes.TERRAIN_MESSAGE_TYPE_REQUESTCHUNK;
intValues = ByteStreamUtils.serializeIntToBytes(worldX);
for(int i = 0; i < 4; i++){
rawBytes[2+i] = intValues[i];
}
intValues = ByteStreamUtils.serializeIntToBytes(worldY);
for(int i = 0; i < 4; i++){
rawBytes[6+i] = intValues[i];
}
break;
case REQUESTEDITVOXEL:
rawBytes = new byte[2+4+4+4+4+4+4+4+4];
//message header

View File

@ -20,56 +20,34 @@ Message categories
public static final byte ENTITY_MESSAGE_TYPE_CREATE = 0;
public static final byte ENTITY_MESSAGE_TYPE_SPAWNCREATURE = 1;
public static final byte ENTITY_MESSAGE_TYPE_SPAWNITEM = 2;
public static final byte ENTITY_MESSAGE_TYPE_SETPOSITION = 3;
public static final byte ENTITY_MESSAGE_TYPE_SETFACING = 4;
public static final byte ENTITY_MESSAGE_TYPE_MOVEUPDATE = 5;
public static final byte ENTITY_MESSAGE_TYPE_ATTACKUPDATE = 6;
public static final byte ENTITY_MESSAGE_TYPE_STARTATTACK = 7;
public static final byte ENTITY_MESSAGE_TYPE_MOVE = 8;
public static final byte ENTITY_MESSAGE_TYPE_KILL = 9;
public static final byte ENTITY_MESSAGE_TYPE_DESTROY = 10;
public static final byte ENTITY_MESSAGE_TYPE_SETBEHAVIORTREE = 11;
public static final byte ENTITY_MESSAGE_TYPE_SETPROPERTY = 12;
public static final byte ENTITY_MESSAGE_TYPE_SETBTREEPROPERTYINT = 13;
public static final byte ENTITY_MESSAGE_TYPE_SETBTREEPROPERTYFLOAT = 14;
public static final byte ENTITY_MESSAGE_TYPE_SETBTREEPROPERTYDOUBLE = 15;
public static final byte ENTITY_MESSAGE_TYPE_SETBTREEPROPERTYSTRING = 16;
public static final byte ENTITY_MESSAGE_TYPE_SETBTREEPROPERTYENUM = 17;
public static final byte ENTITY_MESSAGE_TYPE_ATTACHENTITYTOENTITY = 18;
public static final byte ENTITY_MESSAGE_TYPE_SPAWNFOLIAGESEED = 19;
public static final byte ENTITY_MESSAGE_TYPE_UPDATEENTITYVIEWDIR = 20;
public static final byte ENTITY_MESSAGE_TYPE_MOVEUPDATE = 3;
public static final byte ENTITY_MESSAGE_TYPE_ATTACKUPDATE = 4;
public static final byte ENTITY_MESSAGE_TYPE_STARTATTACK = 5;
public static final byte ENTITY_MESSAGE_TYPE_KILL = 6;
public static final byte ENTITY_MESSAGE_TYPE_DESTROY = 7;
public static final byte ENTITY_MESSAGE_TYPE_SETPROPERTY = 8;
public static final byte ENTITY_MESSAGE_TYPE_ATTACHENTITYTOENTITY = 9;
public static final byte ENTITY_MESSAGE_TYPE_SPAWNFOLIAGESEED = 10;
public static final byte ENTITY_MESSAGE_TYPE_UPDATEENTITYVIEWDIR = 11;
/*
Entity packet sizes
*/
public static final byte ENTITY_MESSAGE_TYPE_SETPOSITION_SIZE = 38;
public static final byte ENTITY_MESSAGE_TYPE_SETFACING_SIZE = 38;
public static final byte ENTITY_MESSAGE_TYPE_MOVEUPDATE_SIZE = 82;
public static final byte ENTITY_MESSAGE_TYPE_MOVEUPDATE_SIZE = 86;
public static final byte ENTITY_MESSAGE_TYPE_ATTACKUPDATE_SIZE = 74;
public static final byte ENTITY_MESSAGE_TYPE_STARTATTACK_SIZE = 2;
public static final byte ENTITY_MESSAGE_TYPE_MOVE_SIZE = 38;
public static final byte ENTITY_MESSAGE_TYPE_KILL_SIZE = 14;
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_SETPROPERTY_SIZE = 22;
public static final byte ENTITY_MESSAGE_TYPE_SETBTREEPROPERTYINT_SIZE = 26;
public static final byte ENTITY_MESSAGE_TYPE_SETBTREEPROPERTYFLOAT_SIZE = 26;
public static final byte ENTITY_MESSAGE_TYPE_SETBTREEPROPERTYDOUBLE_SIZE = 30;
public static final byte ENTITY_MESSAGE_TYPE_SETBTREEPROPERTYENUM_SIZE = 26;
public static final byte ENTITY_MESSAGE_TYPE_UPDATEENTITYVIEWDIR_SIZE = 38;
/*
Lore subcategories
*/
public static final byte LORE_MESSAGE_TYPE_REQUESTRACES = 0;
public static final byte LORE_MESSAGE_TYPE_RESPONSERACES = 1;
public static final byte LORE_MESSAGE_TYPE_REQUESTRACEDATA = 2;
public static final byte LORE_MESSAGE_TYPE_RESPONSERACEDATA = 3;
public static final byte LORE_MESSAGE_TYPE_REQUESTDATA = 4;
public static final byte LORE_MESSAGE_TYPE_RESPONSEDATA = 5;
/*
Lore packet sizes
*/
public static final byte LORE_MESSAGE_TYPE_REQUESTRACES_SIZE = 2;
public static final byte LORE_MESSAGE_TYPE_REQUESTRACEDATA_SIZE = 2;
/*
Player subcategories
*/
@ -85,22 +63,20 @@ Message categories
*/
public static final byte TERRAIN_MESSAGE_TYPE_REQUESTMETADATA = 0;
public static final byte TERRAIN_MESSAGE_TYPE_RESPONSEMETADATA = 1;
public static final byte TERRAIN_MESSAGE_TYPE_REQUESTCHUNK = 2;
public static final byte TERRAIN_MESSAGE_TYPE_REQUESTEDITVOXEL = 3;
public static final byte TERRAIN_MESSAGE_TYPE_UPDATEVOXEL = 4;
public static final byte TERRAIN_MESSAGE_TYPE_REQUESTUSETERRAINPALETTE = 5;
public static final byte TERRAIN_MESSAGE_TYPE_SPAWNPOSITION = 6;
public static final byte TERRAIN_MESSAGE_TYPE_REQUESTCHUNKDATA = 7;
public static final byte TERRAIN_MESSAGE_TYPE_SENDCHUNKDATA = 8;
public static final byte TERRAIN_MESSAGE_TYPE_REQUESTFLUIDDATA = 9;
public static final byte TERRAIN_MESSAGE_TYPE_SENDFLUIDDATA = 10;
public static final byte TERRAIN_MESSAGE_TYPE_UPDATEFLUIDDATA = 11;
public static final byte TERRAIN_MESSAGE_TYPE_REQUESTEDITVOXEL = 2;
public static final byte TERRAIN_MESSAGE_TYPE_UPDATEVOXEL = 3;
public static final byte TERRAIN_MESSAGE_TYPE_REQUESTUSETERRAINPALETTE = 4;
public static final byte TERRAIN_MESSAGE_TYPE_SPAWNPOSITION = 5;
public static final byte TERRAIN_MESSAGE_TYPE_REQUESTCHUNKDATA = 6;
public static final byte TERRAIN_MESSAGE_TYPE_SENDCHUNKDATA = 7;
public static final byte TERRAIN_MESSAGE_TYPE_REQUESTFLUIDDATA = 8;
public static final byte TERRAIN_MESSAGE_TYPE_SENDFLUIDDATA = 9;
public static final byte TERRAIN_MESSAGE_TYPE_UPDATEFLUIDDATA = 10;
/*
Terrain packet sizes
*/
public static final byte TERRAIN_MESSAGE_TYPE_REQUESTMETADATA_SIZE = 2;
public static final byte TERRAIN_MESSAGE_TYPE_RESPONSEMETADATA_SIZE = 30;
public static final byte TERRAIN_MESSAGE_TYPE_REQUESTCHUNK_SIZE = 10;
public static final byte TERRAIN_MESSAGE_TYPE_REQUESTEDITVOXEL_SIZE = 34;
public static final byte TERRAIN_MESSAGE_TYPE_UPDATEVOXEL_SIZE = 34;
public static final byte TERRAIN_MESSAGE_TYPE_REQUESTUSETERRAINPALETTE_SIZE = 38;

View File

@ -15,14 +15,6 @@ public class EntityProtocol {
protected static void handleEntityMessage(ServerConnectionHandler connectionHandler, EntityMessage message){
Entity targetEntity;
switch(message.getMessageSubtype()){
case MOVE:
targetEntity = EntityLookupUtils.getEntityById(message.getentityID());
if(targetEntity != null){
CreatureUtils.serverAttachEntityMessageToMovementTree(targetEntity,message);
}
break;
case SETBEHAVIORTREE:
break;
case MOVEUPDATE:
targetEntity = EntityLookupUtils.getEntityById(message.getentityID());
if(targetEntity != null){
@ -53,14 +45,7 @@ public class EntityProtocol {
case DESTROY:
case CREATE:
case ATTACHENTITYTOENTITY:
case SETFACING:
case SETPOSITION:
case SETPROPERTY:
case SETBTREEPROPERTYDOUBLE:
case SETBTREEPROPERTYENUM:
case SETBTREEPROPERTYFLOAT:
case SETBTREEPROPERTYINT:
case SETBTREEPROPERTYSTRING:
case SPAWNFOLIAGESEED:
case SPAWNITEM:
//silently ignore

View File

@ -11,21 +11,13 @@ public class LoreProtocol {
protected static void handleLoreMessage(ServerConnectionHandler connectionHandler, LoreMessage message){
switch(message.getMessageSubtype()){
case REQUESTDATA:
//TODO
break;
case REQUESTRACEDATA:
//TODO
break;
case REQUESTRACES:
List<String> playableRaces = Globals.gameConfigCurrent.getCreatureTypeLoader().getPlayableRaces();
String returnData = Utilities.stringify(playableRaces);
connectionHandler.addMessagetoOutgoingQueue(LoreMessage.constructResponseRacesMessage(returnData));
break;
case RESPONSEDATA:
case RESPONSERACES:
case RESPONSERACEDATA:
//silently ignore
break;
}

View File

@ -22,9 +22,6 @@ public class TerrainProtocol {
protected static void handleTerrainMessage(ServerConnectionHandler connectionHandler, TerrainMessage message){
switch(message.getMessageSubtype()){
case REQUESTCHUNK:
// sendWorldChunk(connectionHandler, message.getworldX(), message.getworldY());
break;
case REQUESTMETADATA:
sendWorldMetadata(connectionHandler);
break;

View File

@ -1,6 +1,12 @@
package electrosphere.net.synchronization;
import electrosphere.entity.state.movement.groundmove.ClientGroundMovementTree;
import electrosphere.entity.state.movement.groundmove.ServerGroundMovementTree;
import electrosphere.entity.state.equip.ClientEquipState;
import electrosphere.entity.state.attack.ClientAttackTree;
import electrosphere.entity.state.attack.ServerAttackTree;
@ -122,6 +128,14 @@ public class ClientSynchronizationManager {
} break;
}
} break;
case BehaviorTreeIdEnums.BTREE_SERVERGROUNDMOVEMENTTREE_ID: {
switch(message.getfieldId()){
case 11:{
ClientGroundMovementTree tree = ClientGroundMovementTree.getClientGroundMovementTree(entity);
tree.setFacing(ClientGroundMovementTree.getMovementRelativeFacingShortAsEnum((short)message.getbTreeValue()));
} break;
}
} break;
}
}

View File

@ -2,7 +2,6 @@ package electrosphere.server.datacell;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.CopyOnWriteArraySet;
@ -25,7 +24,6 @@ import electrosphere.server.datacell.interfaces.VoxelCellManager;
import electrosphere.server.datacell.physics.PhysicsDataCell;
import electrosphere.server.fluid.manager.ServerFluidChunk;
import electrosphere.server.fluid.manager.ServerFluidManager;
import electrosphere.server.saves.SaveUtils;
import electrosphere.server.terrain.manager.ServerTerrainManager;
import electrosphere.server.terrain.manager.ServerTerrainChunk;
@ -132,8 +130,8 @@ public class GriddedDataCellManager implements DataCellManager, VoxelCellManager
Vector3i oldPosition = player.getWorldPos();
player.setWorldPos(newPosition);
// System.out.println("=======" + "SET" + newX + " " + newY + " FROM " + oldX + " " + oldY + "========");
int removals = 0;
int additions = 0;
// int removals = 0;
// int additions = 0;
for(int x = oldPosition.x - playerSimulationRadius; x < oldPosition.x + playerSimulationRadius + 1; x++){
for(int y = oldPosition.y - playerSimulationRadius; y < oldPosition.y + playerSimulationRadius + 1; y++){
for(int z = oldPosition.z - playerSimulationRadius; z < oldPosition.z + playerSimulationRadius + 1; z++){
@ -357,7 +355,7 @@ public class GriddedDataCellManager implements DataCellManager, VoxelCellManager
public void simulate(){
loadedCellsLock.acquireUninterruptibly();
for(ServerDataCell cell : loadedCells){
Globals.microSimulation.simulate(cell, parent.getHitboxManager());
Globals.microSimulation.simulate(cell);
//simulate fluid
Vector3i cellPos = this.getCellWorldPosition(cell);

View File

@ -18,7 +18,6 @@ import electrosphere.entity.types.attach.AttachUtils;
import electrosphere.entity.types.creature.CreatureUtils;
import electrosphere.entity.types.item.ItemUtils;
import electrosphere.server.datacell.Realm;
import electrosphere.server.datacell.utils.DataCellSearchUtils;
/**
* Callback for managing collisions on the server
@ -42,8 +41,6 @@ public class ServerHitboxResolutionCallback implements CollisionResolutionCallba
boolean isDamageEvent =
impactorShapeStatus != null &&
receiverShapeStatus != null &&
impactorShapeStatus.isActive() &&
receiverShapeStatus.isActive() &&
impactorShapeStatus.getType() == HitboxType.HIT &&
receiverShapeStatus.getType() == HitboxType.HURT &&
AttachUtils.getParent(impactorParent) != receiverParent

View File

@ -1,7 +1,6 @@
package electrosphere.server.datacell.utils;
import electrosphere.entity.Entity;
import electrosphere.logger.LoggerInterface;
import electrosphere.server.datacell.ServerDataCell;
/**

View File

@ -1,7 +1,9 @@
package electrosphere.server.simulation;
import electrosphere.entity.types.attach.AttachUtils;
import electrosphere.collision.hitbox.HitboxManager;
import java.util.Set;
import electrosphere.engine.Globals;
import electrosphere.engine.Main;
import electrosphere.entity.Entity;
@ -10,8 +12,8 @@ import electrosphere.entity.EntityUtils;
import electrosphere.entity.state.collidable.ServerCollidableTree;
import electrosphere.entity.types.item.ItemUtils;
import electrosphere.entity.types.particle.ParticleUtils;
import electrosphere.renderer.actor.Actor;
import electrosphere.server.datacell.ServerDataCell;
import electrosphere.server.poseactor.PoseActor;
/**
* Server-side micro-scale simulation
@ -24,31 +26,29 @@ public class MicroSimulation {
isReady = false;
}
public void simulate(ServerDataCell dataCell, HitboxManager hitboxManager){
/**
* Simulates a provided data cell
* @param dataCell The data cell
*/
public void simulate(ServerDataCell dataCell){
if(dataCell.isReady()){
//simulate ai
Globals.aiManager.simulate();
//update actor animations
for(Entity currentEntity : dataCell.getScene().getEntitiesWithTag(EntityTags.DRAWABLE)){
//fetch actor
Actor currentActor = EntityUtils.getActor(currentEntity);
//increment animations
if(currentActor.isPlayingAnimation()){
currentActor.incrementAnimationTime(Globals.timekeeper.getSimFrameTime() / Main.targetFrameRate);
}
}
//update first person model animations
if(Globals.firstPersonEntity != null){
//fetch actor
Actor currentActor = EntityUtils.getActor(Globals.firstPersonEntity);
//increment animations
if(currentActor.isPlayingAnimation()){
currentActor.incrementAnimationTime(Globals.timekeeper.getSimFrameTime() / Main.targetFrameRate);
Set<Entity> poseableEntities = dataCell.getScene().getEntitiesWithTag(EntityTags.POSEABLE);
if(poseableEntities != null){
for(Entity currentEntity : dataCell.getScene().getEntitiesWithTag(EntityTags.POSEABLE)){
//fetch actor
PoseActor currentPoseActor = EntityUtils.getPoseActor(currentEntity);
//increment animations
if(currentPoseActor.isPlayingAnimation()){
currentPoseActor.incrementAnimationTime(Globals.timekeeper.getSimFrameTime() / Main.targetFrameRate);
}
}
}
//make items play idle animation
for(Entity item : dataCell.getScene().getEntitiesWithTag(EntityTags.ITEM)){
ItemUtils.updateItemActorAnimation(item);
ItemUtils.updateItemPoseActorAnimation(item);
}
//particle state updates
for(Entity particle : dataCell.getScene().getEntitiesWithTag(EntityTags.PARTICLE)){
@ -58,9 +58,6 @@ public class MicroSimulation {
}
//update attached entity positions
AttachUtils.serverUpdateAttachedEntityPositions(dataCell);
//
//hitbox updates
hitboxManager.simulate();
//simulate behavior trees
dataCell.getScene().simulateBehaviorTrees((float)Globals.timekeeper.getSimFrameTime());
//sum collidable impulses