Package org.spout.vanilla.inventory.block

Examples of org.spout.vanilla.inventory.block.EnchantmentTableInventory


* Component that represents a enchantment table in a world.
*/
public class EnchantmentTable extends ViewedBlockComponent {
  @Override
  public boolean open(Player player) {
    EnchantmentTableInventory inventory = new EnchantmentTableInventory();
    EnchantmentTableOpenEvent event = player.getEngine().getEventManager().callEvent(new EnchantmentTableOpenEvent(this, inventory, player));
    if (!event.isCancelled()) {
      player.get(WindowHolder.class).openWindow(new EnchantmentTableWindow(player, this, inventory));
      return true;
    }
View Full Code Here


        break;
      case DISPENSER:
        player.get(WindowHolder.class).openWindow(new DispenserWindow(player, new DispenserInventory()));
        break;
      case ENCHANTMENT_TABLE:
        player.get(WindowHolder.class).openWindow(new EnchantmentTableWindow(player, null, new EnchantmentTableInventory()));
        break;
      case BREWING_STAND:
        player.get(WindowHolder.class).openWindow(new BrewingStandWindow(player, null, new BrewingStandInventory()));
        break;
      case VILLAGER:
View Full Code Here

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) {
      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

        break;
      case DISPENSER:
        player.get(WindowHolder.class).openWindow(new DispenserWindow(player, new DispenserInventory(), title));
        break;
      case ENCHANTMENT_TABLE:
        player.get(WindowHolder.class).openWindow(new EnchantmentTableWindow(player, new EnchantmentTableInventory(), title));
        break;
      case BREWING_STAND:
        player.get(WindowHolder.class).openWindow(new BrewingStandWindow(player, new BrewingStandInventory(), title));
        break;
      case VILLAGER:
View Full Code Here

TOP

Related Classes of org.spout.vanilla.inventory.block.EnchantmentTableInventory

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.