Java 类net.minecraft.inventory.Slot 实例源码

项目:pnc-repressurized    文件:ContainerProgrammer.java   
public ContainerProgrammer(InventoryPlayer inventoryPlayer, TileEntityProgrammer te) {
    super(te);

    addSlotToContainer(new SlotItemHandler(te.getPrimaryInventory(), 0, 326, 15) {
        @Override
        public boolean isItemValid(@Nonnull ItemStack stack) {
            return isProgrammableItem(stack);
        }
    });

    // Add the player's inventory slots to the container
    for (int inventoryRowIndex = 0; inventoryRowIndex < 3; ++inventoryRowIndex) {
        for (int inventoryColumnIndex = 0; inventoryColumnIndex < 9; ++inventoryColumnIndex) {
            addSlotToContainer(new Slot(inventoryPlayer, inventoryColumnIndex + inventoryRowIndex * 9 + 9, 95 + inventoryColumnIndex * 18, 174 + inventoryRowIndex * 18));
        }
    }

    // Add the player's action bar slots to the container
    for (int actionBarSlotIndex = 0; actionBarSlotIndex < 9; ++actionBarSlotIndex) {
        addSlotToContainer(new Slot(inventoryPlayer, actionBarSlotIndex, 95 + actionBarSlotIndex * 18, 232));
    }
}
项目:Mods    文件:ContainerAmmoFurnace.java   
public ContainerAmmoFurnace(InventoryPlayer playerInventory, IInventory furnaceInventory) {
    this.tileFurnace = furnaceInventory;
    for (int i = 0; i < 9; i++)
        this.addSlotToContainer(new Slot(furnaceInventory, i, 9 + (i % 3) * 18, 17 + (i / 3) * 18));
    this.addSlotToContainer(new SlotFurnaceFuel(furnaceInventory, 9, 80, 53));
    for (int i = 0; i < 9; i++)
        this.addSlotToContainer(new SlotFurnaceOutput(playerInventory.player, furnaceInventory, i + 10,
                116 + (i % 3) * 18, 17 + (i / 3) * 18));

    for (int i = 0; i < 3; ++i)
        for (int j = 0; j < 9; ++j)
            this.addSlotToContainer(new Slot(playerInventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));

    for (int k = 0; k < 9; ++k)
        this.addSlotToContainer(new Slot(playerInventory, k, 8 + k * 18, 142));
}
项目:Firma    文件:PlayerInv.java   
public static void buildInventoryLayout(Container container, InventoryPlayer inventory, int x, int y, boolean freezeSlot, boolean toolBarAfterMainInv)
{
    int index = 0;
    if(!toolBarAfterMainInv)
        addToolbarSlots(container, inventory, x, y, freezeSlot);

    for(int i = 0; i < 3; ++i)
    {
        for(int k = 0; k < 9; ++k)
        {
            index =  k + (i+1) * 9;
            addSlotToContainer(container, new Slot(inventory, index, x + k * 18, y + i * 18));
        }
    }

    if(toolBarAfterMainInv)
        addToolbarSlots(container, inventory, x, y, freezeSlot);
}
项目:Bewitchment    文件:ContainerOven.java   
public ContainerOven(IInventory playerInventory, TileOven te) {
    this.oven = te;
    //input slot
    this.addSlotToContainer(new Slot(oven.inventory, 0, 19, 17));
    //fuel slot
    this.addSlotToContainer(new FilteredSlot(oven.inventory, 1, 19, 53, net.minecraft.tileentity.TileEntityFurnace::isItemFuel));
    //jar slot
    this.addSlotToContainer(new FilteredSlot(oven.inventory, 2, 69, 53, s -> s.getItem() == ModItems.fume && s.getMetadata() == 1));
    //fume slot
    this.addSlotToContainer(new OutputSlot(oven.inventory, 3, 128, 53));
    //output slot
    this.addSlotToContainer(new OutputSlot(oven.inventory, 4, 124, 21));

    for (int i = 0; i < 3; ++i) {
        for (int j = 0; j < 9; ++j) {
            this.addSlotToContainer(new Slot(playerInventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
        }
    }

    for (int k = 0; k < 9; ++k) {
        this.addSlotToContainer(new Slot(playerInventory, k, 8 + k * 18, 142));
    }
}
项目:BaseClient    文件:GuiContainerCreative.java   
public ContainerCreative(EntityPlayer p_i1086_1_)
{
    InventoryPlayer inventoryplayer = p_i1086_1_.inventory;

    for (int i = 0; i < 5; ++i)
    {
        for (int j = 0; j < 9; ++j)
        {
            this.addSlotToContainer(new Slot(GuiContainerCreative.field_147060_v, i * 9 + j, 9 + j * 18, 18 + i * 18));
        }
    }

    for (int k = 0; k < 9; ++k)
    {
        this.addSlotToContainer(new Slot(inventoryplayer, k, 9 + k * 18, 112));
    }

    this.scrollTo(0.0F);
}
项目:GardenStuff    文件:ContainerBloomeryFurnace.java   
public ContainerBloomeryFurnace (InventoryPlayer playerInventory, IInventory containerInventory) {
    this.tile = containerInventory;

    primarySlot = addSlotToContainer(new Slot(tile, 0, 56, 17));
    secondarySlot = addSlotToContainer(new Slot(tile, 1, 35, 17));
    fuelSlot = addSlotToContainer(new Slot(tile, 2, 56, 53));

    outputSlot = addSlotToContainer(new SlotBloomeryOutput(playerInventory.player, tile, 3, 116, 35));

    playerSlots = new ArrayList<>();
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 9; j++)
            playerSlots.add(addSlotToContainer(new Slot(playerInventory, j + i * 9 + 9, InventoryX + j * 18, InventoryY + i * 18)));
    }

    hotbarSlots = new ArrayList<>();
    for (int i = 0; i < 9; i++)
        hotbarSlots.add(addSlotToContainer(new Slot(playerInventory, i, InventoryX + i * 18, HotbarY)));
}
项目:ElementalElaboration    文件:ContainerTileCustomMachine.java   
public ContainerTileCustomMachine(IInventory playerInv, TileCustomMachine tileEntity)
{
    super(0,3, 4,40);
    setTileEntity(tileEntity);

    CustomMachineSlot slotFirst = new CustomMachineSlot((ISidedInventory) tileEntity, 0, 52, 16);
    CustomMachineSlot slotSecond = new CustomMachineSlot((ISidedInventory) tileEntity, 1, 80, 16);
    CustomMachineSlot slotThird = new CustomMachineSlot((ISidedInventory) tileEntity, 2, 107, 16);
    CustomMachineSlot slotOut = new CustomMachineSlot((ISidedInventory) tileEntity, 3, 80, 46);

    // Tile Entity, Slot 0-3, Slot IDs 0-3
    this.addSlotToContainer(slotFirst);
    this.addSlotToContainer(slotSecond);
    this.addSlotToContainer(slotThird);

    this.addSlotToContainer(slotOut);

    // Player Inventory, Slot 4-35, Slot IDs 4-35
    for (int y = 0; y < 3; ++y)
        for (int x = 0; x < 9; ++x)
            this.addSlotToContainer(new Slot(playerInv, x + y * 9 + 9, 8 + x * 18, 84 + y * 18));

    // Player Inventory, Slot 0-8, Slot IDs 36-44
    for (int x = 0; x < 9; ++x)
        this.addSlotToContainer(new Slot(playerInv, x, 8 + x * 18, 142));
}
项目:Defier    文件:DefierContainer.java   
@Override
public ItemStack transferStackInSlot(EntityPlayer playerIn, int index) {
    ItemStack itemstack = ItemStack.EMPTY;
    Slot slot = this.inventorySlots.get(index);

    if (slot != null && slot.getHasStack()) {
        ItemStack itemstack1 = slot.getStack();
        itemstack = itemstack1.copy();

        if (index < 2) {
            if (!this.mergeItemStack(itemstack1, 2, this.inventorySlots.size(), true)) {
                return ItemStack.EMPTY;
            }
        } else if (!this.mergeItemStack(itemstack1, 0, 1, false)) {
            return ItemStack.EMPTY;
        }

        if (itemstack1.isEmpty()) {
            slot.putStack(ItemStack.EMPTY);
        } else {
            slot.onSlotChanged();
        }
    }

    return itemstack;
}
项目:BaseClient    文件:GuiContainer.java   
/**
 * Called when the mouse is clicked over a slot or outside the gui.
 */
