Examples of BrewingStandInventory


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

    return getData().get(VanillaData.BREWING_STAND_INVENTORY);
  }

  @Override
  public void onTick(float dt) {
    BrewingStandInventory inventory = getInventory();

    // Update brewing stand display with number of output slots filled
    int filledSlots = 0;
    if (inventory.hasOutput()) {
      for (int i = 0; i < 3; i++) {
        if (inventory.getOutput(i) != null) {
          filledSlots++;
        }
      }
    }
    VanillaMaterials.BREWING_STAND_BLOCK.setFilledPotionSlots(getBlock(), filledSlots);

    if (getBrewTime() <= 0) {
      // Try to start brewing
      if (inventory.hasInput() && inventory.hasOutput()) {
        // Ensure the input is able to brew the three output items
        for (int i = 0; i < 3; i++) {
          ItemStack output = inventory.getOutput(i);
          if (output == null) {
            continue;
          }
          if (((PotionReagent) inventory.getInput().getMaterial()).getResult((PotionItem) output.getMaterial()) == null) {
            return;
          }
        }
        input = inventory.getInput(); // Store input just in case it is later removed during the brewing process
        setBrewTime(1);
        inventory.addAmount(BrewingStandInventory.INPUT_SLOT, -1);
      }
    } else {
      // Continue brewing
      float newBrewTime = getBrewTime() + dt;
      if (newBrewTime > BREW_TIME_INCREMENT) {
        // Brewing has finished
        newBrewTime = -1;

        // Set output
        if (inventory.hasOutput()) {
          for (int i = 0; i < 3; i++) {
            ItemStack output = inventory.getOutput(i);
            if (output == null) {
              continue;
            }
            ItemStack result = new ItemStack(((PotionReagent) input.getMaterial()).getResult((PotionItem) output.getMaterial()), 1);

            PotionBrewEvent event = new PotionBrewEvent(this, new MaterialCause(output.getMaterial(), this.getBlock()), input, output, result);

            VanillaPlugin.getInstance().getEngine().getEventManager().callEvent(event);

            if (!event.isCancelled()) {
              inventory.set(i, event.getResult());
            }
          }
        }
      }
      setBrewTime(newBrewTime);
View Full Code Here

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

        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:
        player.get(WindowHolder.class).openWindow(new VillagerWindow(player, new VillagerInventory()));
        break;
      default:
View Full Code Here

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

  }

  @Override
  public boolean onShiftClick(ItemStack item, int slot, Inventory from) {
    if (!(from instanceof BrewingStandInventory)) {
      final BrewingStandInventory inventory = getBrewingStand().getInventory();
      Material material = item.getMaterial();
      if (material instanceof PotionItem) {
        // Put into output slots
        for (int i = 0; i < 3; i++) {
          if (inventory.getOutput(i) == null) {
            inventory.set(i, item);
            from.set(slot, null);
            return true;
          }
        }
      } else if (material instanceof PotionReagent) {
        // Put into input slot
        if (inventory.getInput() == null) {
          inventory.set(BrewingStandInventory.INPUT_SLOT, item);
          from.set(slot, null);
          return true;
        }
      }
    }
View Full Code Here

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

        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:
        player.get(WindowHolder.class).openWindow(new VillagerWindow(player, new VillagerInventory(), title));
        break;
      default:
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.