Ejemplo n.º 1
0
  @SuppressWarnings("incomplete-switch")
  @Override
  public void onArmorTick(World world, EntityPlayer player, ItemStack stack) {
    if (!stack.hasTagCompound()) stack.setTagCompound(new NBTTagCompound());

    if (stack.getItemDamage() >= stack.getMaxDamage() - 2) {
      NBTTagCompound tag = stack.getTagCompound();
      tag.setBoolean("destroyed", true);
      stack.setTagCompound(tag);

      return;
    }

    switch (this.armorType) {
      case HEAD:
        if (stack.getTagCompound().getBoolean("respiration")
            && stack.getItemDamage() < stack.getMaxDamage() - 16)
          if (player.getAir() == 0) {
            player.setAir(150);
            stack.damageItem(16, player);
          }
        break;
      case LEGS:
      case FEET:
        if (stack.getTagCompound().getBoolean("fall")) {
          if (player.fallDistance > 0) player.fallDistance = 0;
        }
    }
  }
Ejemplo n.º 2
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));
        }
      }
    }
  }
Ejemplo n.º 3
0
 @Override
 public void onTickWhileActive(EntityPlayer player) {
   player.addVelocity(0.0D, 0.1D, 0.0D);
   if (player.fallDistance > 0) player.fallDistance = 0;
   if (player.worldObj instanceof WorldServer) {
     ((WorldServer) player.worldObj)
         .getEntityTracker()
         .func_151248_b(player, new S12PacketEntityVelocity(player));
   }
 }
 void tickPlayer(EntityPlayer player) {
   if (player.worldObj.isRemote) player.stepHeight = player.isSneaking() ? 0.5F : 1F;
   Utils.setWalkSpeed(player.capabilities, Utils.getWalkSpeed(player.capabilities) + 0.05F);
   player.jumpMovementFactor = player.isSprinting() ? 0.05F : 0.04F;
   player.fallDistance = 0F;
   int x = (int) player.posX;
   int y = (int) player.posY - 1;
   int z = (int) player.posZ;
   if (player.worldObj.getBlockId(x, y, z) == Block.dirt.blockID)
     player.worldObj.setBlock(x, y, z, Block.grass.blockID, 0, 2);
 }
Ejemplo n.º 5
0
  public static void checkPlayerPositions() {
    World worldObj = CompactMachines.instance.machineHandler.getWorld();
    if (worldObj.getTotalWorldTime() % 10 == 0) {
      for (int i = 0; i < worldObj.playerEntities.size(); i++) {
        if (worldObj.playerEntities.get(i) instanceof EntityPlayer) {
          EntityPlayer player = (EntityPlayer) worldObj.playerEntities.get(i);

          // Protect against falling into the void
          if (player.posY < 10) {
            player.fallDistance = 0;
            teleportPlayerOutOfMachineDimension((EntityPlayerMP) player);
            continue;
          }

          if (!ConfigurationHandler.keepPlayersInsideOfRooms) {
            continue;
          }

          if (player.capabilities.isCreativeMode && PlayerUtils.isPlayerOpped(player)) {
            // Opped players in creative mode are actually allowed to leave the rooms
            continue;
          }

          int lastCoord = PlayerUtils.getPlayerCoords(player);
          if (lastCoord == -1) {
            // We don't know where the player is atm :(
            continue;
          }

          if (!CompactMachines.instance.machineHandler.hasRoomSize(lastCoord)) {
            // We sadly don't know the size of the room the player is in. Skipping.
            // This automatically changes once any player enters the cube again.
            continue;
          }

          int roomSize =
              Reference.getBoxSize(CompactMachines.instance.machineHandler.getRoomSize(lastCoord));

          AxisAlignedBB bb = CubeTools.getBoundingBoxForCube(lastCoord, roomSize);
          if (!bb.isVecInside(Vec3.createVectorHelper(player.posX, player.posY, player.posZ))) {
            teleportPlayerToCoords((EntityPlayerMP) player, lastCoord, true);

            // Add potion effects for 200 ticks
            player.addPotionEffect(new PotionEffect(2, 200, 5, false)); // Slowness
            player.addPotionEffect(new PotionEffect(9, 200, 5, false)); // Nausea
          }
        }
      }
    }
  }
