Search in sources :

Example 1 with IZeroGDimension

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

the class FreefallHandler method postVanillaMotion.

@SideOnly(Side.CLIENT)
public void postVanillaMotion(EntityPlayerSP p) {
    World world = p.worldObj;
    WorldProvider worldProvider = world.provider;
    if (!(worldProvider instanceof IZeroGDimension)) {
        return;
    }
    ZeroGravityEvent zeroGEvent = new ZeroGravityEvent.Motion(p);
    MinecraftForge.EVENT_BUS.post(zeroGEvent);
    if (zeroGEvent.isCanceled()) {
        return;
    }
    boolean freefall = stats.isInFreefall();
    freefall = this.testFreefall(p, freefall);
    stats.setInFreefall(freefall);
    stats.setInFreefallFirstCheck(true);
    SpinManager spinManager = null;
    if (worldProvider instanceof WorldProviderSpaceStation && !stats.getPlatformControlled()) {
        spinManager = ((WorldProviderSpaceStation) worldProvider).getSpinManager();
    }
    boolean doCentrifugal = spinManager != null;
    if (freefall) {
        this.pjumpticks = 0;
        // Reverse effects of deceleration
        p.motionX /= 0.91F;
        p.motionZ /= 0.91F;
        p.motionY /= 0.9800000190734863D;
        if (spinManager != null) {
            doCentrifugal = spinManager.updatePlayerForSpin(p, 1F);
        }
        // Do freefall motion
        if (!p.capabilities.isCreativeMode) {
            this.freefallMotion(p);
        } else {
            p.capabilities.isFlying = true;
            // Half the normal acceleration in Creative mode
            double dx = p.motionX - this.pPrevMotionX;
            double dy = p.motionY - this.pPrevMotionY;
            double dz = p.motionZ - this.pPrevMotionZ;
            p.motionX -= dx / 2;
            p.motionY -= dy / 2;
            p.motionZ -= dz / 2;
            if (p.motionX > 1.2F) {
                p.motionX = 1.2F;
            }
            if (p.motionX < -1.2F) {
                p.motionX = -1.2F;
            }
            if (p.motionY > 0.7F) {
                p.motionY = 0.7F;
            }
            if (p.motionY < -0.7F) {
                p.motionY = -0.7F;
            }
            if (p.motionZ > 1.2F) {
                p.motionZ = 1.2F;
            }
            if (p.motionZ < -1.2F) {
                p.motionZ = -1.2F;
            }
        }
    // TODO: Think about endless drift?
    // Player may run out of oxygen - that will kill the player eventually if can't get back to SS
    // Could auto-kill + respawn the player if floats too far away (config option whether to lose items or not)
    // But we want players to be able to enjoy the view of the spinning space station from the outside
    // Arm and leg movements could start tumbling the player?
    } else // Not freefall - within arm's length of something or jumping
    {
        double dy = p.motionY - this.pPrevMotionY;
        // if (p.motionY != 0) p.motionY = this.pPrevMotionY;
        if (p.movementInput.jump) {
            if ((p.onGround || stats.isSsOnGroundLast()) && !p.capabilities.isCreativeMode) {
                if (this.pjumpticks < 25)
                    this.pjumpticks++;
                p.motionY -= dy;
            } else {
                p.motionY += 0.015D;
                if (this.pjumpticks == 0) {
                    p.motionY -= dy;
                }
            }
        } else if (this.pjumpticks > 0) {
            p.motionY += 0.0145D * this.pjumpticks;
            this.pjumpticks = 0;
        } else if (p.movementInput.sneak) {
            if (!p.onGround) {
                p.motionY -= 0.015D;
            }
            this.pjumpticks = 0;
        }
    }
    // Artificial gravity
    if (doCentrifugal && !p.onGround) {
        spinManager.applyCentrifugalForce(p);
    }
    this.pPrevMotionX = p.motionX;
    this.pPrevMotionY = p.motionY;
    this.pPrevMotionZ = p.motionZ;
}
Also used : ZeroGravityEvent(micdoodle8.mods.galacticraft.api.event.ZeroGravityEvent) SpinManager(micdoodle8.mods.galacticraft.core.dimension.SpinManager) WorldProviderSpaceStation(micdoodle8.mods.galacticraft.core.dimension.WorldProviderSpaceStation) WorldProvider(net.minecraft.world.WorldProvider) World(net.minecraft.world.World) IZeroGDimension(micdoodle8.mods.galacticraft.api.world.IZeroGDimension) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 2 with IZeroGDimension

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

