Search in sources :

Example 26 with NetHandlerPlayServer

use of net.minecraft.network.NetHandlerPlayServer 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);
        }
    }
}
Also used : ShipData(org.valkyrienskies.mod.common.ships.ShipData) ICapabilityEntityBackup(org.valkyrienskies.mod.common.capability.entity_backup.ICapabilityEntityBackup) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) NetHandlerPlayServer(net.minecraft.network.NetHandlerPlayServer) INetHandlerPlayServer(net.minecraft.network.play.INetHandlerPlayServer)

Aggregations

NetHandlerPlayServer (net.minecraft.network.NetHandlerPlayServer)26 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)16 ItemStack (net.minecraft.item.ItemStack)6 GameProfile (com.mojang.authlib.GameProfile)5 NetworkManager (net.minecraft.network.NetworkManager)5 WorldServer (net.minecraft.world.WorldServer)5 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)5 ResourceDirectory (ivorius.reccomplex.files.loading.ResourceDirectory)3 SaveDirectoryData (ivorius.reccomplex.utils.SaveDirectoryData)3 InventoryPlayer (net.minecraft.entity.player.InventoryPlayer)3 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)3 INetHandlerPlayServer (net.minecraft.network.play.INetHandlerPlayServer)3 Entity (net.minecraft.entity.Entity)2 PacketBuffer (net.minecraft.network.PacketBuffer)2 SPacketCustomPayload (net.minecraft.network.play.server.SPacketCustomPayload)2 SPacketSetSlot (net.minecraft.network.play.server.SPacketSetSlot)2 Player (org.spongepowered.api.entity.living.player.Player)2 CauseStackManager (org.spongepowered.api.event.CauseStackManager)2 ICapabilityEntityBackup (org.valkyrienskies.mod.common.capability.entity_backup.ICapabilityEntityBackup)2 FakePlayerItemInWorldManager (pneumaticCraft.common.ai.FakePlayerItemInWorldManager)2