Ejemplo n.º 6
0
  @SubscribeEvent
  public void onLivingUpdate(LivingUpdateEvent event) {
    if (event.entityLiving instanceof EntityPlayer) {
      EntityPlayer player = (EntityPlayer) event.entityLiving;
      MainExtendedPlayer props = MainExtendedPlayer.get(player);

      if (props.getUsedFruit().equals("gomugomu")
          || props.getUsedFruit().equals("banebane")
          || props.isLogia()
          || (player.getCurrentEquippedItem() != null
              && player.getCurrentEquippedItem().getItem() == ListMisc.Geppo))
        player.fallDistance = 0;
    }
  }
Ejemplo n.º 7
0
 public boolean onItemUse(
     ItemStack stack,
     EntityPlayer player,
     World world,
     int x,
     int y,
     int z,
     int side,
     float hitX,
     float hitY,
     float hitZ) {
   if (world.getBlock(x, y, z) != Blocks.air) {
     if (hammerType.equals(EnumHammerType.POGO)) {
       player.motionY = Math.abs(player.motionY) + 0.5;
       player.fallDistance = 0;
       stack.damageItem(1, player);
       return true;
     }
   }
   return false;
 }
  @SubscribeEvent
  public void entityHurt(LivingHurtEvent event) {
    if (event.entityLiving instanceof EntityPlayer
        && event.source == DamageSource.outOfWorld
        && ((EntityPlayer) event.entityLiving).posY < 0
        && isServer()) {
      EntityPlayer player = (EntityPlayer) event.entityLiving;
      if (!DiscoveryManager.itemUnlocked(QADiscoveries.Item.VACUUM.get().getKey(), player)
          && DiscoveryManager.areParentsUnlocked(
              QADiscoveries.Item.VACUUM.get().getKey(), player)) {
        String translate = "qa.aboutToVoid";
        player.addChatComponentMessage(
            new ChatComponentText(
                LocalizationUtils.translateLocalWithColours(translate, translate)));
        ChunkCoordinates spawn = player.getBedLocation(player.worldObj.provider.dimensionId);

        ChunkCoordinates portalEntrance =
            MinecraftServer.getServer()
                .worldServerForDimension(player.dimension)
                .getEntrancePortalLocation();
        if (portalEntrance != null && spawn == null) {
          spawn = portalEntrance;
        }

        if (spawn == null) {
          spawn = player.worldObj.getSpawnPoint();
        }

        int y = spawn.posY;

        while (!player.worldObj.isAirBlock(spawn.posX, y, spawn.posZ)) // Get top block
        y++;

        player.setPositionAndUpdate(spawn.posX, y, spawn.posZ);
        player.fallDistance = 0F;

        DiscoveryManager.unlockItem(QADiscoveries.Item.VACUUM.get().getKey(), player, false);
      }
    }
  }
  @Override
  public ItemStack onFocusRightClick(
      ItemStack itemstack, World world, EntityPlayer p, MovingObjectPosition movingobjectposition) {
    ItemWandCasting wand = (ItemWandCasting) itemstack.getItem();
    if (!ConfigHandler.enableFlight) {
      return itemstack;
    }
    if (wand.consumeAllVis(itemstack, p, getVisCost(), true, false)) {
      Vec3 vec = p.getLookVec();
      double force =
          1
              / 1.5
              * (1
                  + EnchantmentHelper.getEnchantmentLevel(
                          Config.enchPotency.effectId, wand.getFocusItem(itemstack))
                      * 0.2);
      p.motionX = vec.xCoord * force;
      p.motionY = vec.yCoord * force;
      p.motionZ = vec.zCoord * force;
      p.fallDistance = 0F;
      if (p instanceof EntityPlayerMP) {
        ((EntityPlayerMP) p).playerNetServerHandler.floatingTickCount = 0;
      }
      for (int i = 0; i < 5; i++)
        ThaumicTinkerer.tcProxy.smokeSpiral(
            world,
            p.posX,
            p.posY - p.motionY,
            p.posZ,
            2F,
            (int) (Math.random() * 360),
            (int) p.posY);
      world.playSoundAtEntity(p, "thaumcraft:wind", 0.4F, 1F);
    }

    if (world.isRemote) p.swingItem();

    return itemstack;
  }
 @SubscribeEvent
 public void onLivingUpdate(LivingUpdateEvent event) {
   if (event.entity instanceof EntityPlayer) {
     EntityPlayer player = (EntityPlayer) event.entity;
     ZSSPlayerInfo.get(player).onUpdate();
     if (player.motionY < -0.25D) {
       boolean flag =
           player.getHeldItem() != null && player.getHeldItem().getItem() == ZSSItems.rocsFeather;
       if (flag
           || (player.getCurrentArmor(ArmorIndex.WORN_HELM) != null
               && player.getCurrentArmor(ArmorIndex.WORN_HELM).getItem() == ZSSItems.maskDeku)) {
         player.motionY = -0.25D;
         player.fallDistance = 0.0F;
       }
     }
   }
   if (event.entity instanceof EntityLivingBase) {
     ZSSEntityInfo.get((EntityLivingBase) event.entity).onUpdate();
   }
   if (event.entity instanceof EntityVillager) {
     ZSSVillagerInfo.get((EntityVillager) event.entity).onUpdate();
   }
 }
