Exemplo n.º 1
0
  @SubscribeEvent
  public void playerTick(TickEvent.PlayerTickEvent event) {
    EntityPlayer player = event.player;
    TPlayerStats stats = TPlayerStats.get(player);

    // Wall climb
    if (stats.climbWalls) {
      double motionX = player.posX - player.lastTickPosX;
      double motionZ = player.posZ - player.lastTickPosZ;
      double motionY = player.posY - player.lastTickPosY - 0.762;
      if (motionY > 0.0D && (motionX == 0D || motionZ == 0D)) {
        player.fallDistance = 0.0F;
      }
    }

    // Feet changes
    ItemStack feet = player.getCurrentArmor(0);
    if (feet != null) {
      if (feet.getItem() instanceof IModifyable && !player.isSneaking()) {
        NBTTagCompound tag =
            feet.getTagCompound().getCompoundTag(((IModifyable) feet.getItem()).getBaseTagName());
        int sole = tag.getInteger("Slimy Soles");
        if (sole > 0) {
          if (!player.isSneaking() && player.onGround && prevMotionY < -0.4)
            player.motionY = -prevMotionY * (Math.min(0.99, sole * 0.2));
        }
      }
      prevMotionY = player.motionY;
    }
    if (feet != prevFeet) {
      if (prevFeet != null && prevFeet.getItem() instanceof TravelGear) player.stepHeight -= 0.6f;
      if (feet != null && feet.getItem() instanceof TravelGear) player.stepHeight += 0.6f;
      prevFeet = feet;
    }
    // TODO: Proper minimap support
    /*ItemStack stack = player.inventory.getStackInSlot(8);
    if (stack != null && stack.getItem() instanceof ItemMap)
    {
        stack.getItem().onUpdate(stack, player.worldObj, player, 8, true);
    }*/
    if (!player.isPlayerSleeping()) {
      ItemStack chest = player.getCurrentArmor(2);
      if (chest == null || !(chest.getItem() instanceof IModifyable)) {
        if (!morphLoaded || !morphed) PlayerAbilityHelper.setEntitySize(player, 0.6F, 1.8F);
      } else {
        NBTTagCompound tag =
            chest.getTagCompound().getCompoundTag(((IModifyable) chest.getItem()).getBaseTagName());
        int dodge = tag.getInteger("Perfect Dodge");
        if (dodge > 0) {
          if (!morphLoaded || !morphed)
            PlayerAbilityHelper.setEntitySize(
                player, Math.max(0.15F, 0.6F - (dodge * 0.09f)), 1.8F - (dodge * 0.04f));
        }
      }
    }
  }
  @SubscribeEvent
  public void playerTick(TickEvent.PlayerTickEvent event) {
    EntityPlayer player = event.player;
    TPlayerStats stats = TPlayerStats.get(player);
    if (mc.thePlayer.onGround) {
      controlInstance.landOnGround();
    }
    if (stats.climbWalls && player.isCollidedHorizontally && !player.isSneaking()) {
      player.motionY = 0.1176D;
      player.fallDistance = 0.0f;
    }

    // Feet changes - moved to server side
    /*ItemStack feet = player.getCurrentArmor(0);
    if (feet != null)
    {
        if (feet.getItem() instanceof TravelGear && player.stepHeight < 1.0f)
        {
            player.stepHeight += 0.6f;
        }
        if (feet.getItem() instanceof IModifyable && !player.isSneaking())
        {
            NBTTagCompound tag = feet.getTagCompound().getCompoundTag(((IModifyable) feet.getItem()).getBaseTagName());
            int sole = tag.getInteger("Slimy Soles");
            if (sole > 0)
            {
                if (!player.isSneaking() && player.onGround && prevMotionY < -0.4)
                    player.motionY = -prevMotionY * (Math.min(0.99, sole * 0.2));
            }
        }
        prevMotionY = player.motionY;
    }
    if (feet != prevFeet)
    {
        if (prevFeet != null && prevFeet.getItem() instanceof TravelGear)
            player.stepHeight -= 0.6f;
        if (feet != null && feet.getItem() instanceof TravelGear)
            player.stepHeight += 0.6f;
        prevFeet = feet;
    }*/

    // Legs or wing changes
    /*ItemStack legs = player.getCurrentArmor(1);
    if (legs != null && legs.getItem() instanceof IModifyable)
    {
        NBTTagCompound tag = legs.getTagCompound().getCompoundTag(((IModifyable) legs.getItem()).getBaseTagName());
        if (player.isSprinting())
        {
            if (!sprint)
            {
                sprint = true;
                int sprintboost = tag.getInteger("Sprint Assist");
                if (player.isSprinting() && sprintboost > 0)
                {
                    prevMouseSensitivity = gs.mouseSensitivity;
                    gs.mouseSensitivity *= 1 - (0.15 * sprintboost);
                }
            }
        }
        else if (sprint)
        {
            sprint = false;
            gs.mouseSensitivity = prevMouseSensitivity;
        }
    }*/
    if (!player.isPlayerSleeping() && !morphed) {
      ItemStack chest = player.getCurrentArmor(2);
      if (chest == null || !(chest.getItem() instanceof IModifyable)) {
        PlayerAbilityHelper.setEntitySize(player, 0.6F, 1.8F);
      } else {
        NBTTagCompound tag =
            chest.getTagCompound().getCompoundTag(((IModifyable) chest.getItem()).getBaseTagName());
        int dodge = tag.getInteger("Perfect Dodge");
        if (dodge > 0) {
          PlayerAbilityHelper.setEntitySize(
              player, Math.max(0.15F, 0.6F - (dodge * 0.09f)), 1.8F - (dodge * 0.04f));
        }
      }
    }
  }