当前位置: 首页>>代码示例>>Java>>正文


Java Slot类代码示例

本文整理汇总了Java中net.minecraft.inventory.Slot的典型用法代码示例。如果您正苦于以下问题:Java Slot类的具体用法?Java Slot怎么用?Java Slot使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Slot类属于net.minecraft.inventory包,在下文中一共展示了Slot类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: ContainerProgrammer

import net.minecraft.inventory.Slot; //导入依赖的package包/类
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));
    }
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:23,代码来源:ContainerProgrammer.java

示例2: ContainerAmmoFurnace

import net.minecraft.inventory.Slot; //导入依赖的package包/类
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));
}
 
开发者ID:rafradek,项目名称:Mods,代码行数:17,代码来源:ContainerAmmoFurnace.java

示例3: buildInventoryLayout

import net.minecraft.inventory.Slot; //导入依赖的package包/类
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);
}
 
开发者ID:trigg,项目名称:Firma,代码行数:19,代码来源:PlayerInv.java

示例4: ContainerOven

import net.minecraft.inventory.Slot; //导入依赖的package包/类
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));
	}
}
 
开发者ID:Um-Mitternacht,项目名称:Bewitchment,代码行数:24,代码来源:ContainerOven.java

示例5: ContainerCreative

import net.minecraft.inventory.Slot; //导入依赖的package包/类
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);
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:20,代码来源:GuiContainerCreative.java

示例6: ContainerBloomeryFurnace

import net.minecraft.inventory.Slot; //导入依赖的package包/类
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)));
}
 
开发者ID:jaquadro,项目名称:GardenStuff,代码行数:20,代码来源:ContainerBloomeryFurnace.java

示例7: ContainerTileCustomMachine

import net.minecraft.inventory.Slot; //导入依赖的package包/类
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));
}
 
开发者ID:koravel,项目名称:ElementalElaboration,代码行数:27,代码来源:ContainerTileCustomMachine.java

示例8: transferStackInSlot

import net.minecraft.inventory.Slot; //导入依赖的package包/类
@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;
}
 
开发者ID:tiffit,项目名称:Defier,代码行数:27,代码来源:DefierContainer.java

示例9: handleMouseClick

import net.minecraft.inventory.Slot; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:13,代码来源:GuiContainer.java

示例10: mouseReleased

import net.minecraft.inventory.Slot; //导入依赖的package包/类
@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);
}
 
开发者ID:astronautlabs,项目名称:rezolve,代码行数:14,代码来源:GuiContainerBase.java

示例11: transferStackInSlot

import net.minecraft.inventory.Slot; //导入依赖的package包/类
@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;
}
 
开发者ID:astronautlabs,项目名称:rezolve,代码行数:31,代码来源:ContainerBase.java

示例12: transferStackInSlot

import net.minecraft.inventory.Slot; //导入依赖的package包/类
@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;
}
 
开发者ID:PorPit,项目名称:MineCamera,代码行数:34,代码来源:ContainerPictureBook.java

示例13: renameItem

import net.minecraft.inventory.Slot; //导入依赖的package包/类
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)));
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:14,代码来源:GuiRepair.java

示例14: mouseClicked

import net.minecraft.inventory.Slot; //导入依赖的package包/类
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);
                }
            }
        }
    }
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:32,代码来源:NetworkConnectionPlayerHandler.java

示例15: updateDragSplitting

import net.minecraft.inventory.Slot; //导入依赖的package包/类
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;
        }
    }
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:29,代码来源:GuiContainer.java


注:本文中的net.minecraft.inventory.Slot类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。