Ejemplo n.º 11
0
  @Override
  public void control(EntityPlayerCustom playerCustom, EntityPlayer player, Side side) {
    int x = MathHelper.floor_double(player.posX);
    int y = MathHelper.floor_double(player.posY);
    int z = MathHelper.floor_double(player.posZ);
    int heading = MathHelper.floor_double((double) (player.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
    if (!playerCustom.isSneaking) {
      if (((((Util.isCube(player.worldObj.getBlock(x, y, z - 1)) && heading == 2)
                  || (Util.isCube(player.worldObj.getBlock(x, y, z + 1)) && heading == 0)
                  || (Util.isCube(player.worldObj.getBlock(x - 1, y, z)) && heading == 1)
                  || (Util.isCube(player.worldObj.getBlock(x + 1, y, z)) && heading == 3))
              && ((!Util.isCube(player.worldObj.getBlock(x, y + 1, z - 1)) && heading == 2)
                  || (!Util.isCube(player.worldObj.getBlock(x, y + 1, z + 1)) && heading == 0)
                  || (!Util.isCube(player.worldObj.getBlock(x - 1, y + 1, z)) && heading == 1)
                  || (!Util.isCube(player.worldObj.getBlock(x + 1, y + 1, z)) && heading == 3))
              && (!Util.isCube(player.worldObj.getBlock(x, y - 2, z)))))
          && player.worldObj.getBlock(x, y, z) != Blocks.ladder
          && player.getCurrentEquippedItem() == null) {
        playerCustom.isGrabbing = true;
        playerCustom.rotationYaw = player.rotationYaw;
        playerCustom.rotationPitch = player.rotationPitch;
        playerCustom.prevRotationPitch = player.prevRotationPitch;
        playerCustom.prevRotationYaw = player.prevRotationYaw;
        playerCustom.grabbingDirections[heading] = true;
        if (heading == 0) {
          playerCustom.grabbingDirections[3] = true;
        } else {
          playerCustom.grabbingDirections[heading - 1] = true;
        }

        if (heading == 3) {
          playerCustom.grabbingDirections[0] = true;
        } else {
          playerCustom.grabbingDirections[heading + 1] = true;
        }
      } else {
        playerCustom.isGrabbing = false;
        playerCustom.rotationYaw = 0;
        if (!playerCustom.isRolling) {
          playerCustom.rotationPitch = 0;
        }
        playerCustom.prevRotationPitch = 0;
        playerCustom.prevRotationYaw = 0;
        playerCustom.grabbingDirections[0] = false;
        playerCustom.grabbingDirections[1] = false;
        playerCustom.grabbingDirections[2] = false;
        playerCustom.grabbingDirections[3] = false;
      }
      if (playerCustom.isGrabbing && !playerCustom.wasSneaking && player.isSneaking()) {
        playerCustom.wasSneaking = true;
      }
      if (!playerCustom.isGrabbing) {
        playerCustom.wasSneaking = false;
      }
      if (playerCustom.wasSneaking) {
        return;
      }
      if (!player.isSneaking()
          && !(Boolean)
              ObfuscationReflectionHelper.getPrivateValue(
                  EntityLivingBase.class, (EntityLivingBase) player, 41)
          && playerCustom.isGrabbing) {
        if (heading == 1 || heading == 3) {
          player.setPosition(x + 0.5F, y + 0.9F, player.posZ);
          player.motionX = 0;
        }
        if (heading == 2 || heading == 0) {
          player.setPosition(player.posX, y + 0.9F, z + 0.5F);
          player.motionZ = 0;
        }
        player.motionY = 0.0;
        if (player.isSprinting()) {
          player.setSprinting(false);
        }
      } else if ((Boolean)
              ObfuscationReflectionHelper.getPrivateValue(
                  EntityLivingBase.class, (EntityLivingBase) player, 41)
          && playerCustom.isGrabbing) {
        player.motionY = 0.55D;
      }
    }

    //		if(side == Side.CLIENT){
    ////			Util.channel.sendToServer(new CPacketPlayerAction(playerCustom.isGrabbing ? 0 : 1));
    //		}
    //
    //		if(side == Side.SERVER){
    //			System.out.println("1 : " + playerCustom.isGrabbing);
    //		}
    /*    CLIENT    */
    if (!player.worldObj.isRemote) {
      if (playerCustom.isGrabbing && !player.capabilities.isCreativeMode) {
        PotionEffect potioneffect = player.getActivePotionEffect(Potion.jump);
        float f1 = potioneffect != null ? (float) (potioneffect.getAmplifier() + 1) : 0.0F;
        int i = MathHelper.ceiling_float_int(player.fallDistance - 3.0F - f1);
        if (i > 0) {
          player.playSound(
              i > 4 ? "game.neutral.hurt.fall.big" : "game.neutral.hurt.fall.small", 1.0F, 1.0F);
          damageEntity(EntityLivingBase.class, player, DamageSource.fall, (float) i);
        }
        player.fallDistance = 0;
      }
    }
  }
  @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));
        }
      }
    }
  }
  public ItemStack onItemRightClick(
      ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) {
    if (!par2World.isRemote) {
      if (par1ItemStack.getTagCompound() == null)
        par1ItemStack.setTagCompound(new NBTTagCompound());

      dimensionIn = par2World.provider.dimensionId;
      NBTTagCompound tag = par1ItemStack.getTagCompound();
      this.currentCharge = tag.getInteger("CurrentCharge");
      state = tag.getBoolean("state");
      isSet = tag.getBoolean("isSet");
      x = tag.getInteger("posX");
      y = tag.getInteger("posY");
      z = tag.getInteger("posZ");

      if (par3EntityPlayer.isSneaking() && !par2World.isRemote) {
        if (state == false) {

          par3EntityPlayer.addChatMessage("Recall Mode Activated");
          state = true;
          tag.setBoolean("state", state);
          return par1ItemStack;
        }
        if (state == true) {
          par3EntityPlayer.addChatMessage("Mark Mode Activated");
          state = false;
          tag.setBoolean("state", state);
          return par1ItemStack;
        }
      }
      if (!par3EntityPlayer.isSneaking()) {
        if (this.currentCharge < 100) {
          par3EntityPlayer.addChatMessage("Not enough charge.");

          return par1ItemStack;
        }
        if (this.currentCharge >= 100) {

          if (state == false) {

            if (isSet == true) {
              World otherWorld =
                  MinecraftServer.getServer().worldServerForDimension(tag.getInteger("Dimension"));
              otherWorld.setBlock(
                  tag.getInteger("posX"), tag.getInteger("posY"), tag.getInteger("posZ"), 0);
              this.x = (int) par3EntityPlayer.posX;
              this.y = (int) par3EntityPlayer.posY;
              this.z = (int) par3EntityPlayer.posZ;
              par2World.setBlock(x, y, z, MysticAdditions.markblockid);
              this.currentCharge -= 100;

              tag.setInteger("CurrentCharge", this.currentCharge);
            }
            if (isSet == false) {

              this.x = (int) par3EntityPlayer.posX;
              this.y = (int) par3EntityPlayer.posY;
              this.z = (int) par3EntityPlayer.posZ;
              par2World.setBlock(x, y, z, MysticAdditions.markblockid);
              this.currentCharge -= 100;

              tag.setInteger("CurrentCharge", this.currentCharge);

              isSet = true;
              tag.setBoolean("isSet", isSet);
            }

            tag.setInteger("posX", x);
            tag.setInteger("posY", y);
            tag.setInteger("posZ", z);
            tag.setInteger("Dimension", par2World.provider.dimensionId);
            this.setItemDamageByCharge(par1ItemStack);
            return par1ItemStack;
          }
          if (state == true) {
            if (x == 0 && y == 0 && z == 0) {
              return par1ItemStack;
            }
            par3EntityPlayer.travelToDimension(tag.getInteger("Dimension"));
            par3EntityPlayer.setPositionAndUpdate(x, y, z);
            par3EntityPlayer.fallDistance = 0;
            this.currentCharge -= 100;

            tag.setInteger("CurrentCharge", this.currentCharge);
            this.setItemDamageByCharge(par1ItemStack);
            return par1ItemStack;
          }
        }
      }
    }
    return par1ItemStack;
  }
