當前位置: 首頁>>代碼示例>>Java>>正文


Java ISidedInventory類代碼示例

本文整理匯總了Java中net.minecraft.inventory.ISidedInventory的典型用法代碼示例。如果您正苦於以下問題:Java ISidedInventory類的具體用法?Java ISidedInventory怎麽用?Java ISidedInventory使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ISidedInventory類屬於net.minecraft.inventory包,在下文中一共展示了ISidedInventory類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: ContainerTileCustomMachine

import net.minecraft.inventory.ISidedInventory; //導入依賴的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

示例2: collectItems

import net.minecraft.inventory.ISidedInventory; //導入依賴的package包/類
private void collectItems() {
	applyGravity(attract, true);
	IItemHandler handler = to.getKey();
	ISidedInventory sidedInv = to.getValue();
	getItemsFiltered(absorptionRange).forEach(e -> {
		e.setNoGravity(true);
		for(int slot = 0; slot < handler.getSlots(); slot++) {
			ItemStack inSlot = handler.getStackInSlot(slot);
			ItemStack in = e.getItem();
			if(sidedInv == null || sidedInv.canInsertItem(slot, in, getFacingLazy())) {
				if(inSlot.isEmpty() || (ItemHandlerHelper.canItemStacksStack(inSlot, in)
						&& (inSlot.getCount() < inSlot.getMaxStackSize()
						&& inSlot.getCount() < handler.getSlotLimit(slot)))) {
					ItemStack out = handler.insertItem(slot, in, false);
					if(out != in) {
						e.setItem(out);
						break;
					}
				}
			}
		}
	});
}
 
開發者ID:ArekkuusuJerii,項目名稱:Solar,代碼行數:24,代碼來源:TileVacuumConveyor.java

示例3: dropItems

import net.minecraft.inventory.ISidedInventory; //導入依賴的package包/類
private void dropItems() {
	if(world.getTotalWorldTime() % 10 != 0) return;
	applyGravity(repulse, false);
	IItemHandler handler = from.getKey();
	ISidedInventory sidedInv = from.getValue();
	Vector3 spawn = Vector3.create(getPos()).add(0.5D).offset(getFacingLazy(), 1);
	for(int slot = 0; slot < handler.getSlots(); slot++) {
		ItemStack inSlot = handler.getStackInSlot(slot);
		if(!inSlot.isEmpty()
				&& (lookup.isEmpty() || ItemHandlerHelper.canItemStacksStack(lookup, inSlot))
				&& (sidedInv == null || sidedInv.canExtractItem(slot, inSlot, getFacingLazy()))) {
			ItemStack out = handler.extractItem(slot, Integer.MAX_VALUE, false);
			EntityTemporalItem entity = new EntityTemporalItem(world, spawn.x, spawn.y, spawn.z, out);
			impulseEntityItem(spawn, entity);
			world.spawnEntity(entity);
			break;
		}
	}
}
 
開發者ID:ArekkuusuJerii,項目名稱:Solar,代碼行數:20,代碼來源:TileVacuumConveyor.java

示例4: transferOut

import net.minecraft.inventory.ISidedInventory; //導入依賴的package包/類
private ItemStack transferOut(BlockPos pos, boolean test) {
	EnumFacing facing = getFacing().getOpposite();
	Pair<IItemHandler, ISidedInventory> inv = getInventory(pos, facing);
	if(inv.getKey() != null) {
		IItemHandler handler = inv.getKey();
		ISidedInventory tile = inv.getValue();

		for(int slot = 0; slot < handler.getSlots(); slot++) {
			ItemStack in = handler.getStackInSlot(slot);
			if(!in.isEmpty() && (tile == null || tile.canExtractItem(slot, in, facing))) {
				return handler.extractItem(slot, Integer.MAX_VALUE, test);
			}
		}
	}
	return ItemStack.EMPTY;
}
 
開發者ID:ArekkuusuJerii,項目名稱:Solar,代碼行數:17,代碼來源:TileGravityHopper.java

示例5: transferIn

import net.minecraft.inventory.ISidedInventory; //導入依賴的package包/類
private boolean transferIn(BlockPos pos, ItemStack inserted, boolean test) {
	EnumFacing facing = getFacing();
	Pair<IItemHandler, ISidedInventory> inv = getInventory(pos, facing);
	if(inv.getKey() != null) {
		IItemHandler handler = inv.getKey();
		ISidedInventory tile = inv.getValue();

		for(int slot = 0; slot < handler.getSlots(); slot++) {
			ItemStack inSlot = handler.getStackInSlot(slot);
			if(tile != null && !tile.canInsertItem(slot, inserted, facing)) return false;
			if(inSlot.isEmpty() || (ItemHandlerHelper.canItemStacksStack(inSlot, inserted) && (inSlot.getCount() < inSlot.getMaxStackSize() && inSlot.getCount() < handler.getSlotLimit(slot)))) {
				return handler.insertItem(slot, inserted, test) != inserted;
			}
		}
	}
	return false;
}
 
