Search in sources :

Example 1 with SoundJetpack

use of tonius.simplyjetpacks.client.audio.SoundJetpack in project SimplyJetpacks by Tonius.

the class ClientTickHandler method tickEnd.

private static void tickEnd() {
    if (mc.thePlayer == null || mc.theWorld == null) {
        return;
    }
    if (!mc.isGamePaused()) {
        Iterator<Integer> itr = SyncHandler.getJetpackStates().keySet().iterator();
        int currentEntity;
        while (itr.hasNext()) {
            currentEntity = itr.next();
            Entity entity = mc.theWorld.getEntityByID(currentEntity);
            if (entity == null || !(entity instanceof EntityLivingBase) || entity.dimension != mc.thePlayer.dimension) {
                itr.remove();
            } else {
                ParticleType particle = SyncHandler.getJetpackStates().get(currentEntity);
                if (particle != null) {
                    if (entity.isInWater() && particle != ParticleType.NONE) {
                        particle = ParticleType.BUBBLE;
                    }
                    SimplyJetpacks.proxy.showJetpackParticles(mc.theWorld, (EntityLivingBase) entity, particle);
                    if (Config.jetpackSounds && !SoundJetpack.isPlayingFor(entity.getEntityId())) {
                        Minecraft.getMinecraft().getSoundHandler().playSound(new SoundJetpack((EntityLivingBase) entity));
                    }
                } else {
                    itr.remove();
                }
            }
        }
    }
    if (sprintKeyCheck && mc.thePlayer.movementInput.moveForward < 1.0F) {
        sprintKeyCheck = false;
    }
    if (!Config.doubleTapSprintInAir || !wearingJetpack || mc.thePlayer.onGround || mc.thePlayer.isSprinting() || mc.thePlayer.isUsingItem() || mc.thePlayer.isPotionActive(Potion.blindness)) {
        return;
    }
    if (!sprintKeyCheck && mc.thePlayer.movementInput.moveForward >= 1.0F && !mc.thePlayer.isCollidedHorizontally && (mc.thePlayer.getFoodStats().getFoodLevel() > 6.0F || mc.thePlayer.capabilities.allowFlying)) {
        if (mc.thePlayer.sprintToggleTimer <= 0 && !mc.gameSettings.keyBindSprint.getIsKeyPressed()) {
            mc.thePlayer.sprintToggleTimer = 7;
            sprintKeyCheck = true;
        } else {
            mc.thePlayer.setSprinting(true);
        }
    }
}
Also used : Entity(net.minecraft.entity.Entity) EntityLivingBase(net.minecraft.entity.EntityLivingBase) ParticleType(tonius.simplyjetpacks.setup.ParticleType) SoundJetpack(tonius.simplyjetpacks.client.audio.SoundJetpack)

Aggregations

Entity (net.minecraft.entity.Entity)1 EntityLivingBase (net.minecraft.entity.EntityLivingBase)1 SoundJetpack (tonius.simplyjetpacks.client.audio.SoundJetpack)1 ParticleType (tonius.simplyjetpacks.setup.ParticleType)1