protected void handleMouseClick(Slot slotIn, int slotId, int clickedButton, int clickType)
{
    if (slotIn != null)
    {
        slotId = slotIn.slotNumber;
    }

    this.mc.playerController.windowClick(this.inventorySlots.windowId, slotId, clickedButton, clickType, this.mc.thePlayer);
}
项目:rezolve    文件:GuiContainerBase.java   
@Override
protected void mouseReleased(int mouseX, int mouseY, int state) {
    Slot slot = this.getSlotUnderMouse();

    if (slot != null) {
        if (slot instanceof GhostSlot) {
            return;
        }
    }

    // TODO Auto-generated method stub
    super.mouseReleased(mouseX, mouseY, state);
}
项目:rezolve    文件:ContainerBase.java   
@Override
public ItemStack transferStackInSlot(EntityPlayer playerIn, int fromSlot) {
    ItemStack previous = null;
    Slot slot = (Slot) this.inventorySlots.get(fromSlot);

    if (slot != null && slot.getHasStack()) {
        ItemStack current = slot.getStack();
        previous = current.copy();

        if (fromSlot < 9) {
            // From TE Inventory to Player Inventory
            if (!this.mergeItemStack(current, 9, 45, true))
                return null;
        } else {
            // From Player Inventory to TE Inventory
            if (!this.mergeItemStack(current, 0, 9, false))
                return null;
        }

        if (current.stackSize == 0)
            slot.putStack((ItemStack) null);
        else
            slot.onSlotChanged();

        if (current.stackSize == previous.stackSize)
            return null;
        slot.onPickupFromSlot(playerIn, current);
    }
    return previous;
}
项目:MineCamera    文件:ContainerPictureBook.java   
@Override
public ItemStack transferStackInSlot(EntityPlayer playerIn, int index) {
    Slot slot = inventorySlots.get(index);
    //System.out.println(index);
    if (slot == null || !slot.getHasStack()) {
        return null;
    }

    ItemStack newStack = slot.getStack(), oldStack = newStack.copy();
    boolean isMerged = false;

    if (index >= 0 && index <= 1) {
        isMerged = mergeItemStack(newStack, 2, 38, true);
    } else if (index >= 2 && index < 29) {
        isMerged = !pictureInSlot.getHasStack() && newStack.stackSize <= 1 && mergeItemStack(newStack, 0, 1, false)
                || mergeItemStack(newStack, 29, 38, false);
    } else if (index >= 29 && index < 38) {
        isMerged = !pictureInSlot.getHasStack() && newStack.stackSize <= 1 && mergeItemStack(newStack, 0, 1, false)
                || mergeItemStack(newStack, 2, 29, false);
    }

    if (!isMerged) {
        return null;
    }

    if (newStack.stackSize == 0) {
        slot.putStack(null);
    } else {
        slot.onSlotChanged();
    }
    slot.onPickupFromSlot(playerIn, newStack);
    return oldStack;
}
项目:BaseClient    文件:GuiRepair.java   
private void renameItem()
{
    String s = this.nameField.getText();
    Slot slot = this.anvil.getSlot(0);

    if (slot != null && slot.getHasStack() && !slot.getStack().hasDisplayName() && s.equals(slot.getStack().getDisplayName()))
    {
        s = "";
    }

    this.anvil.updateItemName(s);
    this.mc.thePlayer.sendQueue.addToSendQueue(new C17PacketCustomPayload("MC|ItemName", (new PacketBuffer(Unpooled.buffer())).writeString(s)));
}
项目:pnc-repressurized    文件:NetworkConnectionPlayerHandler.java   
public void mouseClicked(int x, int y, int mouseButton, Slot slot) {
    if (slot != null) {
        if (mouseButton == 0) tryToHackSlot(slot.slotNumber);
        if (mouseButton == 1 && slotHacked[slot.slotNumber]) {
            boolean alreadyFortifying = false;
            for (GuiStatBalloon balloon : balloons) {
                if (balloon.slotNumber == slot.slotNumber) {
                    alreadyFortifying = true;
                    break;
                }
            }
            if (!alreadyFortifying) {
                balloons.add(new GuiStatBalloon(slot.xPos + gui.getGuiLeft() + 8, slot.yPos + gui.getGuiTop() - 5, slot.slotNumber));
            }
        }
        if (mouseButton == 2 && !slotHacked[slot.slotNumber] && ((GuiSecurityStationHacking) gui).hasNukeViruses()) {
            int linesBefore = lineList.size();
            if (tryToHackSlot(slot.slotNumber)) {
                EntityPlayer player = FMLClientHandler.instance().getClient().player;
                NetworkHandler.sendToServer(new PacketUseItem(Itemss.NUKE_VIRUS, 1));
                PneumaticCraftUtils.consumeInventoryItem(player.inventory, Itemss.NUKE_VIRUS);
                for (int i = linesBefore; i < lineList.size(); i++) {
                    RenderProgressingLine line = lineList.get(i);
                    line.setProgress(1);
                    slotHacked[slot.slotNumber] = true;
                    onSlotHack(slot.slotNumber, true);
                }
            }
        }
    }
}
项目:BaseClient    文件:GuiContainer.java   
private void updateDragSplitting()
{
    ItemStack itemstack = this.mc.thePlayer.inventory.getItemStack();

    if (itemstack != null && this.dragSplitting)
    {
        this.dragSplittingRemnant = itemstack.stackSize;

        for (Slot slot : this.dragSplittingSlots)
        {
            ItemStack itemstack1 = itemstack.copy();
            int i = slot.getStack() == null ? 0 : slot.getStack().stackSize;
            Container.computeStackSize(this.dragSplittingSlots, this.dragSplittingLimit, itemstack1, i);

            if (itemstack1.stackSize > itemstack1.getMaxStackSize())
            {
                itemstack1.stackSize = itemstack1.getMaxStackSize();
            }

            if (itemstack1.stackSize > slot.getItemStackLimit(itemstack1))
            {
                itemstack1.stackSize = slot.getItemStackLimit(itemstack1);
            }

            this.dragSplittingRemnant -= itemstack1.stackSize - i;
        }
    }
}
项目:pnc-repressurized    文件:GuiSearcher.java   
@Override
protected void handleMouseClick(Slot par1Slot, int par2, int par3, ClickType par4) {
    if (par1Slot != null) {
        if (par1Slot.slotNumber == 48) {
            par1Slot.putStack(ItemStack.EMPTY);
        } else {
            inventory.setStackInSlot(48, par1Slot.getStack());
        }
    }
}
项目:CraftingParadiseMod    文件:ContainerWorldMachine.java   
public ContainerWorldMachine(EntityPlayer player, TileWorldMachine tile)
{
    this.tile = tile;

    InventoryPlayer ip = player.inventory;
    int playerInventoryX = 35;
    int playerInventoryY = 147;

    for(int x = 0; x < 9; x++)
        this.addSlotToContainer(new Slot(ip, x, playerInventoryX + x * 18 , playerInventoryY+58));

    for(int x = 0; x < 9; x++)
        for(int y = 0; y < 3; y++)
            this.addSlotToContainer(new Slot(ip, 9 + y * 9 + x, playerInventoryX + x * 18, playerInventoryY + y * 18));

    SlotWorldModule core = new SlotWorldModule(tile, 0, 21, 21, IWorldBuilderModule.ModuleType.CORE);
    SlotWorldModule mantle = new SlotWorldModule(tile, 1, 39, 21, IWorldBuilderModule.ModuleType.MANTLE, core);
    SlotWorldModule crust = new SlotWorldModule(tile, 2, 57, 21, IWorldBuilderModule.ModuleType.CRUST, core, mantle);
    SlotWorldModule land = new SlotWorldModule(tile, 3, 21, 39, IWorldBuilderModule.ModuleType.LANDSCAPE, core, mantle, crust);
    SlotWorldModule world = new SlotWorldModule(tile, 4, 39, 39, IWorldBuilderModule.ModuleType.WORLD, core, mantle, crust, land);
    SlotWorldModule atmosphere = new SlotWorldModule(tile, 5, 57, 39, IWorldBuilderModule.ModuleType.ATMOSPHERE, core, mantle, crust, land, world);

    this.addSlotToContainer(core);
    this.addSlotToContainer(mantle);
    this.addSlotToContainer(crust);
    this.addSlotToContainer(land);
    this.addSlotToContainer(world);
    this.addSlotToContainer(atmosphere);
}
项目:VanillaExtras    文件:ContainerBlockBreaker.java   
@Override
public ItemStack transferStackInSlot(EntityPlayer playerIn, int fromSlot) {
    ItemStack previous = ItemStack.EMPTY;
    Slot slot = (Slot) this.inventorySlots.get(fromSlot);

    if (slot != null && slot.getHasStack()) {
        ItemStack current = slot.getStack();
        previous = current.copy();

        if (fromSlot < this.handler.getSlots()) {
            // From the block breaker inventory to player's inventory
            if (!this.mergeItemStack(current, handler.getSlots(), handler.getSlots() + 36, true))
                return ItemStack.EMPTY;
        } else {
            // From the player's inventory to block breaker's inventory
            if (current.getItem() == Items.ENCHANTED_BOOK) {
                if (!this.mergeItemStack(current, 9, handler.getSlots(), false))
                    return ItemStack.EMPTY;
            }
            if (!this.mergeItemStack(current, 0, handler.getSlots(), false))
                return ItemStack.EMPTY;
        }

        if (current.getCount() == 0)
            slot.putStack(ItemStack.EMPTY);
        else
            slot.onSlotChanged();

        if (current.getCount() == previous.getCount())
            return null;
        slot.onTake(playerIn, current);
    }
    return previous;
}
项目:Mods    文件:ContainerTF2Workbench.java   
public ContainerTF2Workbench(EntityPlayer player, InventoryPlayer playerInventory, World worldIn, BlockPos posIn) {
    this.player = player;
    this.world = worldIn;
    this.pos = posIn;
    this.addSlotToContainer(
            new SlotCraftingTF2(playerInventory.player, this.craftMatrix, this.craftResult, 0, 148, 41));

    for (int i = 0; i < 3; ++i)
        for (int j = 0; j < 3; ++j)
            this.addSlotToContainer(new Slot(this.craftMatrix, j + i * 3, 86 + j * 18, 23 + i * 18) {

            });

    /*
     * for (int k = 0; k < 3; ++k) { for (int i1 = 0; i1 < 9; ++i1) {
     * this.addSlotToContainer(new Slot(cabinet, i1 + k * 9 + 9, 8 + i1 *
     * 18, 91 + k * 18)); } }
     */

    for (int k = 0; k < 3; ++k)
        for (int i1 = 0; i1 < 9; ++i1)
            this.addSlotToContainer(new Slot(playerInventory, i1 + k * 9 + 9, 8 + i1 * 18, 98 + k * 18));

    for (int l = 0; l < 9; ++l)
        this.addSlotToContainer(new Slot(playerInventory, l, 8 + l * 18, 156));

    this.onCraftMatrixChanged(this.craftMatrix);
}
项目:VanillaExtras    文件:ContainerBlockBreaker.java   
/**
 * Adds slots to Block Breaker: * 9 slots for breaked block * 1 slot for
 * enchanted book * Inventory slots
 * 
 * @param playerInv
 *            Player inventory for registering it in Gui
 * @param te
 *            Tile Entity
 */
