Search in sources :

Example 1 with ICameraZoomEntity

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

the class RenderPlayerGC method rotateCorpse.

@Override
protected void rotateCorpse(AbstractClientPlayer abstractClientPlayer, float par2, float par3, float par4) {
    if (abstractClientPlayer.isEntityAlive() && abstractClientPlayer.isPlayerSleeping()) {
        RotatePlayerEvent event = new RotatePlayerEvent(abstractClientPlayer);
        MinecraftForge.EVENT_BUS.post(event);
        if (!event.vanillaOverride) {
            super.rotateCorpse(abstractClientPlayer, par2, par3, par4);
        } else if (event.shouldRotate == null) {
            GL11.glRotatef(abstractClientPlayer.getBedOrientationInDegrees(), 0.0F, 1.0F, 0.0F);
        } else if (event.shouldRotate) {
            float rotation = 0.0F;
            if (abstractClientPlayer.playerLocation != null) {
                IBlockState bed = abstractClientPlayer.worldObj.getBlockState(abstractClientPlayer.playerLocation);
                if (bed.getBlock().isBed(abstractClientPlayer.worldObj, abstractClientPlayer.playerLocation, abstractClientPlayer)) {
                    if (bed.getBlock() == GCBlocks.fakeBlock && bed.getValue(BlockMulti.MULTI_TYPE) == BlockMulti.EnumBlockMultiType.CRYO_CHAMBER) {
                        TileEntity tile = event.entityPlayer.worldObj.getTileEntity(abstractClientPlayer.playerLocation);
                        if (tile instanceof TileEntityMulti) {
                            bed = event.entityPlayer.worldObj.getBlockState(((TileEntityMulti) tile).mainBlockPosition);
                        }
                    }
                    if (bed.getBlock() == MarsBlocks.machine && bed.getValue(BlockMachineMars.TYPE) == BlockMachineMars.EnumMachineType.CRYOGENIC_CHAMBER) {
                        switch(bed.getValue(BlockMachineMars.FACING)) {
                            case NORTH:
                                rotation = 0.0F;
                                break;
                            case EAST:
                                rotation = 270.0F;
                                break;
                            case SOUTH:
                                rotation = 180.0F;
                                break;
                            case WEST:
                                rotation = 90.0F;
                                break;
                        }
                    }
                }
            }
            GL11.glRotatef(rotation, 0.0F, 1.0F, 0.0F);
        }
    } else {
        if (Minecraft.getMinecraft().gameSettings.thirdPersonView != 0) {
            final EntityPlayer player = (EntityPlayer) abstractClientPlayer;
            if (player.ridingEntity instanceof ICameraZoomEntity) {
                Entity rocket = player.ridingEntity;
                float rotateOffset = ((ICameraZoomEntity) rocket).getRotateOffset();
                if (rotateOffset > -10F) {
                    GL11.glTranslatef(0, -rotateOffset, 0);
                    float anglePitch = rocket.prevRotationPitch;
                    float angleYaw = rocket.prevRotationYaw;
                    GL11.glRotatef(-angleYaw, 0.0F, 1.0F, 0.0F);
                    GL11.glRotatef(anglePitch, 0.0F, 0.0F, 1.0F);
                    GL11.glTranslatef(0, rotateOffset, 0);
                }
            }
        }
        super.rotateCorpse(abstractClientPlayer, par2, par3, par4);
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) ICameraZoomEntity(micdoodle8.mods.galacticraft.api.entity.ICameraZoomEntity) Entity(net.minecraft.entity.Entity) RendererLivingEntity(net.minecraft.client.renderer.entity.RendererLivingEntity) TileEntity(net.minecraft.tileentity.TileEntity) IBlockState(net.minecraft.block.state.IBlockState) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ICameraZoomEntity(micdoodle8.mods.galacticraft.api.entity.ICameraZoomEntity) TileEntityMulti(micdoodle8.mods.galacticraft.core.tile.TileEntityMulti)

Example 2 with ICameraZoomEntity

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

the class EventHandlerClient method onRenderPlayerPre.

// Lowest priority to do the PushMatrix last, just before vanilla RenderPlayer - this also means if it gets cancelled first by another mod, this will never be called
@SubscribeEvent(priority = EventPriority.LOWEST)
public void onRenderPlayerPre(RenderPlayerEvent.Pre event) {
    GL11.glPushMatrix();
    final EntityPlayer player = event.entityPlayer;
    if (player.ridingEntity instanceof ICameraZoomEntity && player == Minecraft.getMinecraft().thePlayer && Minecraft.getMinecraft().gameSettings.thirdPersonView == 0) {
        Entity entity = player.ridingEntity;
        float rotateOffset = ((ICameraZoomEntity) entity).getRotateOffset();
        if (rotateOffset > -10F) {
            rotateOffset += ClientProxyCore.PLAYER_Y_OFFSET;
            GL11.glTranslatef(0, -rotateOffset, 0);
            float anglePitch = entity.prevRotationPitch + (entity.rotationPitch - entity.prevRotationPitch) * event.partialRenderTick;
            float angleYaw = entity.prevRotationYaw + (entity.rotationYaw - entity.prevRotationYaw) * event.partialRenderTick;
            GL11.glRotatef(-angleYaw, 0.0F, 1.0F, 0.0F);
            GL11.glRotatef(anglePitch, 0.0F, 0.0F, 1.0F);
            GL11.glTranslatef(0, rotateOffset, 0);
        }
    }
    if (player instanceof EntityPlayerSP) {
        sneakRenderOverride = true;
    }
// Gravity - freefall - jetpack changes in player model orientation can go here
}
Also used : Entity(net.minecraft.entity.Entity) ICameraZoomEntity(micdoodle8.mods.galacticraft.api.entity.ICameraZoomEntity) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ICameraZoomEntity(micdoodle8.mods.galacticraft.api.entity.ICameraZoomEntity) EntityPlayerSP(net.minecraft.client.entity.EntityPlayerSP) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 3 with ICameraZoomEntity

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

the class GCEntityClientPlayerMP method isSneaking.

@Override
public boolean isSneaking() {
    if (this.worldObj.provider instanceof IZeroGDimension) {
        ZeroGravityEvent zeroGEvent = new ZeroGravityEvent.SneakOverride(this);
        MinecraftForge.EVENT_BUS.post(zeroGEvent);
        if (zeroGEvent.isCanceled()) {
            return super.isSneaking();
        }
        GCPlayerStatsClient stats = GCPlayerStatsClient.get(this);
        if (stats.getLandingTicks() > 0) {
            if (this.lastLandingTicks == 0)
                this.lastLandingTicks = stats.getLandingTicks();
            this.sneakLast = stats.getLandingTicks() < this.lastLandingTicks;
            return sneakLast;
        } else
            this.lastLandingTicks = 0;
        if (stats.getFreefallHandler().pjumpticks > 0) {
            this.sneakLast = true;
            return true;
        }
        if (EventHandlerClient.sneakRenderOverride) {
            if (this.movementInput != null && this.movementInput.sneak != this.sneakLast) {
                this.sneakLast = this.movementInput.sneak;
                return false;
            }
            // if (stats.freefallHandler.testFreefall(this)) return false;
            if (stats.isInFreefall() || stats.getFreefallHandler().onWall) {
                this.sneakLast = false;
                return false;
            }
        }
    } else if (EventHandlerClient.sneakRenderOverride) {
        if (this.onGround && this.inventory.getCurrentItem() != null && this.inventory.getCurrentItem().getItem() instanceof IHoldableItem && !(this.ridingEntity instanceof ICameraZoomEntity)) {
            IHoldableItem holdableItem = (IHoldableItem) this.inventory.getCurrentItem().getItem();
            if (holdableItem.shouldCrouch(this)) {
                return true;
            }
        }
    }
    this.sneakLast = false;
    return super.isSneaking();
}
Also used : ZeroGravityEvent(micdoodle8.mods.galacticraft.api.event.ZeroGravityEvent) IHoldableItem(micdoodle8.mods.galacticraft.api.item.IHoldableItem) ICameraZoomEntity(micdoodle8.mods.galacticraft.api.entity.ICameraZoomEntity) IZeroGDimension(micdoodle8.mods.galacticraft.api.world.IZeroGDimension)

Example 4 with ICameraZoomEntity

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

the class TransformerHooks method orientCamera.

@SideOnly(Side.CLIENT)
public static void orientCamera(float partialTicks) {
    EntityPlayerSP player = ClientProxyCore.mc.thePlayer;
    GCPlayerStatsClient stats = GCPlayerStatsClient.get(player);
    Entity viewEntity = ClientProxyCore.mc.getRenderViewEntity();
    if (player.ridingEntity instanceof ICameraZoomEntity && ClientProxyCore.mc.gameSettings.thirdPersonView == 0) {
        Entity entity = player.ridingEntity;
        float offset = ((ICameraZoomEntity) entity).getRotateOffset();
        if (offset > -10F) {
            offset += PLAYER_Y_OFFSET;
            GL11.glTranslatef(0, -offset, 0);
            float anglePitch = entity.prevRotationPitch + (entity.rotationPitch - entity.prevRotationPitch) * partialTicks;
            float angleYaw = entity.prevRotationYaw + (entity.rotationYaw - entity.prevRotationYaw) * partialTicks;
            GL11.glRotatef(-anglePitch, 0.0F, 0.0F, 1.0F);
            GL11.glRotatef(angleYaw, 0.0F, 1.0F, 0.0F);
            GL11.glTranslatef(0, offset, 0);
        }
    }
    if (viewEntity instanceof EntityLivingBase && viewEntity.worldObj.provider instanceof IZeroGDimension && !((EntityLivingBase) viewEntity).isPlayerSleeping()) {
        float pitch = viewEntity.prevRotationPitch + (viewEntity.rotationPitch - viewEntity.prevRotationPitch) * partialTicks;
        float yaw = viewEntity.prevRotationYaw + (viewEntity.rotationYaw - viewEntity.prevRotationYaw) * partialTicks + 180.0F;
        float eyeHeightChange = viewEntity.width / 2.0F;
        // GL11.glTranslatef(0.0F, -f1, 0.0F);
        GL11.glRotatef(-yaw, 0.0F, 1.0F, 0.0F);
        GL11.glRotatef(-pitch, 1.0F, 0.0F, 0.0F);
        GL11.glTranslatef(0.0F, 0.0F, 0.1F);
        EnumGravity gDir = stats.getGdir();
        GL11.glRotatef(180.0F * gDir.getThetaX(), 1.0F, 0.0F, 0.0F);
        GL11.glRotatef(180.0F * gDir.getThetaZ(), 0.0F, 0.0F, 1.0F);
        GL11.glRotatef(pitch * gDir.getPitchGravityX(), 1.0F, 0.0F, 0.0F);
        GL11.glRotatef(pitch * gDir.getPitchGravityY(), 0.0F, 1.0F, 0.0F);
        GL11.glRotatef(yaw * gDir.getYawGravityX(), 1.0F, 0.0F, 0.0F);
        GL11.glRotatef(yaw * gDir.getYawGravityY(), 0.0F, 1.0F, 0.0F);
        GL11.glRotatef(yaw * gDir.getYawGravityZ(), 0.0F, 0.0F, 1.0F);
        // GL11.glTranslatef(sneakY * gDir.getSneakVecX(), sneakY * gDir.getSneakVecY(), sneakY * gDir.getSneakVecZ());
        GL11.glTranslatef(eyeHeightChange * gDir.getEyeVecX(), eyeHeightChange * gDir.getEyeVecY(), eyeHeightChange * gDir.getEyeVecZ());
        if (stats.getGravityTurnRate() < 1.0F) {
            GL11.glRotatef(90.0F * (stats.getGravityTurnRatePrev() + (stats.getGravityTurnRate() - stats.getGravityTurnRatePrev()) * partialTicks), stats.getGravityTurnVecX(), stats.getGravityTurnVecY(), stats.getGravityTurnVecZ());
        }
    }
// omit this for interesting 3P views
// GL11.glTranslatef(0.0F, 0.0F, -0.1F);
// GL11.glRotatef(pitch, 1.0F, 0.0F, 0.0F);
// GL11.glRotatef(yaw, 0.0F, 1.0F, 0.0F);
// GL11.glTranslatef(0.0F, f1, 0.0F);
}
Also used : ICameraZoomEntity(micdoodle8.mods.galacticraft.api.entity.ICameraZoomEntity) Entity(net.minecraft.entity.Entity) GCPlayerStatsClient(micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStatsClient) EnumGravity(micdoodle8.mods.galacticraft.core.entities.player.EnumGravity) EntityLivingBase(net.minecraft.entity.EntityLivingBase) ICameraZoomEntity(micdoodle8.mods.galacticraft.api.entity.ICameraZoomEntity) EntityPlayerSP(net.minecraft.client.entity.EntityPlayerSP) IZeroGDimension(micdoodle8.mods.galacticraft.api.world.IZeroGDimension) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 5 with ICameraZoomEntity

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

the class ModelBipedGC method setRotationAngles.

public static void setRotationAngles(ModelBiped biped, float par1, float par2, float par3, float par4, float par5, float par6, Entity par7Entity) {
    if (!(par7Entity instanceof EntityPlayer))
        return;
    final EntityPlayer player = (EntityPlayer) par7Entity;
    final ItemStack currentItemStack = player.inventory.getCurrentItem();
    final float floatPI = 3.1415927F;
    if (!par7Entity.onGround && par7Entity.worldObj.provider instanceof IGalacticraftWorldProvider && par7Entity.ridingEntity == null && !(currentItemStack != null && currentItemStack.getItem() instanceof IHoldableItem)) {
        float speedModifier = 0.1162F * 2;
        float angularSwingArm = MathHelper.cos(par1 * (speedModifier / 2));
        float rightMod = biped.heldItemRight != 0 ? 1 : 2;
        biped.bipedRightArm.rotateAngleX -= MathHelper.cos(par1 * 0.6662F + floatPI) * rightMod * par2 * 0.5F;
        biped.bipedLeftArm.rotateAngleX -= MathHelper.cos(par1 * 0.6662F) * 2.0F * par2 * 0.5F;
        biped.bipedRightArm.rotateAngleX += -angularSwingArm * 4.0F * par2 * 0.5F;
        biped.bipedLeftArm.rotateAngleX += angularSwingArm * 4.0F * par2 * 0.5F;
        biped.bipedLeftLeg.rotateAngleX -= MathHelper.cos(par1 * 0.6662F + floatPI) * 1.4F * par2;
        biped.bipedLeftLeg.rotateAngleX += MathHelper.cos(par1 * 0.1162F * 2 + floatPI) * 1.4F * par2;
        biped.bipedRightLeg.rotateAngleX -= MathHelper.cos(par1 * 0.6662F) * 1.4F * par2;
        biped.bipedRightLeg.rotateAngleX += MathHelper.cos(par1 * 0.1162F * 2) * 1.4F * par2;
    }
    PlayerGearData gearData = GalacticraftCore.proxy.getGearData(player);
    if (gearData != null) {
        if (gearData.getParachute() != null) {
            // Parachute is equipped
            biped.bipedLeftArm.rotateAngleX += floatPI;
            biped.bipedLeftArm.rotateAngleZ += floatPI / 10;
            biped.bipedRightArm.rotateAngleX += floatPI;
            biped.bipedRightArm.rotateAngleZ -= floatPI / 10;
        }
    }
    if (player.inventory.getCurrentItem() != null && player.inventory.getCurrentItem().getItem() instanceof IHoldableItem && !(player.ridingEntity instanceof ICameraZoomEntity)) {
        Item heldItem = player.inventory.getCurrentItem().getItem();
        IHoldableItem holdableItem = (IHoldableItem) heldItem;
        IHoldableItemCustom holdableItemCustom = heldItem instanceof IHoldableItemCustom ? (IHoldableItemCustom) heldItem : null;
        if (holdableItem.shouldHoldLeftHandUp(player)) {
            Vector3 angle = null;
            if (holdableItemCustom != null) {
                angle = holdableItemCustom.getLeftHandRotation(player);
            }
            if (angle == null) {
                angle = new Vector3(floatPI + 0.3F, 0.0F, floatPI / 10.0F);
            }
            biped.bipedLeftArm.rotateAngleX = angle.floatX();
            biped.bipedLeftArm.rotateAngleY = angle.floatY();
            biped.bipedLeftArm.rotateAngleZ = angle.floatZ();
        }
        if (holdableItem.shouldHoldRightHandUp(player)) {
            Vector3 angle = null;
            if (holdableItemCustom != null) {
                angle = holdableItemCustom.getRightHandRotation(player);
            }
            if (angle == null) {
                angle = new Vector3(floatPI + 0.3F, 0.0F, (float) -Math.PI / 10.0F);
            }
            biped.bipedRightArm.rotateAngleX = angle.floatX();
            biped.bipedRightArm.rotateAngleY = angle.floatY();
            biped.bipedRightArm.rotateAngleZ = angle.floatZ();
        }
    }
    final List<?> l = player.worldObj.getEntitiesWithinAABBExcludingEntity(player, AxisAlignedBB.fromBounds(player.posX - 20, 0, player.posZ - 20, player.posX + 20, 200, player.posZ + 20));
    for (int i = 0; i < l.size(); i++) {
        final Entity e = (Entity) l.get(i);
        if (e instanceof EntityTieredRocket) {
            final EntityTieredRocket ship = (EntityTieredRocket) e;
            if (ship.riddenByEntity != null && !(ship.riddenByEntity).equals(player) && (ship.getLaunched() || ship.timeUntilLaunch < 390)) {
                biped.bipedRightArm.rotateAngleZ -= floatPI / 8F + MathHelper.sin(par3 * 0.9F) * 0.2F;
                biped.bipedRightArm.rotateAngleX = floatPI;
                break;
            }
        }
    }
    if (player.isPlayerSleeping() && GalacticraftCore.isPlanetsLoaded) {
        RenderPlayerGC.RotatePlayerEvent event = new RenderPlayerGC.RotatePlayerEvent((AbstractClientPlayer) player);
        MinecraftForge.EVENT_BUS.post(event);
        if (event.vanillaOverride && (event.shouldRotate == null || event.shouldRotate)) {
            biped.bipedHead.rotateAngleX = (float) (20.0F - Math.sin(player.ticksExisted / 10.0F) / 7.0F);
            biped.bipedHead.rotateAngleY = 0.0F;
            biped.bipedHead.rotateAngleZ = 0.0F;
            biped.bipedLeftArm.rotateAngleX = 0.0F;
            biped.bipedLeftArm.rotateAngleY = 0.0F;
            biped.bipedLeftArm.rotateAngleZ = 0.0F;
            biped.bipedRightArm.rotateAngleX = 0.0F;
            biped.bipedRightArm.rotateAngleY = 0.0F;
            biped.bipedRightArm.rotateAngleZ = 0.0F;
        }
    }
    if (biped instanceof ModelPlayer) {
        ModelBiped.copyModelAngles(biped.bipedHead, ((ModelPlayer) biped).bipedHeadwear);
    }
}
Also used : Entity(net.minecraft.entity.Entity) ICameraZoomEntity(micdoodle8.mods.galacticraft.api.entity.ICameraZoomEntity) EntityTieredRocket(micdoodle8.mods.galacticraft.api.prefab.entity.EntityTieredRocket) RenderPlayerGC(micdoodle8.mods.galacticraft.core.client.render.entities.RenderPlayerGC) IGalacticraftWorldProvider(micdoodle8.mods.galacticraft.api.world.IGalacticraftWorldProvider) IHoldableItemCustom(micdoodle8.mods.galacticraft.api.item.IHoldableItemCustom) ICameraZoomEntity(micdoodle8.mods.galacticraft.api.entity.ICameraZoomEntity) Vector3(micdoodle8.mods.galacticraft.api.vector.Vector3) Item(net.minecraft.item.Item) IHoldableItem(micdoodle8.mods.galacticraft.api.item.IHoldableItem) ModelPlayer(net.minecraft.client.model.ModelPlayer) IHoldableItem(micdoodle8.mods.galacticraft.api.item.IHoldableItem) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ItemStack(net.minecraft.item.ItemStack) PlayerGearData(micdoodle8.mods.galacticraft.core.wrappers.PlayerGearData)

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