Exemple #1
0
  @Override
  public void tick() {
    if (getParent() instanceof EntityPlayer) {
      if (Morph.config.getSessionInt("allowFlight") == 0) {
        return;
      }
      EntityPlayer player = (EntityPlayer) getParent();
      if (!player.capabilities.allowFlying) {
        player.capabilities.allowFlying = true;
        player.sendPlayerAbilities();
      }
      if (player.capabilities.isFlying && !player.capabilities.isCreativeMode) {
        double motionX =
            player.worldObj.isRemote ? player.motionX : player.posX - player.lastTickPosX;
        double motionZ =
            player.worldObj.isRemote ? player.motionZ : player.posZ - player.lastTickPosZ;
        int i = Math.round(MathHelper.sqrt_double(motionX * motionX + motionZ * motionZ) * 100.0F);

        if (i > 0 && i < 10) {
          if (player.isInWater() && slowdownInWater) {
            player.addExhaustion(0.125F * (float) i * 0.01F);
          } else {
            player.addExhaustion(0.035F * (float) i * 0.01F);
          }
        } else {
          player.addExhaustion(0.002F);
        }

        if (player.worldObj.isRemote && player.isInWater() && slowdownInWater) {
          MorphInfo info =
              Morph.proxy.tickHandlerClient.playerMorphInfo.get(player.getCommandSenderName());

          if (info != null) {
            boolean swim = false;
            for (Ability ability : info.morphAbilities) {
              if (ability.getType().equalsIgnoreCase("swim")) {
                swim = true;
                break;
              }
            }
            if (!swim) {
              player.motionX *= 0.65D;
              player.motionZ *= 0.65D;

              player.motionY *= 0.2D;
            }
          }
        }
      }
    }
    getParent().fallDistance = 0.0F;
    // TODO make "Thing" take note of this so it can fly...
  }
Exemple #2
0
 @Override
 public void kill() {
   if (getParent() instanceof EntityPlayer) {
     EntityPlayer player = (EntityPlayer) getParent();
     if (!player.capabilities.isCreativeMode) {
       player.capabilities.allowFlying = false;
       if (player.capabilities.isFlying) {
         player.capabilities.isFlying = false;
       }
       player.sendPlayerAbilities();
     }
   }
 }
 @Override
 protected boolean set(EntityPlayer container, Double value) {
   container.capabilities.walkSpeed = value.floatValue();
   container.sendPlayerAbilities();
   return true;
 }
 @Override
 protected boolean set(EntityPlayer entity, Boolean value) {
   entity.capabilities.allowFlying = value;
   entity.sendPlayerAbilities();
   return true;
 }