Package org.spout.api.entity

Examples of org.spout.api.entity.Player


import org.spout.vanilla.protocol.msg.world.block.SignMessage;

public class SignHandler extends MessageHandler<SignMessage> {
  @Override
  public void handleServer(ServerSession session, SignMessage message) {
    Player player = session.getPlayer();
    RepositionManager rmInverse = player.getNetwork().getRepositionManager().getInverse();

    int x = rmInverse.convertX(message.getX());
    int y = rmInverse.convertY(message.getY());
    int z = rmInverse.convertZ(message.getZ());

    Sign sign = player.getWorld().getBlock(x, y, z).get(Sign.class);
    if (sign == null) {
      return;
    }

    String[] text = message.getMessage();
View Full Code Here


    sign.setText(text, new PlayerCause(player));
  }

  @Override
  public void handleClient(ClientSession session, SignMessage message) {
    Player player = session.getPlayer();
    RepositionManager rm = player.getNetwork().getRepositionManager();

    int x = rm.convertX(message.getX());
    int y = rm.convertY(message.getY());
    int z = rm.convertZ(message.getZ());

    Sign sign = player.getWorld().getBlock(x, y, z).get(Sign.class);
    if (sign == null) {
      return;
    }

    String[] text = message.getMessage();
View Full Code Here

import org.spout.vanilla.protocol.msg.world.chunk.ChunkBulkMessage;

public class ChunkBulkHandler extends MessageHandler<ChunkBulkMessage> {
  @Override
  public void handleClient(ClientSession session, ChunkBulkMessage message) {
    Player player = session.getPlayer();
    World world = player.getEngine().getDefaultWorld();//player.getWorld();
    RepositionManager rm = player.getNetwork().getRepositionManager();

    for (int c = 0; c < message.getX().length; c++) {
      int baseX = message.getX()[c] << Chunk.BLOCKS.BITS;
      int baseZ = message.getZ()[c] << Chunk.BLOCKS.BITS;
View Full Code Here

import org.spout.vanilla.protocol.msg.player.PlayerHealthMessage;

public class PlayerHealthHandler extends MessageHandler<PlayerHealthMessage> {
  @Override
  public void handleClient(ClientSession session, PlayerHealthMessage message) {
    Player player = session.getPlayer();

    Health health = player.get(Health.class);
    health.setHealth(message.getHealth(), HealthChangeCause.UNKNOWN);

    Hunger hunger = player.get(Hunger.class);
    hunger.setHunger(message.getFood());
    hunger.setFoodSaturation(message.getFoodSaturation());
  }
View Full Code Here

import org.spout.vanilla.protocol.msg.window.WindowPropertyMessage;

public class WindowPropertyHandler extends MessageHandler<WindowPropertyMessage> {
  @Override
  public void handleClient(ClientSession session, WindowPropertyMessage msg) {
    Player player = session.getPlayer();
    WindowHolder holder = player.get(WindowHolder.class);
    if (holder != null) {
      holder.getActiveWindow().setProperty(msg.getProgressBar(), msg.getValue());
    }
  }
View Full Code Here

import org.spout.math.vector.Vector3f;

public class PlayerInteract extends InteractComponent {
  @Override
  public BlockIterator getAlignedBlocks() {
    Player player = (Player) getOwner();
    Transform ptr = player.get(PlayerHead.class).getHeadTransform();
    Transform tr = new Transform();
    tr.setRotation(Quaternionf.fromRotationTo(Vector3f.FORWARD, ptr.getRotation().getDirection().mul(-1)));
    tr.setPosition(ptr.getPosition());
    return new BlockIterator(player.getWorld(), tr, getRange());
  }
View Full Code Here

  public void handleServer(ServerSession session, PlayerTabCompleteMessage message) {
    String text = message.getText();
    text = text.trim();
    String[] text2 = text.split(" ");

    Player p = ((Server) VanillaPlugin.getInstance().getEngine()).getPlayer(text2[text2.length - 1], false);
    if (p != null) {
      session.send(new PlayerTabCompleteMessage(p.getName()));
    }
  }
View Full Code Here

import org.spout.vanilla.protocol.msg.window.WindowTransactionMessage;

public final class WindowClickHandler extends MessageHandler<WindowClickMessage> {
  @Override
  public void handleServer(ServerSession session, WindowClickMessage message) {
    Player player = session.getPlayer();
    Window window = player.get(WindowHolder.class).getActiveWindow();
    boolean result = false;
    int slot = message.getSlot();
    ClickArguments args = window.getClickArguments(slot, ClickArguments.ClickAction.getAction(message.getMode(), message.getButton()));
    if (args != null) {
      result = window.onClick(args);
View Full Code Here

import org.spout.vanilla.util.PlayerUtil;

public class PlayerUseEntityHandler extends MessageHandler<PlayerUseEntityMessage> {
  @Override
  public void handleServer(ServerSession session, PlayerUseEntityMessage message) {
    Player playerEnt = session.getPlayer();
    Human player = playerEnt.get(Human.class);
    Entity clickedEntity = playerEnt.getWorld().getEntity(message.getTarget());
    if (clickedEntity == null || player == null) {
      return;
    }
    Slot held = PlayerUtil.getHeldSlot(playerEnt);
    if (held == null) {
      return;
    }
    ItemStack holding = held.get();
    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;
View Full Code Here

import org.spout.vanilla.protocol.msg.entity.EntityAnimationMessage;

public final class EntityAnimationHandler extends MessageHandler<EntityAnimationMessage> {
  @Override
  public void handleServer(ServerSession session, EntityAnimationMessage message) {
    Player player = session.getPlayer();

    switch (message.getAnimation()) {
      case SWING_ARM:
        player.getNetwork().callProtocolEvent(new EntityAnimationEvent(player, org.spout.vanilla.data.Animation.SWING_ARM), true);
        break;
      default:
    }
  }
View Full Code Here

TOP

Related Classes of org.spout.api.entity.Player

Copyright © 2018 www.massapicom. 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.