Examples of PlayerInteractEntityEvent


Examples of org.spout.api.event.player.PlayerInteractEntityEvent

  }

  @Override
  public void onInteract(final EntityInteractEvent<?> event) {
    if (event instanceof PlayerInteractEntityEvent) {
      final PlayerInteractEntityEvent pie = (PlayerInteractEntityEvent) event;
      final Player player = (Player) pie.getEntity();
      switch (pie.getAction()) {
        case RIGHT_CLICK:
          final QuickbarInventory playerQuickbar = PlayerUtil.getQuickbar(player);
          if (playerQuickbar == null) {
            return;
          }
View Full Code Here

Examples of org.spout.api.event.player.PlayerInteractEntityEvent

    Material holdingMat = holding == null ? VanillaMaterials.AIR : holding.getMaterial();
    if (holdingMat == null) {
      holdingMat = VanillaMaterials.AIR;
    }
    //TODO VanillaPlayerInteractEntityEvent maybe?
    PlayerInteractEntityEvent event;

    if (message.isPunching()) {
      event = new PlayerInteractEntityEvent(playerEnt, clickedEntity, clickedEntity.getPhysics().getPosition(), Action.LEFT_CLICK);
      if (Spout.getEventManager().callEvent(event).isCancelled()) {
        return;
      }
      holdingMat.onInteract(playerEnt, clickedEntity, Action.LEFT_CLICK);
      clickedEntity.interact(event);

      if (clickedEntity.get(Human.class) != null && !VanillaConfiguration.PLAYER_PVP_ENABLED.getBoolean()) {
        return;
      }

      Living clicked = clickedEntity.get(Living.class);
      if (clicked != null) {
        //TODO: Reimplement exhaustion values

        int damage = 1;
        if (holding != null && holdingMat instanceof VanillaMaterial) {
          damage = ((VanillaMaterial) holdingMat).getDamage();
          if (holdingMat instanceof Tool) {
            // This is a bit of a hack due to the way Tool hierarchy is now (Only Swords can have a damage modifier, but Sword must be an interface and therefore is not able to contain getDamageModifier without code duplication)
            damage += ((Tool) holdingMat).getDamageBonus(clickedEntity, holding);
            //            player.getInventory().getQuickbar().getCurrentSlotInventory().addData(1); TODO: Reimplement durability change
          }
        }

        //Potion modification
        if (holdingMat.equals(VanillaMaterials.AIR)) {
          Effects effect = playerEnt.add(Effects.class);
          if (effect.contains(EntityEffectType.STRENGTH)) {
            damage += 3;
          }
          if (effect.contains(EntityEffectType.WEAKNESS)) {
            damage -= 2;
          }
        }
        //END Potion modification

        // Damage the clicked entity
        if (damage > 0 && !PlayerUtil.isCreativePlayer(clickedEntity) && !clicked.getHealth().isDead()) {
          clicked.getHealth().damage(damage, new PlayerDamageCause(playerEnt, DamageType.ATTACK), damage > 0);
        }
      }
    } else {
      event = new PlayerInteractEntityEvent(playerEnt, clickedEntity, clickedEntity.getPhysics().getPosition(), Action.LEFT_CLICK);
      if (Spout.getEventManager().callEvent(event).isCancelled()) {
        return;
      }
      holdingMat.onInteract(playerEnt, clickedEntity, Action.RIGHT_CLICK);
      clickedEntity.interact(event);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.