Search in sources :

Example 11 with IZeroGDimension

use of micdoodle8.mods.galacticraft.api.world.IZeroGDimension in project Galacticraft by micdoodle8.

the class PlayerClient method onLivingUpdatePost.

@Override
public void onLivingUpdatePost(EntityPlayerSP player) {
    GCPlayerStatsClient stats = GCPlayerStatsClient.get(player);
    boolean ridingThirdPersonEntity = player.ridingEntity instanceof ICameraZoomEntity && ((ICameraZoomEntity) player.ridingEntity).defaultThirdPerson();
    if (stats.getPlatformControlled() || player.worldObj.provider instanceof IZeroGDimension) {
        stats.getFreefallHandler().postVanillaMotion(player);
        if (stats.isInFreefall() || ridingThirdPersonEntity) {
            this.cancelLimbSwing(player);
        } else {
            if (stats.isInFreefallLast() && this.downMot2 < -0.008D) {
                stats.setLandingTicks(5 - (int) (Math.min(this.downMot2, stats.getDownMotionLast()) * 40));
                if (stats.getLandingTicks() > stats.getMaxLandingticks()) {
                    if (stats.getLandingTicks() > stats.getMaxLandingticks() + 4) {
                        stats.getFreefallHandler().pjumpticks = stats.getLandingTicks() - stats.getMaxLandingticks() - 5;
                    }
                    stats.setLandingTicks(stats.getMaxLandingticks());
                }
                float dYmax = 0.3F * stats.getLandingTicks() / stats.getMaxLandingticks();
                float factor = 1F;
                for (int i = 0; i <= stats.getLandingTicks(); i++) {
                    stats.getLandingYOffset()[i] = dYmax * MathHelper.sin(i * 3.1415926F / stats.getLandingTicks()) * factor;
                    factor *= 0.97F;
                }
            }
        }
        if (stats.getLandingTicks() > 0) {
            stats.setLandingTicks(stats.getLandingTicks() - 1);
            player.limbSwing *= 0.8F;
            player.limbSwingAmount = 0F;
        }
    } else {
        stats.setInFreefall(false);
        if (ridingThirdPersonEntity) {
            this.cancelLimbSwing(player);
        }
    }
    if (ridingThirdPersonEntity && !stats.isLastRidingCameraZoomEntity()) {
        if (!ConfigManagerCore.disableVehicleCameraChanges)
            FMLClientHandler.instance().getClient().gameSettings.thirdPersonView = 1;
    }
    if (player.ridingEntity instanceof ICameraZoomEntity) {
        if (!ConfigManagerCore.disableVehicleCameraChanges) {
            stats.setLastZoomed(true);
            TickHandlerClient.zoom(((ICameraZoomEntity) player.ridingEntity).getCameraZoom());
        }
    } else if (stats.isLastZoomed()) {
        if (!ConfigManagerCore.disableVehicleCameraChanges) {
            stats.setLastZoomed(false);
            TickHandlerClient.zoom(4.0F);
        }
    }
    stats.setLastRidingCameraZoomEntity(ridingThirdPersonEntity);
    if (stats.isUsingParachute()) {
        player.fallDistance = 0.0F;
    }
    PlayerGearData gearData = GalacticraftCore.proxy.getGearData(player);
    stats.setUsingParachute(false);
    if (gearData != null) {
        stats.setUsingParachute(gearData.getParachute() != null);
        if (!GalacticraftCore.isHeightConflictingModInstalled) {
            if (gearData.getMask() != GCPlayerHandler.GEAR_NOT_PRESENT) {
                player.height = 1.9375F;
            } else {
                player.height = 1.8F;
            }
            AxisAlignedBB bounds = player.getEntityBoundingBox();
            player.setEntityBoundingBox(new AxisAlignedBB(bounds.minX, bounds.minY, bounds.minZ, bounds.maxX, bounds.minY + (double) player.height, bounds.maxZ));
        }
    }
    if (stats.isUsingParachute() && player.onGround) {
        stats.setUsingParachute(false);
        stats.setLastUsingParachute(false);
        FMLClientHandler.instance().getClient().gameSettings.thirdPersonView = stats.getThirdPersonView();
    }
    if (!stats.isLastUsingParachute() && stats.isUsingParachute()) {
        FMLClientHandler.instance().getClient().getSoundHandler().playSound(new PositionedSoundRecord(new ResourceLocation(Constants.TEXTURE_PREFIX + "player.parachute"), 0.95F + player.getRNG().nextFloat() * 0.1F, 1.0F, (float) player.posX, (float) player.posY, (float) player.posZ));
    }
    stats.setLastUsingParachute(stats.isUsingParachute());
    stats.setLastOnGround(player.onGround);
}
Also used : PositionedSoundRecord(net.minecraft.client.audio.PositionedSoundRecord) ICameraZoomEntity(micdoodle8.mods.galacticraft.api.entity.ICameraZoomEntity) IZeroGDimension(micdoodle8.mods.galacticraft.api.world.IZeroGDimension) PlayerGearData(micdoodle8.mods.galacticraft.core.wrappers.PlayerGearData)

Example 12 with IZeroGDimension

use of micdoodle8.mods.galacticraft.api.world.IZeroGDimension in project Galacticraft by micdoodle8.

the class GCPlayerBaseSP method afterUpdateEntityActionState.

@Override
public void afterUpdateEntityActionState() {
    if (this.player.worldObj.provider instanceof IZeroGDimension) {
        this.player.setJumping(false);
        AxisAlignedBB aABB = this.player.getEntityBoundingBox();
        if ((aABB.minY % 1D) == 0.5D)
            this.player.setEntityBoundingBox(aABB.offset(0D, 0.00001D, 0D));
    }
}
Also used : AxisAlignedBB(net.minecraft.util.AxisAlignedBB) IZeroGDimension(micdoodle8.mods.galacticraft.api.world.IZeroGDimension)

Aggregations

IZeroGDimension (micdoodle8.mods.galacticraft.api.world.IZeroGDimension)12 Entity (net.minecraft.entity.Entity)5 ICameraZoomEntity (micdoodle8.mods.galacticraft.api.entity.ICameraZoomEntity)4 ZeroGravityEvent (micdoodle8.mods.galacticraft.api.event.ZeroGravityEvent)4 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)4 WorldProviderSpaceStation (micdoodle8.mods.galacticraft.core.dimension.WorldProviderSpaceStation)3 GCPlayerStatsClient (micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStatsClient)3 AxisAlignedBB (net.minecraft.util.AxisAlignedBB)3 Vector3 (micdoodle8.mods.galacticraft.api.vector.Vector3)2 SpinManager (micdoodle8.mods.galacticraft.core.dimension.SpinManager)2 EntityLanderBase (micdoodle8.mods.galacticraft.core.entities.EntityLanderBase)2 Block (net.minecraft.block.Block)2 IBlockState (net.minecraft.block.state.IBlockState)2 EntityPlayerSP (net.minecraft.client.entity.EntityPlayerSP)2 EntityLivingBase (net.minecraft.entity.EntityLivingBase)2 EntityFallingBlock (net.minecraft.entity.item.EntityFallingBlock)2 BlockPos (net.minecraft.util.BlockPos)2 World (net.minecraft.world.World)2 WorldProvider (net.minecraft.world.WorldProvider)2 Field (java.lang.reflect.Field)1