use of org.valkyrienskies.mod.common.capability.entity_backup.ICapabilityEntityBackup in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.
the class ITransformablePacket method doPostProcessing.
/**
* Restores the player from local coordinates to where they used to be.
*/
default void doPostProcessing(INetHandlerPlayServer server, boolean callingFromSponge) {
if (isPacketOnMainThread(server, callingFromSponge)) {
NetHandlerPlayServer serverHandler = (NetHandlerPlayServer) server;
EntityPlayerMP player = serverHandler.player;
// If we made a backup in doPreProcessing(), then restore from that backup.
ICapabilityEntityBackup entityBackup = player.getCapability(VSCapabilityRegistry.VS_ENTITY_BACKUP, null);
if (entityBackup.hasBackupPosition()) {
entityBackup.restoreEntityToBackup(player);
}
}
}
use of org.valkyrienskies.mod.common.capability.entity_backup.ICapabilityEntityBackup in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.
the class ITransformablePacket method doPreProcessing.
/**
* Puts the player into local coordinates and makes a record of where they used to be.
*/
default void doPreProcessing(INetHandlerPlayServer server, boolean callingFromSponge) {
if (isPacketOnMainThread(server, callingFromSponge)) {
// System.out.println("Pre packet process");
NetHandlerPlayServer serverHandler = (NetHandlerPlayServer) server;
EntityPlayerMP player = serverHandler.player;
ShipData physicsObject = getPacketParent(serverHandler);
if (physicsObject != null) {
// First make a backup of the player position
ICapabilityEntityBackup entityBackup = player.getCapability(VSCapabilityRegistry.VS_ENTITY_BACKUP, null);
entityBackup.backupEntityPosition(player);
// Then put the player into ship coordinates.
physicsObject.getShipTransform().transform(player, TransformType.GLOBAL_TO_SUBSPACE, true);
}
}
}
Aggregations