the class FreefallHandler method testFreefall.

@SideOnly(Side.CLIENT)
private boolean testFreefall(EntityPlayerSP p, boolean flag) {
    World world = p.worldObj;
    WorldProvider worldProvider = world.provider;
    if (!(worldProvider instanceof IZeroGDimension)) {
        return false;
    }
    ZeroGravityEvent zeroGEvent = new ZeroGravityEvent.InFreefall(p);
    MinecraftForge.EVENT_BUS.post(zeroGEvent);
    if (zeroGEvent.isCanceled()) {
        return false;
    }
    if (this.pjumpticks > 0 || (stats.isSsOnGroundLast() && p.movementInput.jump)) {
        return false;
    }
    if (p.ridingEntity != null) {
        Entity e = p.ridingEntity;
        if (e instanceof EntitySpaceshipBase) {
            return ((EntitySpaceshipBase) e).getLaunched();
        }
        if (e instanceof EntityLanderBase) {
            return false;
        }
    // TODO: should check whether lander has landed (whatever that means)
    // TODO: could check other ridden entities - every entity should have its own freefall check :(
    }
    // This is an "on the ground" check
    if (!flag) {
        return false;
    } else {
        float rY = p.rotationYaw % 360F;
        double zreach = 0D;
        double xreach = 0D;
        if (rY < 80F || rY > 280F) {
            zreach = 0.2D;
        }
        if (rY < 170F && rY > 10F) {
            xreach = 0.2D;
        }
        if (rY < 260F && rY > 100F) {
            zreach = -0.2D;
        }
        if (rY < 350F && rY > 190F) {
            xreach = -0.2D;
        }
        AxisAlignedBB playerReach = p.getEntityBoundingBox().addCoord(xreach, 0, zreach);
        boolean checkBlockWithinReach;
        if (worldProvider instanceof WorldProviderSpaceStation) {
            SpinManager spinManager = ((WorldProviderSpaceStation) worldProvider).getSpinManager();
            checkBlockWithinReach = playerReach.maxX >= spinManager.ssBoundsMinX && playerReach.minX <= spinManager.ssBoundsMaxX && playerReach.maxY >= spinManager.ssBoundsMinY && playerReach.minY <= spinManager.ssBoundsMaxY && playerReach.maxZ >= spinManager.ssBoundsMinZ && playerReach.minZ <= spinManager.ssBoundsMaxZ;
        // Player is somewhere within the space station boundaries
        } else {
            checkBlockWithinReach = true;
        }
        if (checkBlockWithinReach) {
            // Check if the player's bounding box is in the same block coordinates as any non-vacuum block (including torches etc)
            // If so, it's assumed the player has something close enough to grab onto, so is not in freefall
            // Note: breatheable air here means the player is definitely not in freefall
            int xm = MathHelper.floor_double(playerReach.minX);
            int xx = MathHelper.floor_double(playerReach.maxX);
            int ym = MathHelper.floor_double(playerReach.minY);
            int yy = MathHelper.floor_double(playerReach.maxY);
            int zm = MathHelper.floor_double(playerReach.minZ);
            int zz = MathHelper.floor_double(playerReach.maxZ);
            for (int x = xm; x <= xx; x++) {
                for (int y = ym; y <= yy; y++) {
                    for (int z = zm; z <= zz; z++) {
                        // Blocks.air is hard vacuum - we want to check for that, here
                        Block b = world.getBlockState(new BlockPos(x, y, z)).getBlock();
                        if (Blocks.air != b && GCBlocks.brightAir != b) {
                            this.onWall = true;
                            return false;
                        }
                    }
                }
            }
        }
    }
    /*
        if (freefall)
        {
            //If that check didn't produce a result, see if the player is inside the walls
            //TODO: could apply special weightless movement here like Coriolis force - the player is inside the walls,  not touching them, and in a vacuum
            int quadrant = 0;
            double xd = p.posX - this.spinCentreX;
            double zd = p.posZ - this.spinCentreZ;
            if (xd<0)
            {
                if (xd<-Math.abs(zd))
                {
                    quadrant = 2;
                } else
                    quadrant = (zd<0) ? 3 : 1;
            } else
                if (xd>Math.abs(zd))
                {
                    quadrant = 0;
                } else
                    quadrant = (zd<0) ? 3 : 1;

            int ymin = MathHelper.floor_double(p.boundingBox.minY)-1;
            int ymax = MathHelper.floor_double(p.boundingBox.maxY);
            int xmin, xmax, zmin, zmax;

            switch (quadrant)
            {
            case 0:
                xmin = MathHelper.floor_double(p.boundingBox.maxX);
                xmax = this.ssBoundsMaxX - 1;
                zmin = MathHelper.floor_double(p.boundingBox.minZ)-1;
                zmax = MathHelper.floor_double(p.boundingBox.maxZ)+1;
                break;
            case 1:
                xmin = MathHelper.floor_double(p.boundingBox.minX)-1;
                xmax = MathHelper.floor_double(p.boundingBox.maxX)+1;
                zmin = MathHelper.floor_double(p.boundingBox.maxZ);
                zmax = this.ssBoundsMaxZ - 1;
                break;
            case 2:
                zmin = MathHelper.floor_double(p.boundingBox.minZ)-1;
                zmax = MathHelper.floor_double(p.boundingBox.maxZ)+1;
                xmin = this.ssBoundsMinX;
                xmax = MathHelper.floor_double(p.boundingBox.minX);
                break;
            case 3:
            default:
                xmin = MathHelper.floor_double(p.boundingBox.minX)-1;
                xmax = MathHelper.floor_double(p.boundingBox.maxX)+1;
                zmin = this.ssBoundsMinZ;
                zmax = MathHelper.floor_double(p.boundingBox.minZ);
                break;
            }

            //This block search could cost a lot of CPU (but client side) - maybe optimise later
            BLOCKCHECK0:
            for(int x = xmin; x <= xmax; x++)
                for (int z = zmin; z <= zmax; z++)
                    for (int y = ymin; y <= ymax; y++)
                        if (Blocks.air != this.worldProvider.worldObj.getBlock(x, y, z))
                        {
                            freefall = false;
                            break BLOCKCHECK0;
                        }
        }*/
    this.onWall = false;
    return true;
}
Also used : ZeroGravityEvent(micdoodle8.mods.galacticraft.api.event.ZeroGravityEvent) EntitySpaceshipBase(micdoodle8.mods.galacticraft.api.prefab.entity.EntitySpaceshipBase) AxisAlignedBB(net.minecraft.util.AxisAlignedBB) Entity(net.minecraft.entity.Entity) World(net.minecraft.world.World) SpinManager(micdoodle8.mods.galacticraft.core.dimension.SpinManager) EntityLanderBase(micdoodle8.mods.galacticraft.core.entities.EntityLanderBase) WorldProviderSpaceStation(micdoodle8.mods.galacticraft.core.dimension.WorldProviderSpaceStation) WorldProvider(net.minecraft.world.WorldProvider) EntityFallingBlock(net.minecraft.entity.item.EntityFallingBlock) Block(net.minecraft.block.Block) BlockPos(net.minecraft.util.BlockPos) IZeroGDimension(micdoodle8.mods.galacticraft.api.world.IZeroGDimension) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 3 with IZeroGDimension

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

