Search in sources :

Example 6 with ICameraZoomEntity

use of micdoodle8.mods.galacticraft.api.entity.ICameraZoomEntity 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 7 with ICameraZoomEntity

use of micdoodle8.mods.galacticraft.api.entity.ICameraZoomEntity in project Galacticraft by micdoodle8.

the class LayerHeldItemGC method doRenderLayer.

@Override
public void doRenderLayer(AbstractClientPlayer player, float p_177141_2_, float p_177141_3_, float partialTicks, float p_177141_5_, float p_177141_6_, float p_177141_7_, float scale) {
    if (player.ridingEntity instanceof ICameraZoomEntity) {
        return;
    }
    ItemStack itemstack = player.getHeldItem();
    if (itemstack != null) {
        GlStateManager.pushMatrix();
        if (this.livingEntityRenderer.getMainModel().isChild) {
            float f = 0.5F;
            GlStateManager.translate(0.0F, 0.625F, 0.0F);
            GlStateManager.rotate(-20.0F, -1.0F, 0.0F, 0.0F);
            GlStateManager.scale(f, f, f);
        }
        ((ModelBiped) this.livingEntityRenderer.getMainModel()).postRenderArm(0.0625F);
        GlStateManager.translate(-0.0625F, 0.4375F, 0.0625F);
        if (player instanceof EntityPlayer && ((EntityPlayer) player).fishEntity != null) {
            itemstack = new ItemStack(Items.fishing_rod, 0);
        }
        Item item = itemstack.getItem();
        Minecraft minecraft = Minecraft.getMinecraft();
        if (item instanceof ItemBlock && Block.getBlockFromItem(item).getRenderType() == 2) {
            GlStateManager.translate(0.0F, 0.1875F, -0.3125F);
            GlStateManager.rotate(20.0F, 1.0F, 0.0F, 0.0F);
            GlStateManager.rotate(45.0F, 0.0F, 1.0F, 0.0F);
            float f1 = 0.375F;
            GlStateManager.scale(-f1, -f1, f1);
        }
        if (player.isSneaking()) {
            GlStateManager.translate(0.0F, 0.203125F, 0.0F);
        }
        minecraft.getItemRenderer().renderItem(player, itemstack, ItemCameraTransforms.TransformType.THIRD_PERSON);
        GlStateManager.popMatrix();
    }
}
Also used : Item(net.minecraft.item.Item) ModelBiped(net.minecraft.client.model.ModelBiped) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ICameraZoomEntity(micdoodle8.mods.galacticraft.api.entity.ICameraZoomEntity) ItemStack(net.minecraft.item.ItemStack) ItemBlock(net.minecraft.item.ItemBlock) Minecraft(net.minecraft.client.Minecraft)

Aggregations

ICameraZoomEntity (micdoodle8.mods.galacticraft.api.entity.ICameraZoomEntity)7 Entity (net.minecraft.entity.Entity)4 EntityPlayer (net.minecraft.entity.player.EntityPlayer)4 IZeroGDimension (micdoodle8.mods.galacticraft.api.world.IZeroGDimension)3 IHoldableItem (micdoodle8.mods.galacticraft.api.item.IHoldableItem)2 PlayerGearData (micdoodle8.mods.galacticraft.core.wrappers.PlayerGearData)2 EntityPlayerSP (net.minecraft.client.entity.EntityPlayerSP)2 Item (net.minecraft.item.Item)2 ItemStack (net.minecraft.item.ItemStack)2 ZeroGravityEvent (micdoodle8.mods.galacticraft.api.event.ZeroGravityEvent)1 IHoldableItemCustom (micdoodle8.mods.galacticraft.api.item.IHoldableItemCustom)1 EntityTieredRocket (micdoodle8.mods.galacticraft.api.prefab.entity.EntityTieredRocket)1 Vector3 (micdoodle8.mods.galacticraft.api.vector.Vector3)1 IGalacticraftWorldProvider (micdoodle8.mods.galacticraft.api.world.IGalacticraftWorldProvider)1 RenderPlayerGC (micdoodle8.mods.galacticraft.core.client.render.entities.RenderPlayerGC)1 EnumGravity (micdoodle8.mods.galacticraft.core.entities.player.EnumGravity)1 GCPlayerStatsClient (micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStatsClient)1 TileEntityMulti (micdoodle8.mods.galacticraft.core.tile.TileEntityMulti)1 IBlockState (net.minecraft.block.state.IBlockState)1 Minecraft (net.minecraft.client.Minecraft)1