public ContainerBlockBreaker(IInventory playerInv, TileEntityBlockBreaker te) {
    this.te = te;
    this.handler = te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);

    this.addSlotToContainer(new SlotItemHandler(handler, 0, 62, 17));
    this.addSlotToContainer(new SlotItemHandler(handler, 1, 80, 17));
    this.addSlotToContainer(new SlotItemHandler(handler, 2, 98, 17));
    this.addSlotToContainer(new SlotItemHandler(handler, 3, 62, 35));
    this.addSlotToContainer(new SlotItemHandler(handler, 4, 80, 35));
    this.addSlotToContainer(new SlotItemHandler(handler, 5, 98, 35));
    this.addSlotToContainer(new SlotItemHandler(handler, 6, 62, 53));
    this.addSlotToContainer(new SlotItemHandler(handler, 7, 80, 53));
    this.addSlotToContainer(new SlotItemHandler(handler, 8, 98, 53));
    this.addSlotToContainer(new SlotItemEnchantedBook(handler, 9, 134, 17));

    int xPos = 8;
    int yPos = 84;

    for (int y = 0; y < 3; ++y) {
        for (int x = 0; x < 9; ++x) {
            this.addSlotToContainer(new Slot(playerInv, x + y * 9 + 9, xPos + x * 18, yPos + y * 18));
        }
    }

    for (int x = 0; x < 9; ++x) {
        this.addSlotToContainer(new Slot(playerInv, x, xPos + x * 18, yPos + 58));
    }
}
项目:pnc-repressurized    文件:ContainerPneumaticBase.java   
@Nonnull
private ItemStack slotClickPhantom(Slot slot, int dragType, ClickType clickType, EntityPlayer player) {
    ItemStack stack = ItemStack.EMPTY;

    if (clickType == ClickType.CLONE && dragType == 2) {
        // middle-click: clear slot
        if (((IPhantomSlot) slot).canAdjust()) {
            slot.putStack(ItemStack.EMPTY);
        }
    } else if ((clickType == ClickType.PICKUP || clickType == ClickType.QUICK_MOVE) && (dragType == 0 || dragType == 1)) {
        // left or right-click...
        InventoryPlayer playerInv = player.inventory;
        slot.onSlotChanged();
        ItemStack stackSlot = slot.getStack();
        ItemStack stackHeld = playerInv.getItemStack();

        stack = stackSlot.copy();
        if (stackSlot.isEmpty()) {
            if (!stackHeld.isEmpty() && slot.isItemValid(stackHeld)) {
                fillPhantomSlot(slot, stackHeld, clickType, dragType);
            }
        } else if (stackHeld.isEmpty()) {
            adjustPhantomSlot(slot, clickType, dragType);
            slot.onTake(player, playerInv.getItemStack());
        } else if (slot.isItemValid(stackHeld)) {
            if (canStacksMerge(stackSlot, stackHeld)) {
                adjustPhantomSlot(slot, clickType, dragType);
            } else {
                fillPhantomSlot(slot, stackHeld, clickType, dragType);
            }
        }
    }
    return stack;
}
项目:BetterBeginningsReborn    文件:ContainerWickerBasket.java   
public ItemStack transferStackInSlot(EntityPlayer playerIn, int index)
   {
ItemStack newStack = null;
Slot slot = (Slot)this.inventorySlots.get(index);

if (slot != null && slot.getHasStack())
{
    ItemStack containedStack = slot.getStack();
    newStack = containedStack.copy();

    if (index < TileEntityWickerBasket.INV_SIZE)
    {
    if (!this.mergeItemStack(containedStack, TileEntityWickerBasket.INV_SIZE, this.inventorySlots.size(), true))
    {
        return null;
    }
    }
    else if (!this.mergeItemStack(containedStack, 0, TileEntityWickerBasket.INV_SIZE, false))
    {
    return null;
    }

    if (containedStack.getCount() == 0)
    {
    slot.putStack((ItemStack)null);
    }
    else
    {
    slot.onSlotChanged();
    }
}

return newStack;
   }