the class FreefallHandler method tickFreefallEntity.

/**
 * Call this on every freefalling non-player entity in a dimension
 * either at the end of the world tick (ideal) or else during the
 * start of the next world tick (e.g. during updateWeather())
 *
 * May require iteration through the world's loadedEntityList
 * See SpinManager.updateSpin() for an example
 * @param e
 */
public static void tickFreefallEntity(Entity e) {
    if (e.worldObj.provider instanceof IZeroGDimension)
        ((IZeroGDimension) e.worldObj.provider).setInFreefall(e);
    // Undo deceleration applied at the end of the previous tick
    boolean warnLog = false;
    if (e instanceof EntityLivingBase) {
        ZeroGravityEvent zeroGEvent = new ZeroGravityEvent.InFreefall((EntityLivingBase) e);
        MinecraftForge.EVENT_BUS.post(zeroGEvent);
        if (!zeroGEvent.isCanceled()) {
            // 0.91F;
            e.motionX /= (double) 0.91F;
            // 0.91F;
            e.motionZ /= (double) 0.91F;
            e.motionY /= (e instanceof EntityFlying) ? 0.91F : 0.9800000190734863D;
            if (e.motionX > 10D) {
                warnLog = true;
                e.motionX = 10D;
            } else if (e.motionX < -10D) {
                warnLog = true;
                e.motionX = -10D;
            }
            if (e.motionY > 10D) {
                warnLog = true;
                e.motionY = 10D;
            } else if (e.motionY < -10D) {
                warnLog = true;
                e.motionY = -10D;
            }
            if (e.motionZ > 10D) {
                warnLog = true;
                e.motionZ = 10D;
            } else if (e.motionZ < -10D) {
                warnLog = true;
                e.motionZ = -10D;
            }
        }
    } else if (e instanceof EntityFallingBlock) {
        e.motionY /= 0.9800000190734863D;
        // e.lastTickPosY += 0.03999999910593033D;
        if (e.motionY > 10D) {
            warnLog = true;
            e.motionY = 10D;
        } else if (e.motionY < -10D) {
            warnLog = true;
            e.motionY = -10D;
        }
    } else {
        e.motionX /= 0.9800000190734863D;
        e.motionY /= 0.9800000190734863D;
        e.motionZ /= 0.9800000190734863D;
        if (e.motionX > 10D) {
            warnLog = true;
            e.motionX = 10D;
        } else if (e.motionX < -10D) {
            warnLog = true;
            e.motionX = -10D;
        }
        if (e.motionY > 10D) {
            warnLog = true;
            e.motionY = 10D;
        } else if (e.motionY < -10D) {
            warnLog = true;
            e.motionY = -10D;
        }
        if (e.motionZ > 10D) {
            warnLog = true;
            e.motionZ = 10D;
        } else if (e.motionZ < -10D) {
            warnLog = true;
            e.motionZ = -10D;
        }
    }
    if (warnLog)
        GCLog.debug(e.getName() + " moving too fast");
}
Also used : ZeroGravityEvent(micdoodle8.mods.galacticraft.api.event.ZeroGravityEvent) EntityFallingBlock(net.minecraft.entity.item.EntityFallingBlock) EntityFlying(net.minecraft.entity.EntityFlying) EntityLivingBase(net.minecraft.entity.EntityLivingBase) IZeroGDimension(micdoodle8.mods.galacticraft.api.world.IZeroGDimension)