開發者ID:ArekkuusuJerii,項目名稱:Solar,代碼行數:18,代碼來源:TileGravityHopper.java

示例6: putStackInInventoryAllSlots

import net.minecraft.inventory.ISidedInventory; //導入依賴的package包/類
/**
 * Attempts to place the passed stack in the inventory, using as many slots as required. Returns leftover items
 */
public static ItemStack putStackInInventoryAllSlots(IInventory inventoryIn, IInventory stack, ItemStack side, @Nullable EnumFacing p_174918_3_)
{
    if (stack instanceof ISidedInventory && p_174918_3_ != null)
    {
        ISidedInventory isidedinventory = (ISidedInventory)stack;
        int[] aint = isidedinventory.getSlotsForFace(p_174918_3_);

        for (int k = 0; k < aint.length && !side.func_190926_b(); ++k)
        {
            side = insertStack(inventoryIn, stack, side, aint[k], p_174918_3_);
        }
    }
    else
    {
        int i = stack.getSizeInventory();

        for (int j = 0; j < i && !side.func_190926_b(); ++j)
        {
            side = insertStack(inventoryIn, stack, side, j, p_174918_3_);
        }
    }

    return side;
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:28,代碼來源:TileEntityHopper.java

示例7: WidgetSlot

import net.minecraft.inventory.ISidedInventory; //導入依賴的package包/類
public WidgetSlot(final IInventory inv, final int slot, final int x, final int y) {
    super(inv, slot, x + 1, y + 1);
    this.isISided = (inv instanceof ISidedInventory);
    this.side = 0;
    if (this.isISided) {
        this.side = 0;
        while (this.side < 6) {
            final int[] arr$;
            final int[] slots = arr$ = ((ISidedInventory)inv).getAccessibleSlotsFromSide(this.side);
            for (final int s : arr$) {
                if (s == slot) {
                    return;
                }
            }
            ++this.side;
        }
    }
}
 
開發者ID:sameer,項目名稱:ExtraUtilities,代碼行數:19,代碼來源:WidgetSlot.java

示例8: getFirstExtractableItemStackSlot

import net.minecraft.inventory.ISidedInventory; //導入依賴的package包/類
private static int getFirstExtractableItemStackSlot(final IInventory inv, final int side) {
    for (final int i : XUHelper.getInventorySideSlots(inv, side)) {
        final ItemStack item = inv.getStackInSlot(i);
        if (item != null && item.stackSize > 0 && (!(inv instanceof ISidedInventory) || ((ISidedInventory)inv).canExtractItem(i, item, side))) {
            if (!item.getItem().hasContainerItem(item)) {
                return i;
            }
            final ItemStack t = item.getItem().getContainerItem(item);
            for (final int j : XUHelper.getInventorySideSlots(inv, side)) {
                if (((j != i && inv.getStackInSlot(j) == null) || (j == i && item.stackSize == 1)) && inv.isItemValidForSlot(j, t) && (!(inv instanceof ISidedInventory) || ((ISidedInventory)inv).canInsertItem(i, t, side))) {
                    return i;
                }
            }
        }
    }
    return -1;
}
 
開發者ID:sameer,項目名稱:ExtraUtilities,代碼行數:18,代碼來源:TileEntityTransferNodeInventory.java

示例9: isValidTileEntity

import net.minecraft.inventory.ISidedInventory; //導入依賴的package包/類
public static boolean isValidTileEntity(final TileEntity inv, final int side) {
    if (inv == null) {
        return false;
    }
    final ForgeDirection forgeSide = ForgeDirection.getOrientation(side);
    final String classname = inv.getClass().toString();
    if (classname.contains("thermalexpansion") && classname.contains("conduit")) {
        return false;
    }
    if (inv instanceof IFluidHandler) {
        final FluidTankInfo[] t = ((IFluidHandler)inv).getTankInfo(forgeSide);
        if (t != null && t.length != 0) {
            return true;
        }
    }
    if (inv instanceof IInventory && ((IInventory)inv).getSizeInventory() > 0) {
        if (!(inv instanceof ISidedInventory)) {
            return true;
        }
        final int[] t2 = ((ISidedInventory)inv).getAccessibleSlotsFromSide(side);
        if (t2 != null && t2.length != 0) {
            return true;
        }
    }
    return isRFEnergy(inv, forgeSide);
}
 
開發者ID:sameer,項目名稱:ExtraUtilities,代碼行數:27,代碼來源:TNHelper.java

示例10: InventoryRange

import net.minecraft.inventory.ISidedInventory; //導入依賴的package包/類
public InventoryRange(IInventory inv, int side)
{
    this.inv = inv;
    this.side = side;
    if(inv instanceof ISidedInventory)
    {
        sidedInv = (ISidedInventory)inv;
        slots = sidedInv.getAccessibleSlotsFromSide(side);
    }
    else
    {
        slots = new int[inv.getSizeInventory()];
        for(int i = 0; i < slots.length; i++)
            slots[i] = i;
    }
}
 
開發者ID:4Space,項目名稱:4Space-5,代碼行數:17,代碼來源:InventoryRange.java

示例11: doInsertItem

import net.minecraft.inventory.ISidedInventory; //導入依賴的package包/類
public static int doInsertItem(Object into, ItemStack item, EnumFacing side, boolean insert) {
	if (into == null || ItemStackTools.isNullStack(item)) {
		return 0;
	}
	if (into instanceof ISidedInventory) {
		return ItemUtil.doInsertItemInv((ISidedInventory) into, item, side, insert);
	} else if (into instanceof IInventory) {
		return ItemUtil.doInsertItemInv(getInventory((IInventory) into), item, side, insert);
	} else if (into instanceof IItemHandler){
		IItemHandler handler = (IItemHandler)into;
		int startSize = ItemStackTools.getStackSize(item);
		ItemStack res = ItemHandlerHelper.insertItemStacked(handler, item.copy(), !insert);
		int val = ItemStackTools.isNullStack(res) ? startSize : startSize - ItemStackTools.getStackSize(res);
		return val;
	}

	return 0;
}
 
開發者ID:Alec-WAM,項目名稱:CrystalMod,代碼行數:19,代碼來源:ItemUtil.java

示例12: getItemHandler

import net.minecraft.inventory.ISidedInventory; //導入依賴的package包/類
public static IItemHandler getItemHandler(World world, BlockPos pos, EnumFacing side, boolean includeEntities) {
	TileEntity te = world.getTileEntity(pos);
	if (te instanceof IDrawer) {
		return new DrawerWrapper((IDrawer) te);
	} else if (te instanceof IDrawerGroup) {
		return new DrawerGroupWrapper((IDrawerGroup) te);
	} else if (te == null || !te.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side)) {
		IInventory inv = includeEntities ? TileEntityHopper.getInventoryAtPosition(world, pos.getX(), pos.getY(), pos.getZ()) : (te instanceof IInventory ? (IInventory) te : null);
		if (inv != null) {
			if (inv instanceof ISidedInventory) {
				return new SidedInvWrapper((ISidedInventory) inv, side);
			} else {
				return new InvWrapper(inv);
			}
		} else
			return null;
	} else {
		return te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side);
	}
}
 
