Package org.spout.api.entity

Examples of org.spout.api.entity.Player


  }

  @CommandDescription (aliases = {"kill"}, usage = "[player]", desc = "Kill yourself or another player")
  @Permissible ("vanilla.command.kill")
  public void kill(CommandSource source, CommandArguments args) throws CommandException {
    Player player = args.popPlayerOrMe("player", source);
    args.assertCompletelyParsed();

    Health health = player.get(Health.class);
    if (health == null) {
      throw new CommandException(player.getDisplayName() + " can not be killed.");
    }
    health.kill(HealthChangeCause.COMMAND);
  }
View Full Code Here


  @Permissible ("vanilla.command.biome")
  @Filter (PlayerFilter.class)
  public void getBiomeName(CommandSource source, CommandArguments args) throws CommandException {
    args.assertCompletelyParsed();

    Player player = (Player) source;
    if (!(player.getPhysics().getPosition().getWorld().getGenerator() instanceof BiomeGenerator)) {
      throw new CommandException("This map does not appear to have any biome data.");
    }
    Point pos = player.getPhysics().getPosition();
    Biome biome = pos.getWorld().getBiome(pos.getBlockX(), pos.getBlockY(), pos.getBlockZ());
    source.sendMessage(plugin.getPrefix() + ChatStyle.GREEN + "Current biome: " + ChatStyle.WHITE + (biome != null ? biome.getName() : "none"));
  }
View Full Code Here

    }
    args.assertCompletelyParsed();

    String name = command.getName();
    if (name.startsWith("quickbar_")) {
      Player player = (Player) source;
      PlayerInventory inventory = player.get(PlayerInventory.class);
      if (inventory != null) {
        QuickbarInventory quickbar = inventory.getQuickbar();
        HUD hud = player.get(HUD.class);
        int newSlot = quickbar.getSelectedSlot().getIndex();
        if (name.endsWith("left")) {
          newSlot++;
          if (newSlot > 8) {
            newSlot = 0;
View Full Code Here

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

public class EntityMetadataHandler extends MessageHandler<EntityMetadataMessage> {
  @Override
  public void handleClient(ClientSession session, EntityMetadataMessage message) {
    Player player = session.getPlayer();
    World world = player.getWorld();

    int entityId = message.getEntityId();

    Entity entity = world.getEntity(entityId);
    if (entity == null) {
      player.getEngine().getLogger().warning("EntityMetadataHandler entity doesn't exist");
      return;
    }

    MetadataComponent metadataComponent = entity.get(MetadataComponent.class);
    if (metadataComponent != null) {
View Full Code Here

  }

  // TODO: vanilla input
  @Override
  public void onTick(float dt) {
    Player player = (Player) getOwner();
    Transform ts = player.getPhysics().getTransform();
    PlayerInputState inputState = player.input();
    PhysicsComponent sc = player.getPhysics();

    Vector3f offset = Vector3f.ZERO;
    float speed = 50;
    if (inputState.getForward()) {
      offset = offset.sub(ts.forwardVector().mul(speed * dt));
    }
    if (inputState.getBackward()) {
      offset = offset.add(ts.forwardVector().mul(speed * dt));
    }
    if (inputState.getLeft()) {
      offset = offset.sub(ts.rightVector().mul(speed * dt));
    }
    if (inputState.getRight()) {
      offset = offset.add(ts.rightVector().mul(speed * dt));
    }
    if (inputState.getJump()) {
      offset = offset.add(ts.upVector().mul(speed * dt));
    }
    if (inputState.getCrouch()) {
      offset = offset.sub(ts.upVector().mul(speed * dt));
    }

    player.get(EntityHead.class).setOrientation(Quaternionf.fromAxesAnglesDeg(inputState.pitch(), inputState.yaw(), ts.getRotation().getAxesAngleDeg().getZ()));
    player.getPhysics().translate(offset);
    player.getPhysics().setRotation(Quaternionf.fromAxesAnglesDeg(inputState.pitch(), inputState.yaw(), ts.getRotation().getAxesAngleDeg().getZ()));
  }
View Full Code Here

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

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

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

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();
    if (message.get() == null) {
      //Taking item from existing slot
      window.setCursorItem(null);
      ClickArguments args = window.getClickArguments(message.getSlot(), ClickArguments.ClickAction.LEFT_CLICK);
      if (args != null) {
View Full Code Here

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

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

    int baseX = message.getX() << Chunk.BLOCKS.BITS;
    int baseZ = message.getZ() << Chunk.BLOCKS.BITS;

    final byte[][] data = message.getData();
View Full Code Here

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

public class BlockBulkHandler extends MessageHandler<BlockBulkMessage> {
  @Override
  public void handleClient(ClientSession session, BlockBulkMessage message) {
    Player player = session.getPlayer();
    World world = player.getWorld();
    RepositionManager rm = player.getNetwork().getRepositionManager();
    int baseX = message.getChunkX() << Chunk.BLOCKS.BITS;
    int baseZ = message.getChunkZ() << Chunk.BLOCKS.BITS;

    for (int i = 0; i < message.getChanges(); i++) {
      int x = rm.convertX(message.getCoordinates()[i * 3] + baseX);
View Full Code Here

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

public class WindowEnchantItemHandler extends MessageHandler<WindowEnchantItemMessage> {
  @Override
  public void handleServer(ServerSession session, WindowEnchantItemMessage message) {
    Player player = session.getPlayer();
    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) {
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.