Java源码示例:net.minecraftforge.items.SlotItemHandler
示例1
public SawmillContainer(int windowId, PlayerInventory playerInventory, IItemHandlerModifiable inventory, IIntArray dryTimes)
{
super(TYPE, windowId);
fields = dryTimes;
wrappedInventory = new ChoppingContext(inventory, null, 0, 0, RANDOM);
world = playerInventory.player.world;
addSlot(new SlotItemHandler(inventory, 0, 56, 17));
addSlot(new SawmillFuelSlot(inventory, 1, 56, 53));
addSlot(new SawmillOutputSlot(inventory, 2, 116, 35));
bindPlayerInventory(playerInventory);
trackIntArray(fields);
}
示例2
@Override
protected int getMaxStackSizeFromSlotAndStack(Slot slot, ItemStack stack)
{
// Our main item inventory or the furnace inventory
if (slot instanceof SlotItemHandler)
{
SlotItemHandler slotItemHandler = (SlotItemHandler) slot;
if (slotItemHandler.getItemHandler() == this.inventory ||
slotItemHandler.getItemHandler() == this.tecs.getFurnaceInventory())
{
return slotItemHandler.getItemStackLimit(stack);
}
}
// Player inventory, module slots or crafting slots
return super.getMaxStackSizeFromSlotAndStack(slot, stack);
}
示例3
@Override
public void addMachineSlots(IItemHandler handler) {
this.addSlotToContainer(new SlotItemHandler(handler, 0, 22, 35));
this.addSlotToContainer(new SlotItemHandler(handler, 1, 50, 35));
this.addSlotToContainer(new SlotItemHandler(handler, 2, 78, 35));
this.addSlotToContainer(new SlotItemHandler(handler, 3, 106, 35));
this.addSlotToContainer(new SlotItemHandler(handler, 4, 134, 35));
}
示例4
@Override
public void addMachineSlots(IItemHandler handler) {
addSlotToContainer(new SlotItemHandler(handler, 0, 17, 35));
addSlotToContainer(new SlotItemHandler(handler, 1, 52, 35));
addSlotToContainer(new SlotItemHandler(handler, 2, 80, 35));
addSlotToContainer(new SlotItemHandler(handler, 3, 108, 35));
}
示例5
private int addSlotRange(IItemHandler handler, int index, int x, int y, int amount, int dx) {
for (int i = 0; i < amount; i++) {
addSlot(new SlotItemHandler(handler, index, x, y));
x += dx;
index++;
}
return index;
}
示例6
private int addSlotRange(IItemHandler handler, int index, int x, int y, int amount, int dx) {
for (int i = 0; i < amount; i++) {
addSlot(new SlotItemHandler(handler, index, x, y));
x += dx;
index++;
}
return index;
}
示例7
private void addOwnSlots() {
IItemHandler itemHandler = this.te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
int x = 10;
int y = 26;
int slotIndex = 0;
addSlotToContainer(new SlotItemHandler(itemHandler, slotIndex++, x, y)); x += 18;
addSlotToContainer(new SlotItemHandler(itemHandler, slotIndex++, x, y)); x += 18;
addSlotToContainer(new SlotItemHandler(itemHandler, slotIndex++, x, y));
x = 118;
addSlotToContainer(new SlotItemHandler(itemHandler, slotIndex++, x, y)); x += 18;
addSlotToContainer(new SlotItemHandler(itemHandler, slotIndex++, x, y)); x += 18;
addSlotToContainer(new SlotItemHandler(itemHandler, slotIndex++, x, y));
}
示例8
private void addOwnSlots() {
IItemHandler itemHandler = this.te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
int slotIndex = 0;
for (int row = 0; row < 3; ++row) {
for (int col = 0; col < 9; ++col) {
int x = 10 + col * 18;
int y = row * 18 + 8;
this.addSlotToContainer(new SlotItemHandler(itemHandler, slotIndex++, x, y));
}
}
}
示例9
private void addOwnSlots() {
IItemHandler itemHandler = this.te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
int x = 10;
int y = 26;
int slotIndex = 0;
addSlotToContainer(new SlotItemHandler(itemHandler, slotIndex, x, y));
}
示例10
public ContainerComponentBox(IInventory playerInventory, TileEntityComponentBox box)
{
this.box = box;
this.item = null;
this.slots = box.slots;
this.numRows = slots.getSlots() / 9;
int i = (this.numRows - 4) * 18;
for (int j = 0; j < this.numRows; ++j)
{
for (int k = 0; k < 9; ++k)
{
this.addSlotToContainer(new SlotItemHandler(slots, k + j * 9, 8 + k * 18, 18 + j * 18));
}
}
for (int l = 0; l < 3; ++l)
{
for (int j1 = 0; j1 < 9; ++j1)
{
this.addSlotToContainer(new Slot(playerInventory, j1 + l * 9 + 9, 8 + j1 * 18, 103 + l * 18 + i));
}
}
for (int i1 = 0; i1 < 9; ++i1)
{
this.addSlotToContainer(new Slot(playerInventory, i1, 8 + i1 * 18, 161 + i));
}
}
示例11
public ContainerComponentBox(IInventory playerInventory, ItemStack itemStack)
{
this.box = null;
this.item = itemStack;
slots = new ItemStackHandlerComponent(18);
if (itemStack.hasTagCompound() && itemStack.getTagCompound().hasKey("contents"))
{
slots.deserializeNBT(itemStack.getTagCompound().getCompoundTag("contents"));
}
this.numRows = slots.getSlots() / 9;
int i = (this.numRows - 4) * 18;
for (int j = 0; j < this.numRows; ++j)
{
for (int k = 0; k < 9; ++k)
{
this.addSlotToContainer(new SlotItemHandler(slots, k + j * 9, 8 + k * 18, 18 + j * 18));
}
}
for (int l = 0; l < 3; ++l)
{
for (int j1 = 0; j1 < 9; ++j1)
{
this.addSlotToContainer(new Slot(playerInventory, j1 + l * 9 + 9, 8 + j1 * 18, 103 + l * 18 + i));
}
}
for (int i1 = 0; i1 < 9; ++i1)
{
this.addSlotToContainer(new Slot(playerInventory, i1, 8 + i1 * 18, 161 + i));
}
}
示例12
public ContainerBlueprintArchive(IInventory playerInventory, TileEntityBlueprintArchive archive)
{
this.archive = archive;
this.numRows = archive.slots.getSlots() / 9;
int i = (this.numRows - 4) * 18;
for (int j = 0; j < this.numRows; ++j)
{
for (int k = 0; k < 9; ++k)
{
this.addSlotToContainer(new SlotItemHandler(archive.slots, k + j * 9, 8 + k * 18, 18 + j * 18));
}
}
for (int l = 0; l < 3; ++l)
{
for (int j1 = 0; j1 < 9; ++j1)
{
this.addSlotToContainer(new Slot(playerInventory, j1 + l * 9 + 9, 8 + j1 * 18, 103 + l * 18 + i));
}
}
for (int i1 = 0; i1 < 9; ++i1)
{
this.addSlotToContainer(new Slot(playerInventory, i1, 8 + i1 * 18, 161 + i));
}
}
示例13
private DryingRackContainer(int windowId, PlayerInventory playerInventory, IItemHandler inventory, IIntArray dryTimes)
{
super(TYPE, windowId);
dryTimeRemainingArray = dryTimes;
addSlot(new SlotItemHandler(inventory, 0, 26, 34));
addSlot(new SlotItemHandler(inventory, 1, 62, 34));
addSlot(new SlotItemHandler(inventory, 2, 98, 34));
addSlot(new SlotItemHandler(inventory, 3, 134, 34));
bindPlayerInventory(playerInventory, 84);
this.trackIntArray(dryTimeRemainingArray);
}
示例14
@Override
protected int getMaxStackSizeFromSlotAndStack(Slot slot, ItemStack stack)
{
// Our inventory
if (slot instanceof SlotItemHandler && ((SlotItemHandler) slot).getItemHandler() == this.inventory)
{
return slot.getItemStackLimit(stack);
}
// Player inventory
return super.getMaxStackSizeFromSlotAndStack(slot, stack);
}
示例15
@Override
public boolean canMergeSlot(ItemStack stack, Slot slot)
{
return (slot instanceof SlotItemHandler) &&
(slot instanceof SlotItemHandlerCraftResult) == false &&
(slot instanceof SlotItemHandlerFurnaceOutput) == false &&
this.inventoryPlayer.getItemStack().isEmpty() == false;
}
示例16
protected void setupBackpackSlots() {
int xOffset = 1 + getContainerInvXOffset();
int yOffset = 1 + getBorderTop();
for (int y = 0; y < size.getRows(); y++, yOffset += 18)
for (int x = 0; x < size.getColumns(); x++)
addSlotToContainer(new SlotItemHandler(items, x + y * size.getColumns(),
xOffset + x * 18, yOffset));
}
示例17
public GuiBlueprint addSlot(SlotType type, int x, int y) {
addSlot(new SlotElement(new SlotItemHandler(tile.itemHandler, slots.size(), x + type.getSlotOffsetX(), y + type.getSlotOffsetY()), type, x, y));
return this;
}
示例18
@Override
public void addMachineSlots(IItemHandler handler) {
addSlotToContainer(new SlotItemHandler(handler, 0, 17, 35));
}
示例19
@Override
public void addMachineSlots(IItemHandler handler) {
addSlotToContainer(new SlotItemHandler(handler, 0, 17, 35));
addSlotToContainer(new SlotItemHandler(handler, 1, 80, 35));
}
示例20
@Override
public void addMachineSlots(IItemHandler handler) {
this.addSlotToContainer(new SlotItemHandler(handler, 0, 17, 35));
this.addSlotToContainer(new SlotItemHandler(handler, 1, 80, 35));
this.addSlotToContainer(new SlotItemHandler(handler, 2, 80, 72));
}
示例21
@Override
public void addMachineSlots(IItemHandler handler) {
this.addSlotToContainer(new SlotItemHandler(handler, 0, 17, 35));
this.addSlotToContainer(new SlotItemHandler(handler, 1, 123, 35));
}
示例22
@Override
public void addMachineSlots(IItemHandler handler) {
addSlotToContainer(new SlotItemHandler(handler, 0, 17, 35));
addSlotToContainer(new SlotItemHandler(handler, 1, 80, 35));
}
示例23
@Override
public void addMachineSlots(IItemHandler handler) {
addSlotToContainer(new SlotItemHandler(handler, 0, 17, 35));
}
示例24
@Override
public void addMachineSlots(IItemHandler handler) {
addSlotToContainer(new SlotItemHandler(handler, 0, 17, 35));
addSlotToContainer(new SlotItemHandler(handler, 1, 80, 35));
}
示例25
@Override
public void addMachineSlots(IItemHandler handler) {
addSlotToContainer(new SlotItemHandler(handler, 0, 17, 35));
}
示例26
@Override
public void addMachineSlots(IItemHandler handler) {
addSlotToContainer(new SlotItemHandler(handler, 0, 17, 35));
addSlotToContainer(new SlotItemHandler(handler, 1, 80, 35));
}
示例27
@Override
public void addMachineSlots(IItemHandler handler) {
addSlotToContainer(new SlotItemHandler(handler, 0, 17, 35));
addSlotToContainer(new SlotItemHandler(handler, 1, 80, 35));
}
示例28
@Override
public void addMachineSlots(IItemHandler handler) {
addSlotToContainer(new SlotItemHandler(handler, 0, 17, 35));
addSlotToContainer(new SlotItemHandler(handler, 1, 80, 35));
}
示例29
@Override
public void addMachineSlots(IItemHandler handler) {
addSlotToContainer(new SlotItemHandler(handler, 0, 17, 35));
addSlotToContainer(new SlotItemHandler(handler, 1, 80, 35));
}
示例30
@Override
public void addMachineSlots(IItemHandler handler) {
addSlotToContainer(new SlotItemHandler(handler, 0, 17, 35));
addSlotToContainer(new SlotItemHandler(handler, 1, 80, 35));
}