開發者ID:tom5454,項目名稱:Toms-Mod,代碼行數:21,代碼來源:TomsModUtils.java

示例13: canInsertItem

import net.minecraft.inventory.ISidedInventory; //導入依賴的package包/類
@Override
public boolean canInsertItem(int slot, ItemStack itemstack, EnumFacing direction) {
    if (slot < filters.length) {
        return true;
    }
    try {
        IInventory target = getRecursiveTarget();
        if (target == null) {
            return true;
        }
        if (target instanceof ISidedInventory) {
            return ((ISidedInventory) target).canInsertItem(slot - filters.length, itemstack, facing_direction) && itemPassesFilter(itemstack);
        }
        return itemPassesFilter(itemstack);
    } finally {
        endRecursion();
    }
}
 
開發者ID:purpleposeidon,項目名稱:Factorization,代碼行數:19,代碼來源:TileEntityParaSieve.java

示例14: canExtractItem

import net.minecraft.inventory.ISidedInventory; //導入依賴的package包/類
@Override
public boolean canExtractItem(int index, ItemStack itemstack, EnumFacing direction) {
    if (index < filters.length) {
        return true;
    }
    try {
        IInventory target = getRecursiveTarget();
        if (target == null) {
            return true;
        }
        if (target instanceof ISidedInventory) {
            return ((ISidedInventory) target).canExtractItem(index - filters.length, itemstack, facing_direction) && itemPassesFilter(itemstack);
        }
        return itemPassesFilter(itemstack);
    } finally {
        endRecursion();
    }
}
 
開發者ID:purpleposeidon,項目名稱:Factorization,代碼行數:19,代碼來源:TileEntityParaSieve.java

示例15: canAccessSlot

import net.minecraft.inventory.ISidedInventory; //導入依賴的package包/類
public static boolean canAccessSlot(IInventory inv, int slot) {
    if (inv instanceof ISidedInventory) {
        ISidedInventory isi = (ISidedInventory) inv;
        //O(n). Ugh.
        for (EnumFacing face : EnumFacing.VALUES) {
            int[] slots = isi.getSlotsForFace(face);
            for (int j = 0; j < slots.length; j++) {
                if (slots[j] == slot) {
                    return true;
                }
            }
        }
    } else {
        return true;
    }
    return false;
}
 
開發者ID:purpleposeidon,項目名稱:Factorization,代碼行數:18,代碼來源:InvUtil.java


注:本文中的net.minecraft.inventory.ISidedInventory類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。