项目:pnc-repressurized    文件:ContainerPneumaticBase.java   
private void fillPhantomSlot(Slot slot, ItemStack stackHeld, ClickType clickType, int dragType) {
    if (!((IPhantomSlot) slot).canAdjust()) {
        return;
    }
    int stackSize = dragType == 0 ? stackHeld.getCount() : 1;
    if (stackSize > slot.getSlotStackLimit()) {
        stackSize = slot.getSlotStackLimit();
    }
    ItemStack phantomStack = stackHeld.copy();
    phantomStack.setCount(stackSize);

    slot.putStack(phantomStack);
}
项目:Anima-Mundi    文件:ContainerAnimaGenerator.java   
public ItemStack transferStackInSlot(EntityPlayer playerIn, int index)
{
    ItemStack itemstack = ItemStack.EMPTY;
    Slot slot = this.inventorySlots.get(index);

    if (slot != null && slot.getHasStack())
    {
        ItemStack itemstack1 = slot.getStack();
        itemstack = itemstack1.copy();

        if (index < items.getSlots())
        {
            if (!this.mergeItemStack(itemstack1, items.getSlots(), this.inventorySlots.size(), true))
            {
                return ItemStack.EMPTY;
            }
        }
        else if (!this.mergeItemStack(itemstack1, 0, items.getSlots(), false))
        {
            return ItemStack.EMPTY;
        }

        if (itemstack1.isEmpty())
        {
            slot.putStack(ItemStack.EMPTY);
        }
        else
        {
            slot.onSlotChanged();
        }
    }

    return itemstack;
}
项目:pnc-repressurized    文件:ContainerInventorySearcher.java   
public ContainerInventorySearcher(InventoryPlayer inventoryPlayer) {
    // Add the player's inventory slots to the container
    for (int inventoryRowIndex = 0; inventoryRowIndex < 3; ++inventoryRowIndex) {
        for (int inventoryColumnIndex = 0; inventoryColumnIndex < 9; ++inventoryColumnIndex) {
            addSlotToContainer(new Slot(inventoryPlayer, inventoryColumnIndex + inventoryRowIndex * 9 + 9, 8 + inventoryColumnIndex * 18, 48 + inventoryRowIndex * 18));
        }
    }

    // Add the player's action bar slots to the container
    for (int actionBarSlotIndex = 0; actionBarSlotIndex < 9; ++actionBarSlotIndex) {
        addSlotToContainer(new Slot(inventoryPlayer, actionBarSlotIndex, 8 + actionBarSlotIndex * 18, 106));
    }
}
项目:pnc-repressurized    文件:ContainerProgrammer.java   
@Nonnull
@Override
public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int slotIndex) {
    ItemStack stack = ItemStack.EMPTY;
    Slot srcSlot = inventorySlots.get(slotIndex);

    if (srcSlot != null && srcSlot.getHasStack()) {
        ItemStack stackInSlot = srcSlot.getStack();
        stack = stackInSlot.copy();

        if (slotIndex == 0) {
            if (!mergeItemStack(stackInSlot, 1, 36, false)) return ItemStack.EMPTY;
            srcSlot.onSlotChange(stackInSlot, stack);
        } else if (isProgrammableItem(stack)) {
            if (!mergeItemStack(stackInSlot, 0, 1, false)) return ItemStack.EMPTY;
            srcSlot.onSlotChange(stackInSlot, stack);
        }
        if (stackInSlot.isEmpty()) {
            srcSlot.putStack(ItemStack.EMPTY);
        } else {
            srcSlot.onSlotChanged();
        }

        if (stackInSlot.getCount() == stack.getCount()) return ItemStack.EMPTY;

        srcSlot.onTake(par1EntityPlayer, stackInSlot);
    }

    return stack;
}
项目:BaseClient    文件:GuiContainer.java   
private void updateDragSplitting()
{
    ItemStack itemstack = this.mc.thePlayer.inventory.getItemStack();

    if (itemstack != null && this.dragSplitting)
    {
        this.dragSplittingRemnant = itemstack.stackSize;

        for (Slot slot : this.dragSplittingSlots)
        {
            ItemStack itemstack1 = itemstack.copy();
            int i = slot.getStack() == null ? 0 : slot.getStack().stackSize;
            Container.computeStackSize(this.dragSplittingSlots, this.dragSplittingLimit, itemstack1, i);

            if (itemstack1.stackSize > itemstack1.getMaxStackSize())
            {
                itemstack1.stackSize = itemstack1.getMaxStackSize();
            }

            if (itemstack1.stackSize > slot.getItemStackLimit(itemstack1))
            {
                itemstack1.stackSize = slot.getItemStackLimit(itemstack1);
            }

            this.dragSplittingRemnant -= itemstack1.stackSize - i;
        }
    }
}
项目:Industrial-Foregoing    文件:CustomColoredItemHandler.java   
@Override
public List<Slot> getSlots(BasicTeslaContainer container) {
    List<Slot> slots = super.getSlots(container);
    BoundingRectangle box = this.getBoundingBox();
    int i = 0;
    for (int y = 0; y < slotsY; y++) {
        for (int x = 0; x < slotsX; x++) {
            slots.add(new FilteredSlot(this.getItemHandlerForContainer(), i, box.getLeft() + 1 + x * 18, box.getTop() + 1 + y * 18));
            ++i;
        }
    }
    return slots;
}
项目:BaseClient    文件:GuiContainer.java   
/**
 * Returns the slot at the given coordinates or null if there is none.
 */