Example 4 with IZeroGDimension

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

the class GCEntityClientPlayerMP method onLivingUpdate.

@Override
public void onLivingUpdate() {
    ClientProxyCore.playerClientHandler.onLivingUpdatePre(this);
    try {
        if (this.worldObj.provider instanceof IZeroGDimension) {
            // from: EntityPlayerSP
            if (this.sprintingTicksLeft > 0) {
                --this.sprintingTicksLeft;
                if (this.sprintingTicksLeft == 0) {
                    this.setSprinting(false);
                }
            }
            if (this.sprintToggleTimer > 0) {
                --this.sprintToggleTimer;
            }
            this.prevTimeInPortal = this.timeInPortal;
            if (this.inPortal) {
                if (this.mc.currentScreen != null && !this.mc.currentScreen.doesGuiPauseGame()) {
                    this.mc.displayGuiScreen((GuiScreen) null);
                }
                if (this.timeInPortal == 0.0F) {
                    this.mc.getSoundHandler().playSound(PositionedSoundRecord.create(new ResourceLocation("portal.trigger"), this.rand.nextFloat() * 0.4F + 0.8F));
                }
                this.timeInPortal += 0.0125F;
                if (this.timeInPortal >= 1.0F) {
                    this.timeInPortal = 1.0F;
                }
                this.inPortal = false;
            } else if (this.isPotionActive(Potion.confusion) && this.getActivePotionEffect(Potion.confusion).getDuration() > 60) {
                this.timeInPortal += 0.006666667F;
                if (this.timeInPortal > 1.0F) {
                    this.timeInPortal = 1.0F;
                }
            } else {
                if (this.timeInPortal > 0.0F) {
                    this.timeInPortal -= 0.05F;
                }
                if (this.timeInPortal < 0.0F) {
                    this.timeInPortal = 0.0F;
                }
            }
            if (this.timeUntilPortal > 0) {
                --this.timeUntilPortal;
            }
            boolean flag1 = this.movementInput.sneak;
            float sprintlevel = 0.8F;
            boolean flag2 = this.movementInput.moveForward >= sprintlevel;
            this.movementInput.updatePlayerMoveState();
            if (this.isUsingItem() && !this.isRiding()) {
                this.movementInput.moveStrafe *= 0.2F;
                this.movementInput.moveForward *= 0.2F;
                this.sprintToggleTimer = 0;
            }
            // CUSTOM-------------------
            GCPlayerStatsClient stats = GCPlayerStatsClient.get(this);
            if (stats.getLandingTicks() > 0) {
                this.movementInput.moveStrafe *= 0.5F;
                this.movementInput.moveForward *= 0.5F;
            }
            // -----------END CUSTOM
            this.pushOutOfBlocks(this.posX - (double) this.width * 0.35D, this.getEntityBoundingBox().minY + 0.5D, this.posZ + (double) this.width * 0.35D);
            this.pushOutOfBlocks(this.posX - (double) this.width * 0.35D, this.getEntityBoundingBox().minY + 0.5D, this.posZ - (double) this.width * 0.35D);
            this.pushOutOfBlocks(this.posX + (double) this.width * 0.35D, this.getEntityBoundingBox().minY + 0.5D, this.posZ - (double) this.width * 0.35D);
            this.pushOutOfBlocks(this.posX + (double) this.width * 0.35D, this.getEntityBoundingBox().minY + 0.5D, this.posZ + (double) this.width * 0.35D);
            boolean flag3 = (float) this.getFoodStats().getFoodLevel() > 6.0F || this.capabilities.allowFlying;
            if (this.onGround && !flag1 && !flag2 && this.movementInput.moveForward >= sprintlevel && !this.isSprinting() && flag3 && !this.isUsingItem() && !this.isPotionActive(Potion.blindness)) {
                if (this.sprintToggleTimer <= 0 && !this.mc.gameSettings.keyBindSprint.isKeyDown()) {
                    this.sprintToggleTimer = 7;
                } else {
                    this.setSprinting(true);
                }
            }
            if (!this.isSprinting() && this.movementInput.moveForward >= sprintlevel && flag3 && !this.isUsingItem() && !this.isPotionActive(Potion.blindness) && this.mc.gameSettings.keyBindSprint.isKeyDown()) {
                this.setSprinting(true);
            }
            if (this.isSprinting() && (this.movementInput.moveForward < sprintlevel || this.isCollidedHorizontally || !flag3)) {
                this.setSprinting(false);
            }
            if (this.capabilities.isFlying && this.isCurrentViewEntity()) {
                if (this.movementInput.sneak) {
                    this.motionY -= (double) (this.capabilities.getFlySpeed() * 3.0F);
                }
                if (this.movementInput.jump) {
                    this.motionY += (double) (this.capabilities.getFlySpeed() * 3.0F);
                }
            }
            if (this.worldObj.getDifficulty() == EnumDifficulty.PEACEFUL && this.worldObj.getGameRules().getBoolean("naturalRegeneration")) {
                if (this.getHealth() < this.getMaxHealth() && this.ticksExisted % 20 == 0) {
                    this.heal(1.0F);
                }
                if (this.foodStats.needFood() && this.ticksExisted % 10 == 0) {
                    this.foodStats.setFoodLevel(this.foodStats.getFoodLevel() + 1);
                }
            }
            this.inventory.decrementAnimations();
            this.prevCameraYaw = this.cameraYaw;
            // from: EntityLivingBase
            if (this.newPosRotationIncrements > 0) {
                double d0 = this.posX + (this.newPosX - this.posX) / (double) this.newPosRotationIncrements;
                double d1 = this.posY + (this.newPosY - this.posY) / (double) this.newPosRotationIncrements;
                double d2 = this.posZ + (this.newPosZ - this.posZ) / (double) this.newPosRotationIncrements;
                double d3 = MathHelper.wrapAngleTo180_double(this.newRotationYaw - (double) this.rotationYaw);
                this.rotationYaw = (float) ((double) this.rotationYaw + d3 / (double) this.newPosRotationIncrements);
                this.rotationPitch = (float) ((double) this.rotationPitch + (this.newRotationPitch - (double) this.rotationPitch) / (double) this.newPosRotationIncrements);
                --this.newPosRotationIncrements;
                this.setPosition(d0, d1, d2);
                this.setRotation(this.rotationYaw, this.rotationPitch);
            } else if (!this.isServerWorld()) {
                this.motionX *= 0.98D;
                this.motionY *= 0.98D;
                this.motionZ *= 0.98D;
            }
            if (Math.abs(this.motionX) < 0.005D) {
                this.motionX = 0.0D;
            }
            if (Math.abs(this.motionY) < 0.005D) {
                this.motionY = 0.0D;
            }
            if (Math.abs(this.motionZ) < 0.005D) {
                this.motionZ = 0.0D;
            }
            this.worldObj.theProfiler.startSection("ai");
            if (this.isMovementBlocked()) {
                this.isJumping = false;
                this.moveStrafing = 0.0F;
                this.moveForward = 0.0F;
                this.randomYawVelocity = 0.0F;
            } else
                this.updateEntityActionState();
            this.worldObj.theProfiler.endSection();
            this.worldObj.theProfiler.startSection("travel");
            this.moveStrafing *= 0.98F;
            this.moveForward *= 0.98F;
            this.randomYawVelocity *= 0.9F;
            // CUSTOM--------------
            AxisAlignedBB aABB = this.getEntityBoundingBox();
            if ((aABB.minY % 1D) == 0.5D)
                this.setEntityBoundingBox(aABB.offset(0D, 0.00001D, 0D));
            // -----------END CUSTOM
            this.moveEntityWithHeading(this.moveStrafing, this.moveForward);
            this.worldObj.theProfiler.endSection();
            this.worldObj.theProfiler.startSection("push");
            if (!this.worldObj.isRemote) {
                this.collideWithNearbyEntities();
            }
            this.worldObj.theProfiler.endSection();
            // -from: EntityPlayer
            // Omit IAttributeInstance - seems relevant only on server
            // Omit        this.jumpMovementFactor = this.speedInAir;
            // (no bounding in space)
            float f = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
            float f1 = (float) (Math.atan(-this.motionY * 0.20000000298023224D) * 15.0D);
            if (f > 0.1F) {
                f = 0.1F;
            }
            if (!this.onGround || this.getHealth() <= 0.0F) {
                f = 0.0F;
            }
            if (this.onGround || this.getHealth() <= 0.0F) {
                f1 = 0.0F;
            }
            this.cameraYaw += (f - this.cameraYaw) * 0.4F;
            this.cameraPitch += (f1 - this.cameraPitch) * 0.8F;
            if (this.getHealth() > 0.0F && !this.isSpectator()) {
                AxisAlignedBB axisalignedbb = null;
                if (this.ridingEntity != null && !this.ridingEntity.isDead) {
                    axisalignedbb = this.getEntityBoundingBox().union(this.ridingEntity.getEntityBoundingBox()).expand(1.0D, 0.0D, 1.0D);
                } else {
                    axisalignedbb = this.getEntityBoundingBox().expand(1.0D, 0.5D, 1.0D);
                }
                List<Entity> list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, axisalignedbb);
                for (int i = 0; i < list.size(); ++i) {
                    Entity entity = (Entity) list.get(i);
                    if (!entity.isDead) {
                        entity.onCollideWithPlayer(this);
                    }
                }
            }
            // (modified CUSTOM)
            if (this.lastIsFlying != this.capabilities.isFlying) {
                this.lastIsFlying = this.capabilities.isFlying;
                this.sendPlayerAbilities();
            }
        } else {
            super.onLivingUpdate();
        }
    } catch (RuntimeException e) {
        FMLLog.severe("A mod has crashed while Minecraft was doing a normal player tick update.  See details below.  GCEntityClientPlayerMP is in this because that is the player class name when Galacticraft is installed.  This is =*NOT*= a bug in Galacticraft, please report it to the mod indicated by the first lines of the crash report.");
        throw (e);
    }
    ClientProxyCore.playerClientHandler.onLivingUpdatePost(this);
}
Also used : AxisAlignedBB(net.minecraft.util.AxisAlignedBB) ICameraZoomEntity(micdoodle8.mods.galacticraft.api.entity.ICameraZoomEntity) Entity(net.minecraft.entity.Entity) ResourceLocation(net.minecraft.util.ResourceLocation) IZeroGDimension(micdoodle8.mods.galacticraft.api.world.IZeroGDimension)

Example 5 with IZeroGDimension

use of micdoodle8.mods.galacticraft.api.world.IZeroGDimension 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)

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