use of io.xol.chunkstories.api.client.net.ClientPacketsProcessor in project chunkstories-api by Hugobros3.
the class PacketDecal method process.
@Override
public void process(PacketSender sender, DataInputStream in, PacketReceptionContext processor) throws IOException, PacketProcessingException {
decalName = in.readUTF();
Vector3d position = new Vector3d();
position.x = (in.readDouble());
position.y = (in.readDouble());
position.z = (in.readDouble());
Vector3d orientation = new Vector3d();
orientation.x = (in.readDouble());
orientation.y = (in.readDouble());
orientation.z = (in.readDouble());
Vector3d size = new Vector3d();
size.x = (in.readDouble());
size.y = (in.readDouble());
size.z = (in.readDouble());
if (processor instanceof ClientPacketsProcessor) {
ClientPacketsProcessor cpp = (ClientPacketsProcessor) processor;
cpp.getContext().getDecalsManager().drawDecal(position, orientation, size, decalName);
}
}
use of io.xol.chunkstories.api.client.net.ClientPacketsProcessor in project chunkstories-api by Hugobros3.
the class PacketEntity method process.
public void process(PacketSender sender, DataInputStream in, PacketReceptionContext processor) throws IOException, UnknownComponentException {
long entityUUID = in.readLong();
short entityTypeID = in.readShort();
if (entityTypeID == -1)
return;
World world = processor.getWorld();
if (world == null)
return;
Entity entity = world.getEntityByUUID(entityUUID);
boolean addToWorld = false;
// Create an entity if the servers tells you to do so
if (entity == null) {
if (world instanceof WorldMaster && sender instanceof RemotePlayer) {
((Player) sender).sendMessage("You are sending packets to the server about a removed entity. Ignoring those.");
return;
} else {
entity = processor.getWorld().getContentTranslator().getEntityForId(entityTypeID).create(// This is technically wrong
new Location(world, 0, 0, 0));
entity.setUUID(entityUUID);
addToWorld = true;
}
}
int componentId = in.readInt();
// Loop throught all components
while (componentId != 0) {
try {
entity.getComponents().tryPullComponentInStream(componentId, sender, in);
} catch (UnknownComponentException e) {
processor.logger().warn(e.getMessage());
}
componentId = in.readInt();
}
// Add to world if it was missing and we didn't receive the despawn flag
if (addToWorld && entity.exists()) {
// Only the WorldMaster is allowed to spawn new entities in the world
if (processor instanceof ClientPacketsProcessor)
processor.getWorld().addEntity(entity);
}
}
Aggregations