Package org.spout.vanilla.component.entity.living

Examples of org.spout.vanilla.component.entity.living.Human


    // Figure out what entity to affect
    // Note: this could be put in a method in the Vanilla human component instead
    // This version is rather inaccurate...
    double lastDistanceToEntity = 5.0;
    Point point = player.getPhysics().getPosition();
    Human human = player.get(Human.class);
    Vector3f direction;
    if (human == null) {
      direction = player.getPhysics().getRotation().getDirection();
    } else {
      direction = human.getHead().getLookingAt();
    }
    Entity nearest = null;
    for (double d = 0.0; d <= 50.0; d += 0.25) {
      Point pos = point.add(direction.mul(d));
      Entity near = point.getWorld().getNearestEntity(pos, player, (int) lastDistanceToEntity);
View Full Code Here


    minY = node.MIN_Y.getInt() & (~Chunk.BLOCKS.MASK);
    stepY = node.STEP_Y.getInt() & (~Chunk.BLOCKS.MASK);
    lastY = Integer.MAX_VALUE;

    final ManagedMap data = world.getData();
    final Human human = getOwner().add(Human.class);
    GameMode gamemode = null;
    Difficulty difficulty = data.get(VanillaData.DIFFICULTY);
    Dimension dimension = data.get(VanillaData.DIMENSION);
    WorldType worldType = data.get(VanillaData.WORLD_TYPE);

    if (human != null) {
      gamemode = human.getGameMode();
    }
    getSession().send(new PlayerRespawnMessage(0, difficulty.getId(), gamemode.getId(), 256, worldType.toString()));
    getSession().send(new PlayerRespawnMessage(1, difficulty.getId(), gamemode.getId(), 256, worldType.toString()));
    getSession().send(new PlayerRespawnMessage(dimension.getId(), difficulty.getId(), gamemode.getId(), 256, worldType.toString()));

    if (human != null) {
      human.updateAbilities();
    }

    getSession().send(new PlayerHeldItemChangeMessage(getOwner().add(PlayerInventory.class).getQuickbar().getSelectedSlot().getIndex()));

    // Vanilla Only, MC does not send full inventory update on world change, nor on first connect
View Full Code Here

  public void gamemode(CommandSource source, CommandArguments args) throws CommandException {
    GameMode mode = VanillaArgumentTypes.popGameMode("gamemode", args);
    Player player = args.popPlayerOrMe("player", source);
    args.assertCompletelyParsed();

    Human human = player.get(Human.class);
    if (human == null) {
      throw new CommandException("Invalid player!");
    }

    human.setGamemode(mode);

    if (!player.equals(source)) {
      source.sendMessage(plugin.getPrefix() + ChatStyle.WHITE + player.getName()
          + "'s " + ChatStyle.GREEN + "gamemode has been changed to "
          + ChatStyle.WHITE + mode.name() + ChatStyle.GREEN + ".");
View Full Code Here

  private final boolean canFly;
  private final boolean creativeMode;
  private final Player player;

  public PlayerAbilityUpdateEvent(Player player) {
    Human human = player.get(Human.class);
    if (human == null) {
      throw new IllegalStateException("Cannot call PlayerAbilityChangeEvent for players which don't have the Human component");
    }
    this.player = player;
    flyingSpeed = human.getFlyingSpeed();
    walkingSpeed = human.getWalkingSpeed();
    godMode = human.getGodMode();
    isFlying = human.isFlying();
    canFly = human.canFly();
    creativeMode = human.getGameMode() == GameMode.CREATIVE;
  }
View Full Code Here

public final class EntityActionHandler extends MessageHandler<EntityActionMessage> {
  @Override
  public void handleServer(ServerSession session, EntityActionMessage message) {
    Player player = session.getPlayer();
    Human human = player.get(Human.class);
    List<Parameter<?>> parameters = new ArrayList<Parameter<?>>();
    switch (message.getAction()) {
      case EntityActionMessage.ACTION_CROUCH:

        if (human != null) {
          if (!player.getEngine().getEventManager().callEvent(new PlayerToggleSneakingEvent(player, true)).isCancelled()) {
            human.setSneaking(true);
          }
        }
        break;
      case EntityActionMessage.ACTION_UNCROUCH:
        if (human != null) {
          if (!player.getEngine().getEventManager().callEvent(new PlayerToggleSneakingEvent(player, false)).isCancelled()) {
            human.setSneaking(false);
          }
        }
        break;
      case EntityActionMessage.ACTION_LEAVE_BED:
        player.getNetwork().callProtocolEvent(new EntityAnimationEvent(player, Animation.LEAVE_BED));
        break;
      case EntityActionMessage.ACTION_START_SPRINTING:
        if (human != null) {
          if (!player.getEngine().getEventManager().callEvent(new PlayerToggleSprintingEvent(player, true)).isCancelled()) {
            human.setSprinting(true);
          }
        }
        break;
      case EntityActionMessage.ACTION_STOP_SPRINTING:
        if (human != null) {
          if (!player.getEngine().getEventManager().callEvent(new PlayerToggleSprintingEvent(player, false)).isCancelled()) {
            human.setSprinting(false);
          }
        }
        break;
      default:
        break;
View Full Code Here

public class WindowCreativeActionHandler extends MessageHandler<WindowCreativeActionMessage> {
  @Override
  public void handleServer(ServerSession session, WindowCreativeActionMessage message) {
    Player holder = session.getPlayer();
    Human human = holder.get(Human.class);
    if (human == null) {
      return;
    }
    if (human.isSurvival()) {
      holder.kick("Attempted to use the creative inventory while on survival.");
      return;
    }

    Window window = holder.get(WindowHolder.class).getActiveWindow();
View Full Code Here

    EnchantmentTableWindow window = (EnchantmentTableWindow) player.get(WindowHolder.class).getActiveWindow();
    EnchantmentTableInventory inv = (EnchantmentTableInventory) window.getInventoryConverters().get(2).getInventory();
    int enchantSlot = message.getEnchantment();
    int enchantLevel = window.getEnchantmentLevel(enchantSlot);

    Human human = player.get(Human.class);
    Level level = player.get(Level.class);

    if (human == null || level == null) {
      return;
    }
    if (human.getGameMode() != GameMode.CREATIVE && level.getLevel() < enchantLevel) {
      return;
    }
    if (!Enchantment.addRandomEnchantments(inv.get(), enchantLevel)) {
      return;
    }
    inv.update(EnchantmentTableInventory.SLOT, inv.get());
    if (human.getGameMode() != GameMode.CREATIVE) {
      level.removeLevels(enchantLevel);
    }
  }
View Full Code Here

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);
View Full Code Here

public final class PlayerAbilityHandler extends MessageHandler<PlayerAbilityMessage> {
  @Override
  public void handleServer(ServerSession session, PlayerAbilityMessage message) {
    Player player = session.getPlayer();
    Human human = player.get(Human.class);
    if (human != null) {
      // TODO - this should do a permission check and revert if required
      human.setFlyingSpeed(message.getFlyingSpeed(), false);
      human.setWalkingSpeed(message.getWalkingSpeed(), false);
      human.setFlying(message.isFlying(), false);
      human.setCanFly(message.canFly(), false);
      human.setGodMode(message.isGodMode(), false);
      human.setCreativeMode(message.isCreativeMode(), false);
    }
  }
View Full Code Here

  }

  @Override
  public void handleClient(ClientSession session, PlayerAbilityMessage message) {
    Player player = session.getPlayer();
    Human human = player.get(Human.class);
    if (human != null) {
      // TODO - this should do a permission check and revert if required
      human.setFlyingSpeed(message.getFlyingSpeed(), false);
      human.setWalkingSpeed(message.getWalkingSpeed(), false);
      human.setFlying(message.isFlying(), false);
      human.setCanFly(message.canFly(), false);
      human.setGodMode(message.isGodMode(), false);
      human.setCreativeMode(message.isCreativeMode(), false);
    }
  }
View Full Code Here

TOP

Related Classes of org.spout.vanilla.component.entity.living.Human

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.