use of net.minecraft.network.play.INetHandlerPlayServer in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.
the class ITransformablePacket method isPacketOnMainThread.
default boolean isPacketOnMainThread(INetHandlerPlayServer server, boolean callingFromSponge) {
if (!ValkyrienSkiesMod.isSpongePresent() || callingFromSponge) {
NetHandlerPlayServer serverHandler = (NetHandlerPlayServer) server;
EntityPlayerMP player = serverHandler.player;
return player.getServerWorld().isCallingFromMinecraftThread();
} else {
return false;
}
}
use of net.minecraft.network.play.INetHandlerPlayServer 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 net.minecraft.network.play.INetHandlerPlayServer 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