Search in sources :

Example 36 with EntityPlayerSP

use of net.minecraft.client.entity.EntityPlayerSP in project Railcraft by Railcraft.

the class PacketGuiInteger method readData.

@Override
public void readData(RailcraftInputStream data) throws IOException {
    windowId = data.readByte();
    dataId = data.readByte();
    value = data.readInt();
    EntityPlayerSP player = FMLClientHandler.instance().getClient().thePlayer;
    if (player.openContainer != null && player.openContainer.windowId == windowId)
        player.openContainer.updateProgressBar(dataId, value);
}
Also used : EntityPlayerSP(net.minecraft.client.entity.EntityPlayerSP)

Example 37 with EntityPlayerSP

use of net.minecraft.client.entity.EntityPlayerSP in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.

the class EntityDraggable method tickAddedVelocity.

//TODO: Finishme
public void tickAddedVelocity() {
    if (worldBelowFeet != null && !ValkyrienWarfareMod.physicsManager.isEntityFixed(draggableAsEntity)) {
        CoordTransformObject coordTransform = worldBelowFeet.wrapping.coordTransform;
        float rotYaw = draggableAsEntity.rotationYaw;
        float rotPitch = draggableAsEntity.rotationPitch;
        float prevYaw = draggableAsEntity.prevRotationYaw;
        float prevPitch = draggableAsEntity.prevRotationPitch;
        Vector oldPos = new Vector(draggableAsEntity);
        RotationMatrices.applyTransform(coordTransform.prevwToLTransform, coordTransform.prevWToLRotation, draggableAsEntity);
        RotationMatrices.applyTransform(coordTransform.lToWTransform, coordTransform.lToWRotation, draggableAsEntity);
        Vector newPos = new Vector(draggableAsEntity);
        //Move the entity back to its old position, the added velocity will be used afterwards
        draggableAsEntity.setPosition(oldPos.X, oldPos.Y, oldPos.Z);
        Vector addedVel = oldPos.getSubtraction(newPos);
        velocityAddedToPlayer = addedVel;
        draggableAsEntity.rotationYaw = rotYaw;
        draggableAsEntity.rotationPitch = rotPitch;
        draggableAsEntity.prevRotationYaw = prevYaw;
        draggableAsEntity.prevRotationPitch = prevPitch;
        Vector oldLookingPos = new Vector(draggableAsEntity.getLook(1.0F));
        RotationMatrices.applyTransform(coordTransform.prevWToLRotation, oldLookingPos);
        RotationMatrices.applyTransform(coordTransform.lToWRotation, oldLookingPos);
        double newPitch = Math.asin(oldLookingPos.Y) * -180D / Math.PI;
        double f4 = -Math.cos(-newPitch * 0.017453292D);
        double radianYaw = Math.atan2((oldLookingPos.X / f4), (oldLookingPos.Z / f4));
        radianYaw += Math.PI;
        radianYaw *= -180D / Math.PI;
        if (!(Double.isNaN(radianYaw) || Math.abs(newPitch) > 85)) {
            double wrappedYaw = MathHelper.wrapDegrees(radianYaw);
            double wrappedRotYaw = MathHelper.wrapDegrees(draggableAsEntity.rotationYaw);
            double yawDif = wrappedYaw - wrappedRotYaw;
            if (Math.abs(yawDif) > 180D) {
                if (yawDif < 0) {
                    yawDif += 360D;
                } else {
                    yawDif -= 360D;
                }
            }
            yawDif %= 360D;
            final double threshold = .1D;
            if (Math.abs(yawDif) < threshold) {
                yawDif = 0D;
            }
            yawDifVelocity = yawDif;
        }
    }
    boolean onGroundOrig = draggableAsEntity.onGround;
    if (!ValkyrienWarfareMod.physicsManager.isEntityFixed(draggableAsEntity)) {
        float originalWalked = draggableAsEntity.distanceWalkedModified;
        float originalWalkedOnStep = draggableAsEntity.distanceWalkedOnStepModified;
        boolean originallySneaking = draggableAsEntity.isSneaking();
        draggableAsEntity.setSneaking(false);
        if (draggableAsEntity.worldObj.isRemote && draggableAsEntity instanceof EntityPlayerSP) {
            EntityPlayerSP playerSP = (EntityPlayerSP) draggableAsEntity;
            MovementInput moveInput = playerSP.movementInput;
            originallySneaking = moveInput.sneak;
            moveInput.sneak = false;
        }
        draggableAsEntity.moveEntity(velocityAddedToPlayer.X, velocityAddedToPlayer.Y, velocityAddedToPlayer.Z);
        if (!(draggableAsEntity instanceof EntityPlayer)) {
            if (draggableAsEntity instanceof EntityArrow) {
                draggableAsEntity.prevRotationYaw = draggableAsEntity.rotationYaw;
                draggableAsEntity.rotationYaw -= yawDifVelocity;
            } else {
                draggableAsEntity.prevRotationYaw = draggableAsEntity.rotationYaw;
                draggableAsEntity.rotationYaw += yawDifVelocity;
            }
        } else {
            if (draggableAsEntity.worldObj.isRemote) {
                draggableAsEntity.prevRotationYaw = draggableAsEntity.rotationYaw;
                draggableAsEntity.rotationYaw += yawDifVelocity;
            }
        }
        //Do not add this movement as if the entity were walking it
        draggableAsEntity.distanceWalkedModified = originalWalked;
        draggableAsEntity.distanceWalkedOnStepModified = originalWalkedOnStep;
        draggableAsEntity.setSneaking(originallySneaking);
        if (draggableAsEntity.worldObj.isRemote && draggableAsEntity instanceof EntityPlayerSP) {
            EntityPlayerSP playerSP = (EntityPlayerSP) draggableAsEntity;
            MovementInput moveInput = playerSP.movementInput;
            moveInput.sneak = originallySneaking;
        }
    }
    if (onGroundOrig) {
        draggableAsEntity.onGround = onGroundOrig;
    }
    velocityAddedToPlayer.multiply(.99D);
    yawDifVelocity *= .95D;
}
Also used : CoordTransformObject(ValkyrienWarfareBase.PhysicsManagement.CoordTransformObject) EntityArrow(net.minecraft.entity.projectile.EntityArrow) EntityPlayer(net.minecraft.entity.player.EntityPlayer) EntityPlayerSP(net.minecraft.client.entity.EntityPlayerSP) Vector(ValkyrienWarfareBase.API.Vector) MovementInput(net.minecraft.util.MovementInput)

Aggregations

EntityPlayerSP (net.minecraft.client.entity.EntityPlayerSP)37 ItemStack (net.minecraft.item.ItemStack)9 Entity (net.minecraft.entity.Entity)7 BlockPos (net.minecraft.util.BlockPos)6 SideOnly (cpw.mods.fml.relauncher.SideOnly)3 ArrayList (java.util.ArrayList)3 RailcraftContainer (mods.railcraft.common.gui.containers.RailcraftContainer)3 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)3 JsonObject (com.google.gson.JsonObject)2 DrawItem (com.microsoft.Malmo.Schemas.DrawItem)2 EntityTypes (com.microsoft.Malmo.Schemas.EntityTypes)2 List (java.util.List)2 IBlockState (net.minecraft.block.state.IBlockState)2 WorldClient (net.minecraft.client.multiplayer.WorldClient)2 EntityPlayer (net.minecraft.entity.player.EntityPlayer)2 MovementInput (net.minecraft.util.MovementInput)2 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)2 Vector (ValkyrienWarfareBase.API.Vector)1 CoordTransformObject (ValkyrienWarfareBase.PhysicsManagement.CoordTransformObject)1 JsonArray (com.google.gson.JsonArray)1