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);
}
}
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
}
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();
}
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);
}
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);
}
}
Aggregations