Ejemplo n.º 14
0
  public void updateTask() {
    if (!theDigimon.worldObj.isRemote
        && theDigimon.riddenByEntity != null
        && theDigimon.riddenByEntity instanceof EntityPlayer) {
      rider = (EntityPlayer) theDigimon.riddenByEntity;
      theDigimon.moveForward = 0.0F;
      theDigimon.moveStrafing = 0.0F;
      theDigimon.isJumping = false;
      theDigimon.running = false;
      rider.fallDistance = 0.0F;
      theDigimon.prevRotationYaw =
          theDigimon.rotationYaw = theDigimon.rotationYawHead = rider.rotationYaw;
      float f = (float) Math.PI;
      float f1 = f / 180F;

      if (rider.moveForward > 0.1F) {
        float f2 = rider.rotationYaw * f1;
        theDigimon.motionX += (double) rider.moveForward * -Math.sin(f2) * spd;
        theDigimon.motionZ += (double) rider.moveForward * Math.cos(f2) * spd;
        theDigimon.running = true;

        if (!rider.isJumping && canFly) {
          theDigimon.motionY = -0.05D;
        }
      } else if (rider.moveForward < -0.1F) {
        float f3 = rider.rotationYaw * f1;
        theDigimon.motionX += (double) rider.moveForward * -Math.sin(f3) * spd;
        theDigimon.motionZ += (double) rider.moveForward * Math.cos(f3) * spd;
        theDigimon.running = true;

        if (!rider.isJumping && canFly) {
          theDigimon.motionY = -0.05D;
        }
      }

      theDigimon.rotationYaw -= rider.moveStrafing * 5F;

      if (theDigimon.deepness() != 0) {
        theDigimon.motionY = 0.5D;
      }

      if (canFly) {
        if (rider.isJumping && theDigimon.posY < worldMax) {
          theDigimon.motionY = motion;
        }

        if (--timer < 0) {
          theDigimon.motionY -= 0.1D;
        }

        if (theDigimon.toGround() < minDis) {
          theDigimon.motionY = 0.2D;
        }

        if (theDigimon.onGround || theDigimon.toGround() == minDis) {
          timer = maxTime;
        }
      } else if (rider.isJumping && theDigimon.onGround) {
        theDigimon.motionY = motion;
      }

      double d =
          Math.abs(
              Math.sqrt(
                  theDigimon.motionX * theDigimon.motionX
                      + theDigimon.motionZ * theDigimon.motionZ));

      if (d > 0.375D) {
        double d1 = 0.375D / d;
        theDigimon.motionX = theDigimon.motionX * d1;
        theDigimon.motionZ = theDigimon.motionZ * d1;
      }
    }
  }