private Slot getSlotAtPosition(int x, int y)
{
    for (int i = 0; i < this.inventorySlots.inventorySlots.size(); ++i)
    {
        Slot slot = (Slot)this.inventorySlots.inventorySlots.get(i);

        if (this.isMouseOverSlot(slot, x, y))
        {
            return slot;
        }
    }

    return null;
}
项目:Mods    文件:ContainerBench.java   
/**
 * Take a stack from the specified inventory slot.
 */
@Override
@Nullable
public ItemStack transferStackInSlot(EntityPlayer playerIn, int index) {
    ItemStack itemstack = ItemStack.EMPTY;
    Slot slot = this.inventorySlots.get(index);

    if (slot != null && slot.getHasStack()) {
        ItemStack itemstack1 = slot.getStack();
        itemstack = itemstack1.copy();

        if (index == 0) {
            if (!this.mergeItemStack(itemstack1, 1, 28, true))
                return ItemStack.EMPTY;

            slot.onSlotChange(itemstack1, itemstack);
        } else if (index >= 1 && index < 28) {
            if (!this.mergeItemStack(itemstack1, 0, 1, false))
                return ItemStack.EMPTY;
        } else if (!this.mergeItemStack(itemstack1, 1, 28, false))
            return ItemStack.EMPTY;

        if (itemstack1.isEmpty())
            slot.putStack(ItemStack.EMPTY);
        else
            slot.onSlotChanged();

        if (itemstack1.getCount() ==itemstack.getCount())
            return ItemStack.EMPTY;

        slot.onTake(playerIn, itemstack1);
    }

    return itemstack;
}
项目:ExSartagine    文件:ContainerPan.java   
public ContainerPan(InventoryPlayer playerInventory, TileEntityPan pan) {

    this.addSlotToContainer(new SlotPanInput(pan.getInventory(), 0, 56, 17));
       this.addSlotToContainer(new SlotPanOutput(playerInventory.player, pan.getInventory(), 1, 116, 35));

       for (int i = 0; i < 3; ++i)
           for (int j = 0; j < 9; ++j)
               this.addSlotToContainer(new Slot(playerInventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));

       for (int k = 0; k < 9; ++k)
           this.addSlotToContainer(new Slot(playerInventory, k, 8 + k * 18, 142));
}
项目:ExSartagine    文件:ContainerPot.java   
public ContainerPot(InventoryPlayer playerInventory, TileEntityPot pot) {

    this.addSlotToContainer(new SlotPotInput(pot.getInventory(), 0, 56, 17));
       this.addSlotToContainer(new SlotPanOutput(playerInventory.player, pot.getInventory(), 1, 116, 35));

       for (int i = 0; i < 3; ++i)
           for (int j = 0; j < 9; ++j)
               this.addSlotToContainer(new Slot(playerInventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));

       for (int k = 0; k < 9; ++k)
           this.addSlotToContainer(new Slot(playerInventory, k, 8 + k * 18, 142));
}
项目:Machines-and-Stuff    文件:ContainerFurnace.java   
public ContainerFurnace(InventoryPlayer invPlayer, TileEntityMachineFurnace tile) {

    addSlotToContainer(new SlotMachineInput(tile, 0, 44, 35));
    addSlotToContainer(new SlotOutput(tile.itemStackHandler, 1, 116, 35));
    for(int x = 0; x < 9; x++) {
        addSlotToContainer(new Slot(invPlayer, x, 8 + 18 * x, 142));
    }

    for(int y = 0; y < 3; y++) {
        for(int x = 0; x < 9; x++) {
            addSlotToContainer(new Slot(invPlayer, x + y * 9 + 9, 8 + 18 * x, 84 + y * 18));
        }
    }

}
项目:Bewitchment    文件:ContainerBase.java   
protected void addPlayerSlots(InventoryPlayer playerInventory, int x, int y) {
    for (int i = 0; i < 3; ++i) {
        for (int j = 0; j < 9; ++j) {
            addSlotToContainer(new Slot(playerInventory, j + i * 9 + 9, x + j * 18, y + i * 18));
        }
    }

    for (int i = 0; i < 9; ++i) {
        addSlotToContainer(new Slot(playerInventory, i, x + i * 18, y + 58));
    }
}
项目:Bewitchment    文件:ContainerThreadSpinner.java   
public ContainerThreadSpinner(InventoryPlayer pi, TileEntityThreadSpinner spinner) {
    ts = spinner;
    addSlotToContainer(new OutputSlot(spinner.getInventory(), 0, 116, 34));
    addSlotToContainer(new Slot(spinner.getInventory(), 1, 44, 25));
    addSlotToContainer(new Slot(spinner.getInventory(), 2, 62, 25));
    addSlotToContainer(new Slot(spinner.getInventory(), 3, 44, 43));
    addSlotToContainer(new Slot(spinner.getInventory(), 4, 62, 43));
    addPlayerSlots(pi, 8, 84);
}
项目:Bewitchment    文件:ContainerApiary.java   
@Override
public ItemStack transferStackInSlot(EntityPlayer player, int slotIndex) {
    final Slot slot = inventorySlots.get(slotIndex);
    ItemStack copy = ItemStack.EMPTY;

    if (slot != null && slot.getHasStack()) {
        final ItemStack original = slot.getStack();
        copy = original.copy();

        if (slotIndex == 0) {
            if (!mergeItemStack(original, 19, 55, true)) return ItemStack.EMPTY;
            slot.onSlotChange(original, copy);
        } else if (slotIndex > 19) {
            if (original.getCount() == 1 && !mergeItemStack(original, 0, 1, false)) return ItemStack.EMPTY;
            slot.onSlotChange(original, copy);
        } else {
            if (!mergeItemStack(original, 19, 55, true)) return ItemStack.EMPTY;
            slot.onSlotChange(original, copy);
        }

        if (original.getCount() == 0) {
            slot.putStack(ItemStack.EMPTY);
        } else {
            slot.onSlotChanged();
        }

        if (original.getCount() == copy.getCount()) return ItemStack.EMPTY;

        slot.onTake(player, original);
    }

    return copy;
}
项目:BaseClient    文件:GuiRepair.java   
private void renameItem()
{
    String s = this.nameField.getText();
    Slot slot = this.anvil.getSlot(0);

    if (slot != null && slot.getHasStack() && !slot.getStack().hasDisplayName() && s.equals(slot.getStack().getDisplayName()))
    {
        s = "";
    }

    this.anvil.updateItemName(s);
    this.mc.thePlayer.sendQueue.addToSendQueue(new C17PacketCustomPayload("MC|ItemName", (new PacketBuffer(Unpooled.buffer())).writeString(s)));
}
项目:Backmemed    文件:GuiContainer.java   
/**
 * Returns the slot at the given coordinates or null if there is none.
 */
