Package net.minecraft.inventory

Examples of net.minecraft.inventory.Slot


  }

  @Override
  public ItemStack slotClick(int slotNum, int mouseButton, int modifier, EntityPlayer player)
  {
    Slot slot = slotNum < 0 ? null : (Slot) this.inventorySlots.get(slotNum);
    if (slot instanceof SlotFake)
    {
      return slotClickPhantom(slot, mouseButton, modifier, player);
    }
    return super.slotClick(slotNum, mouseButton, modifier, player);
View Full Code Here


    boolean changed = false;
    if (stackToShift.isStackable())
    {
      for (int slotIndex = start; stackToShift.stackSize > 0 && slotIndex < end; slotIndex++)
      {
        Slot slot = (Slot) inventorySlots.get(slotIndex);
        ItemStack stackInSlot = slot.getStack();
        if (stackInSlot != null && canStacksMerge(stackInSlot, stackToShift))
        {
          int resultingStackSize = stackInSlot.stackSize + stackToShift.stackSize;
          int max = Math.min(stackToShift.getMaxStackSize(), slot.getSlotStackLimit());
          if (resultingStackSize <= max)
          {
            stackToShift.stackSize = 0;
            stackInSlot.stackSize = resultingStackSize;
            slot.onSlotChanged();
            changed = true;
          } else if (stackInSlot.stackSize < max)
          {
            stackToShift.stackSize -= max - stackInSlot.stackSize;
            stackInSlot.stackSize = max;
            slot.onSlotChanged();
            changed = true;
          }
        }
      }
    }
    if (stackToShift.stackSize > 0)
    {
      for (int slotIndex = start; stackToShift.stackSize > 0 && slotIndex < end; slotIndex++)
      {
        Slot slot = (Slot) inventorySlots.get(slotIndex);
        ItemStack stackInSlot = slot.getStack();
        if (stackInSlot == null)
        {
          int max = Math.min(stackToShift.getMaxStackSize(), slot.getSlotStackLimit());
          stackInSlot = stackToShift.copy();
          stackInSlot.stackSize = Math.min(stackToShift.stackSize, max);
          stackToShift.stackSize -= stackInSlot.stackSize;
          slot.putStack(stackInSlot);
          slot.onSlotChanged();
          changed = true;
        }
      }
    }
    return changed;
View Full Code Here

  private boolean tryShiftItem(ItemStack stackToShift, int numSlots)
  {
    for (int machineIndex = 0; machineIndex < numSlots - 9 * 4; machineIndex++)
    {
      Slot slot = (Slot) inventorySlots.get(machineIndex);
      if (slot instanceof SlotFake)
      {
        continue;
      }
      if (!slot.isItemValid(stackToShift))
      {
        continue;
      }
      if (shiftItemStack(stackToShift, machineIndex, machineIndex + 1))
      {
View Full Code Here

  @Override
  public ItemStack transferStackInSlot(EntityPlayer player, int slotIndex)
  {
    ItemStack originalStack = null;
    Slot slot = (Slot) inventorySlots.get(slotIndex);
    int numSlots = inventorySlots.size();
    if (slot != null && slot.getHasStack())
    {
      ItemStack stackInSlot = slot.getStack();
      originalStack = stackInSlot.copy();
      if (slotIndex >= numSlots - 9 * 4 && tryShiftItem(stackInSlot, numSlots))
      {
        // NOOP
      } else if (slotIndex >= numSlots - 9 * 4 && slotIndex < numSlots - 9)
      {
        if (!shiftItemStack(stackInSlot, numSlots - 9, numSlots))
        {
          return null;
        }
      } else if (slotIndex >= numSlots - 9 && slotIndex < numSlots)
      {
        if (!shiftItemStack(stackInSlot, numSlots - 9 * 4, numSlots - 9))
        {
          return null;
        }
      } else if (!shiftItemStack(stackInSlot, numSlots - 9 * 4, numSlots))
      {
        return null;
      }
      slot.onSlotChange(stackInSlot, originalStack);
      if (stackInSlot.stackSize <= 0)
      {
        slot.putStack(null);
      } else
      {
        slot.onSlotChanged();
      }
      if (stackInSlot.stackSize == originalStack.stackSize)
      {
        return null;
      }
      slot.onPickupFromSlot(player, stackInSlot);
    }
    return originalStack;
  }
View Full Code Here

  public static Slot getHoveredSlot(Container container, int mouseX, int mouseY) {
    Utils.debug( "Getting slot at: (%s, %s)", mouseX, mouseY );

    for( int i = 0; i < container.inventorySlots.size(); i++ ) {
      Slot slot = container.getSlot( i );
      if( slot != null ) {
        if( isMouseOverSlot( slot, mouseX, mouseY ) ) {
          return slot;
        }
      }
View Full Code Here

  }

  private boolean matching = false;

  private boolean matchingTarget() {
    Slot outputSlot = player.openContainer.getSlot( 0 );
    if( target == null ) {
      return outputSlot.getHasStack();
    }
    return outputSlot.getHasStack() && InventoryUtils.similarStacks( outputSlot.getStack(), target, false );
  }
View Full Code Here

    }
    return outputSlot.getHasStack() && InventoryUtils.similarStacks( outputSlot.getStack(), target, false );
  }

  private void paintTarget() {
    Slot slot = player.openContainer.getSlot( 0 );

    if( !matching && target != null ) {
      int x = slot.xDisplayPosition, y = slot.yDisplayPosition;

      this.zLevel = 100.0F;
View Full Code Here

    return this.isPointInRegion( slot.xDisplayPosition, slot.yDisplayPosition, dim, dim, mouseX, mouseY );
  }

  public Slot getSlotAt(int x, int y) {
    for( int i = 0; i < this.inventorySlots.inventorySlots.size(); i++ ) {
      Slot slot = (Slot) this.inventorySlots.inventorySlots.get( i );
      if( isMouseOverSlot( slot, x, y ) )
        return slot;
    }
    return null;
  }
View Full Code Here

    if( keyDescription.equals( "xact.clear" ) ) {
      setRecipe( null );

    } else if( keyDescription.equals( "xact.load" ) ) {
      Slot hoveredSlot = GuiUtils.getHoveredSlot( guiLeft, guiTop );

      if( hoveredSlot != null && hoveredSlot.getHasStack() ) {
        ItemStack stackInSlot = hoveredSlot.getStack();
        if( CraftManager.isEncoded( stackInSlot ) ) {
          recipe = RecipeUtils.getRecipe( stackInSlot, GuiUtils.getWorld() );
          if( recipe != null && recipe.isValid() ) {
            setRecipe( recipe );
          }
View Full Code Here

    return color | TRANSPARENCY;
  }

  private int getHoveredRecipe(int mouseX, int mouseY) {
    for( int i = 0; i < 4; i++ ) {
      Slot slot = (Slot) this.inventorySlots.inventorySlots.get( i );

      if( slot != null && slot.getHasStack() ) {
        if( isPointInRegion( slot.xDisplayPosition - 3, slot.yDisplayPosition - 3, 22, 22, mouseX, mouseY ) ) {
          return i;
        }
      }
    }
View Full Code Here

TOP

Related Classes of net.minecraft.inventory.Slot

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.