Examples of Slot


Examples of net.minecraft.inventory.Slot

  }

  @Override
  public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par2) {
    ItemStack var3 = null;
    Slot var4 = (Slot) inventorySlots.get(par2);

    if (var4 != null && var4.getHasStack()) {
      ItemStack var5 = var4.getStack();

      if (var5.getItem() instanceof ItemSoulMould) {
        var3 = var5.copy();

        if (par2 < 1) {
          if (!mergeItemStack(var5, 1, 37, false))
            return null;
        } else if (!mergeItemStack(var5, 0, 1, false))
          return null;

        if (var5.stackSize == 0)
          var4.putStack(null);
        else
          var4.onSlotChanged();

        if (var5.stackSize == var3.stackSize)
          return null;

        var4.onPickupFromSlot(par1EntityPlayer, var5);
      }
    }

    return var3;
  }
View Full Code Here

Examples of net.minecraft.inventory.Slot

    boolean successful = false;
    int i = !r ? start : length - 1;
    int iterOrder = !r ? 1 : -1;

    Slot slot;
    ItemStack existingStack;

    if (stack.isStackable()) {
      while (stack.stackSize > 0 && (!r && i < length || r && i >= start)) {
        slot = slots.get(i);
        existingStack = slot.getStack();

        if (slot.isItemValid(stack) && existingStack != null && existingStack.getItem().equals(stack.getItem())
            && (!stack.getHasSubtypes() || stack.getItemDamage() == existingStack.getItemDamage())
            && ItemStack.areItemStackTagsEqual(stack, existingStack)) {
          int existingSize = existingStack.stackSize + stack.stackSize;
          int maxStack = Math.min(stack.getMaxStackSize(), slot.getSlotStackLimit());

          if (existingSize <= maxStack) {
            stack.stackSize = 0;
            existingStack.stackSize = existingSize;
            slot.onSlotChanged();
            successful = true;
          } else if (existingStack.stackSize < maxStack) {
            stack.stackSize -= maxStack - existingStack.stackSize;
            existingStack.stackSize = maxStack;
            slot.onSlotChanged();
            successful = true;
          }
        }

        i += iterOrder;
      }
    }

    if (stack.stackSize > 0) {
      i = !r ? start : length - 1;

      while (stack.stackSize > 0 && (!r && i < length || r && i >= start)) {
        slot = slots.get(i);
        existingStack = slot.getStack();

        if (slot.isItemValid(stack) && existingStack == null) {
          int maxStack = limit ? Math.min(stack.getMaxStackSize(), slot.getSlotStackLimit()) : slot.getSlotStackLimit();
          existingStack = stack.splitStack(Math.min(stack.stackSize, maxStack));
          slot.putStack(existingStack);
          slot.onSlotChanged();
          successful = true;
        }

        i += iterOrder;
      }
View Full Code Here

Examples of net.minecraft.src.Slot

        }
    for(int a = 0; a < 2; a++)
        {
          for(int i = 0; i < 9; i++)
            {
                addSlot(new Slot(theTile, i + (a*9), 8 + i * 18, 112 + (18*a)));
            }
        }

        for(int j = 0; j < 3; j++)
        {
            for(int i1 = 0; i1 < 9; i1++)
            {
                addSlot(new Slot(thePlayer.inventory, i1 + j * 9 + 9, 8 + i1 * 18, 152 + j * 18));
            }
        }
       
        for(int i3 = 0; i3 < 9; i3++)
        {
            addSlot(new Slot(thePlayer.inventory, i3, 8 + i3 * 18, 211));
        }
       
       
        if (mod_CraftingTableIII.RecipeType == 0)
        {
View Full Code Here

Examples of org.apache.hadoop.hdfs.ShortCircuitShm.Slot

    while (true) {
      curPeer = nextDomainPeer();
      if (curPeer == null) break;
      if (curPeer.fromCache) remainingCacheTries--;
      DomainPeer peer = (DomainPeer)curPeer.peer;
      Slot slot = null;
      ShortCircuitCache cache = clientContext.getShortCircuitCache();
      try {
        MutableBoolean usedPeer = new MutableBoolean(false);
        slot = cache.allocShmSlot(datanode, peer, usedPeer,
            new ExtendedBlockId(block.getBlockId(), block.getBlockPoolId()),
View Full Code Here

Examples of org.apache.hadoop.hdfs.shortcircuit.ShortCircuitShm.Slot

        factory.createDescriptor("testAllocateSlots", 4096);
    ShortCircuitShm shm = new ShortCircuitShm(ShmId.createRandom(), stream);
    int numSlots = 0;
    ArrayList<Slot> slots = new ArrayList<Slot>();
    while (!shm.isFull()) {
      Slot slot = shm.allocAndRegisterSlot(new ExtendedBlockId(123L, "test_bp1"));
      slots.add(slot);
      numSlots++;
    }
    LOG.info("allocated " + numSlots + " slots before running out.");
    int slotIdx = 0;
    for (Iterator<Slot> iter = shm.slotIterator();
        iter.hasNext(); ) {
      Assert.assertTrue(slots.contains(iter.next()));
    }
    for (Slot slot : slots) {
      Assert.assertFalse(slot.addAnchor());
      Assert.assertEquals(slotIdx++, slot.getSlotIdx());
    }
    for (Slot slot : slots) {
      slot.makeAnchorable();
    }
    for (Slot slot : slots) {
      Assert.assertTrue(slot.addAnchor());
    }
    for (Slot slot : slots) {
      slot.removeAnchor();
    }
    for (Slot slot : slots) {
      shm.unregisterSlot(slot.getSlotIdx());
      slot.makeInvalid();
    }
    shm.free();
    stream.close();
    FileUtil.fullyDelete(path);
  }
View Full Code Here

Examples of org.apache.hadoop.hdfs.shortcircuit.ShortCircuitShm.Slot

    RegisteredShm removedShm = segments.remove(shm.getShmId());
    Preconditions.checkState(removedShm == shm,
        "failed to remove " + shm.getShmId());
    // Stop tracking the slots.
    for (Iterator<Slot> iter = shm.slotIterator(); iter.hasNext(); ) {
      Slot slot = iter.next();
      boolean removed = slots.remove(slot.getBlockId(), slot);
      Preconditions.checkState(removed);
      slot.makeInvalid();
    }
    // De-allocate the memory map and close the shared file.
    shm.free();
  }
View Full Code Here

Examples of org.apache.hadoop.hdfs.shortcircuit.ShortCircuitShm.Slot

    RegisteredShm shm = segments.get(shmId);
    if (shm == null) {
      throw new InvalidRequestException("there is no shared memory segment " +
          "registered with shmId " + shmId);
    }
    Slot slot = shm.registerSlot(slotId.getSlotIdx(), blockId);
    if (isCached) {
      slot.makeAnchorable();
    } else {
      slot.makeUnanchorable();
    }
    boolean added = slots.put(blockId, slot);
    Preconditions.checkState(added);
    if (LOG.isTraceEnabled()) {
      LOG.trace(this + ": registered " + blockId + " with slot " +
View Full Code Here

Examples of org.apache.hadoop.hdfs.shortcircuit.ShortCircuitShm.Slot

    RegisteredShm shm = segments.get(shmId);
    if (shm == null) {
      throw new InvalidRequestException("there is no shared memory segment " +
          "registered with shmId " + shmId);
    }
    Slot slot = shm.getSlot(slotId.getSlotIdx());
    slot.makeInvalid();
    shm.unregisterSlot(slotId.getSlotIdx());
    slots.remove(slot.getBlockId(), slot);
  }
View Full Code Here

Examples of org.apache.hadoop.hdfs.shortcircuit.ShortCircuitShm.Slot

    MutableBoolean usedPeer = new MutableBoolean(false);
    ExtendedBlockId blockId = new ExtendedBlockId(123, "xyz");
    final DatanodeInfo datanode =
        new DatanodeInfo(cluster.getDataNodes().get(0).getDatanodeId());
    // Allocating the first shm slot requires using up a peer.
    Slot slot = cache.allocShmSlot(datanode, peer, usedPeer,
                    blockId, "testAllocShm_client");
    Assert.assertNotNull(slot);
    Assert.assertTrue(usedPeer.booleanValue());
    cache.getDfsClientShmManager().visit(new Visitor() {
      @Override
View Full Code Here

Examples of org.apache.hadoop.hdfs.shortcircuit.ShortCircuitShm.Slot

        return null;
      }
      Entry<ShmId, DfsClientShm> entry = notFull.firstEntry();
      DfsClientShm shm = entry.getValue();
      ShmId shmId = shm.getShmId();
      Slot slot = shm.allocAndRegisterSlot(blockId);
      if (shm.isFull()) {
        if (LOG.isTraceEnabled()) {
          LOG.trace(this + ": pulled the last slot " + slot.getSlotIdx() +
              " out of " + shm);
        }
        DfsClientShm removedShm = notFull.remove(shmId);
        Preconditions.checkState(removedShm == shm);
        full.put(shmId, shm);
      } else {
        if (LOG.isTraceEnabled()) {
          LOG.trace(this + ": pulled slot " + slot.getSlotIdx() +
              " out of " + shm);
        }
      }
      return slot;
    }
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.