private Slot getSlotAtPosition(int x, int y)
{
    for (int i = 0; i < this.inventorySlots.inventorySlots.size(); ++i)
    {
        Slot slot = (Slot)this.inventorySlots.inventorySlots.get(i);

        if (this.isMouseOverSlot(slot, x, y) && slot.canBeHovered())
        {
            return slot;
        }
    }

    return null;
}
项目:Metalworks    文件:InterfaceBlastFurnace.java   
@Override
public void initSlots(TileBlastFurnace tile, ContainerMachine<TileBlastFurnace> container, EntityPlayer player) {
    container.addSlot(new Slot(tile.inventory, TileBlastFurnace.INPUT1, 61, 11));
    container.addSlot(new Slot(tile.inventory, TileBlastFurnace.INPUT2, 81, 11));
    container.addSlot(new Slot(tile.inventory, TileBlastFurnace.INPUT3, 101, 11));
    container.addSlot(new SlotFurnaceOutput(player, tile.inventory, TileBlastFurnace.OUTPUT1, 71, 57));
    container.addSlot(new SlotFurnaceOutput(player, tile.inventory, TileBlastFurnace.OUTPUT2, 91, 57));
}
项目:CustomWorldGen    文件:GuiRepair.java   
private void renameItem()
{
    String s = this.nameField.getText();
    Slot slot = this.anvil.getSlot(0);

    if (slot != null && slot.getHasStack() && !slot.getStack().hasDisplayName() && s.equals(slot.getStack().getDisplayName()))
    {
        s = "";
    }

    this.anvil.updateItemName(s);
    this.mc.thePlayer.connection.sendPacket(new CPacketCustomPayload("MC|ItemName", (new PacketBuffer(Unpooled.buffer())).writeString(s)));
}