Ejemplo n.º 15
0
  @Override
  public ItemStack onItemRightClick(
      ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) {
    PropertyDoom doom = PropertyDoom.get(par3EntityPlayer);

    if (!par3EntityPlayer.isSneaking()
        || !TragicWeapon.canUseAbility(doom, TragicConfig.doomAbilityCost[5])) {
      ArrowNockEvent event = new ArrowNockEvent(par3EntityPlayer, par1ItemStack);
      MinecraftForge.EVENT_BUS.post(event);
      if (event.isCanceled()) return event.result;

      if (par3EntityPlayer.capabilities.isCreativeMode
          || par3EntityPlayer.inventory.hasItem(Items.arrow)) {
        par3EntityPlayer.setItemInUse(par1ItemStack, this.getMaxItemUseDuration(par1ItemStack));
      }
    } else {
      if (TragicWeapon.getStackCooldown(par1ItemStack) == 0 && TragicConfig.doomAbility[8]) {
        float f = 1.0F;
        float f1 =
            par3EntityPlayer.prevRotationPitch
                + (par3EntityPlayer.rotationPitch - par3EntityPlayer.prevRotationPitch) * f;
        float f2 =
            par3EntityPlayer.prevRotationYaw
                + (par3EntityPlayer.rotationYaw - par3EntityPlayer.prevRotationYaw) * f;
        double d0 =
            par3EntityPlayer.prevPosX + (par3EntityPlayer.posX - par3EntityPlayer.prevPosX) * f;
        double d1 =
            par3EntityPlayer.prevPosY
                + (par3EntityPlayer.posY - par3EntityPlayer.prevPosY) * f
                + (par3EntityPlayer.worldObj.isRemote
                    ? par3EntityPlayer.getEyeHeight() - par3EntityPlayer.getDefaultEyeHeight()
                    : par3EntityPlayer
                        .getEyeHeight()); // isRemote check to revert changes to ray trace position
        // due to adding the eye height clientside and player
        // yOffset differences
        double d2 =
            par3EntityPlayer.prevPosZ + (par3EntityPlayer.posZ - par3EntityPlayer.prevPosZ) * f;
        Vec3 vec3 = Vec3.createVectorHelper(d0, d1, d2);
        float f3 = MathHelper.cos(-f2 * 0.017453292F - (float) Math.PI);
        float f4 = MathHelper.sin(-f2 * 0.017453292F - (float) Math.PI);
        float f5 = -MathHelper.cos(-f1 * 0.017453292F);
        float f6 = MathHelper.sin(-f1 * 0.017453292F);
        float f7 = f4 * f5;
        float f8 = f3 * f5;
        double d3 = 50.0D;

        if (par3EntityPlayer instanceof EntityPlayerMP) {
          d3 =
              ((EntityPlayerMP) par3EntityPlayer).theItemInWorldManager.getBlockReachDistance()
                  + 46.0;
        }

        Vec3 vec31 = vec3.addVector(f7 * d3, f6 * d3, f8 * d3);
        MovingObjectPosition mop =
            par3EntityPlayer.worldObj.func_147447_a(vec3, vec31, true, false, true);

        if (mop == null) {
          if (!par2World.isRemote)
            par3EntityPlayer.addChatMessage(new ChatComponentText("Out of range to teleport to!"));
          return par1ItemStack;
        }

        if (mop.typeOfHit == MovingObjectType.BLOCK
            && par3EntityPlayer instanceof EntityPlayerMP
            && ((EntityPlayerMP) par3EntityPlayer)
                .playerNetServerHandler
                .func_147362_b()
                .isChannelOpen()) {
          if (par3EntityPlayer.isRiding()) par3EntityPlayer.mountEntity((Entity) null);

          double d4 = WorldHelper.getXPositionFromSide(mop.sideHit, mop.hitVec.xCoord);
          double d5 = WorldHelper.getYPositionFromSide(mop.sideHit, mop.hitVec.yCoord);
          double d6 = WorldHelper.getZPositionFromSide(mop.sideHit, mop.hitVec.zCoord);

          par3EntityPlayer.setPositionAndUpdate(d4, d5, d6);
          par3EntityPlayer.fallDistance = 0.0F;
          if (!par3EntityPlayer.capabilities.isCreativeMode)
            doom.increaseDoom(-TragicConfig.doomAbilityCost[8]);
          TragicWeapon.setStackCooldown(par1ItemStack, 5);
        }
      }
    }
    return par1ItemStack;
  }