本文整理汇总了Java中net.minecraft.inventory.ISidedInventory.getSlotsForFace方法的典型用法代码示例。如果您正苦于以下问题:Java ISidedInventory.getSlotsForFace方法的具体用法?Java ISidedInventory.getSlotsForFace怎么用?Java ISidedInventory.getSlotsForFace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.inventory.ISidedInventory
的用法示例。
在下文中一共展示了ISidedInventory.getSlotsForFace方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: isValidItemFor
import net.minecraft.inventory.ISidedInventory; //导入方法依赖的package包/类
protected boolean isValidItemFor(ItemStack item, TileEntity target, EnumFacing side){
if(item == null) return false;
if(target instanceof IInventory){
BlockPos targetPos = target.getPos();
ISidedInventory dt = InventoryWrapper.wrap(TileEntityHopper.getInventoryAtPosition(getWorld(),targetPos.getX(), targetPos.getY(), targetPos.getZ()));
int[] slots = dt.getSlotsForFace(side);
for(int i = 0; i < slots.length; i++){
int slot = slots[i];
if(dt.canInsertItem(slot, item, side)){
return true;
}
}
return false;
}else{
return true;
}
}
示例4: canInsertItemInto
import net.minecraft.inventory.ISidedInventory; //导入方法依赖的package包/类
protected static boolean canInsertItemInto(ItemStack item, ISidedInventory dest, EnumFacing destFace){
if(item == null || item.getItem() == null || isLocked(dest)){
return false;
}
int[] slots = dest.getSlotsForFace(destFace);
for(int i = 0; i < slots.length; i++){
int slot = slots[i];
if(dest.canInsertItem(slot, item, destFace)){
ItemStack destItem = dest.getStackInSlot(slot);
if(destItem == null) {
return true;
} else {
return ItemStack.areItemsEqual(item, destItem);
}
}
}
return false;
}
示例5: canInsert
import net.minecraft.inventory.ISidedInventory; //导入方法依赖的package包/类
private boolean canInsert(ItemStack item, EnumFacing f){
TileEntity target = getWorld().getTileEntity(getPos().offset(f));
if(target instanceof IInventory){
EnumFacing side = f.getOpposite();
ISidedInventory dt = InventoryWrapper.wrap((IInventory)target);
int[] slots = dt.getSlotsForFace(side);
for(int i = 0; i < slots.length; i++){
int slot = slots[i];
if(dt.canInsertItem(slot, item, side)){
ItemStack targetSlot = dt.getStackInSlot(slot);
if( (targetSlot == null) ||
(ItemStack.areItemsEqual(item, targetSlot)
&& !targetSlot.getItem().isDamageable()
&& targetSlot.stackSize < targetSlot.getMaxStackSize()
&& targetSlot.stackSize < dt.getInventoryStackLimit())){
return true;
}
}
}
return false;
}else{
return false;
}
}
示例6: isInventoryFull
import net.minecraft.inventory.ISidedInventory; //导入方法依赖的package包/类
/**
* Returns false if the inventory has any room to place items in
*/
private boolean isInventoryFull(IInventory inventoryIn, EnumFacing side)
{
if (inventoryIn instanceof ISidedInventory)
{
ISidedInventory isidedinventory = (ISidedInventory)inventoryIn;
int[] aint = isidedinventory.getSlotsForFace(side);
for (int k = 0; k < aint.length; ++k)
{
ItemStack itemstack1 = isidedinventory.getStackInSlot(aint[k]);
if (itemstack1 == null || itemstack1.stackSize != itemstack1.getMaxStackSize())
{
return false;
}
}
}
else
{
int i = inventoryIn.getSizeInventory();
for (int j = 0; j < i; ++j)
{
ItemStack itemstack = inventoryIn.getStackInSlot(j);
if (itemstack == null || itemstack.stackSize != itemstack.getMaxStackSize())
{
return false;
}
}
}
return true;
}
示例7: 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, ItemStack stack, EnumFacing side)
{
if (inventoryIn instanceof ISidedInventory && side != null)
{
ISidedInventory isidedinventory = (ISidedInventory)inventoryIn;
int[] aint = isidedinventory.getSlotsForFace(side);
for (int k = 0; k < aint.length && stack != null && stack.stackSize > 0; ++k)
{
stack = insertStack(inventoryIn, stack, aint[k], side);
}
}
else
{
int i = inventoryIn.getSizeInventory();
for (int j = 0; j < i && stack != null && stack.stackSize > 0; ++j)
{
stack = insertStack(inventoryIn, stack, j, side);
}
}
if (stack != null && stack.stackSize == 0)
{
stack = null;
}
return stack;
}
示例8: isInventoryEmpty
import net.minecraft.inventory.ISidedInventory; //导入方法依赖的package包/类
/**
* Returns false if the specified IInventory contains any items
*/
private static boolean isInventoryEmpty(IInventory inventoryIn, EnumFacing side)
{
if (inventoryIn instanceof ISidedInventory)
{
ISidedInventory isidedinventory = (ISidedInventory)inventoryIn;
int[] aint = isidedinventory.getSlotsForFace(side);
for (int i = 0; i < aint.length; ++i)
{
if (isidedinventory.getStackInSlot(aint[i]) != null)
{
return false;
}
}
}
else
{
int j = inventoryIn.getSizeInventory();
for (int k = 0; k < j; ++k)
{
if (inventoryIn.getStackInSlot(k) != null)
{
return false;
}
}
}
return true;
}
示例9: 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, ItemStack stack, @Nullable EnumFacing side)
{
if (inventoryIn instanceof ISidedInventory && side != null)
{
ISidedInventory isidedinventory = (ISidedInventory)inventoryIn;
int[] aint = isidedinventory.getSlotsForFace(side);
for (int k = 0; k < aint.length && stack != null && stack.stackSize > 0; ++k)
{
stack = insertStack(inventoryIn, stack, aint[k], side);
}
}
else
{
int i = inventoryIn.getSizeInventory();
for (int j = 0; j < i && stack != null && stack.stackSize > 0; ++j)
{
stack = insertStack(inventoryIn, stack, j, side);
}
}
if (stack != null && stack.stackSize == 0)
{
stack = null;
}
return stack;
}
示例10: isInventoryEmpty
import net.minecraft.inventory.ISidedInventory; //导入方法依赖的package包/类
/**
* Returns false if the specified IInventory contains any items
*/
private static boolean isInventoryEmpty(IInventory inventoryIn, EnumFacing side)
{
if (inventoryIn instanceof ISidedInventory)
{
ISidedInventory isidedinventory = (ISidedInventory)inventoryIn;
int[] aint = isidedinventory.getSlotsForFace(side);
for (int i : aint)
{
if (isidedinventory.getStackInSlot(i) != null)
{
return false;
}
}
}
else
{
int j = inventoryIn.getSizeInventory();
for (int k = 0; k < j; ++k)
{
if (inventoryIn.getStackInSlot(k) != null)
{
return false;
}
}
}
return true;
}
示例11: isInventoryFull
import net.minecraft.inventory.ISidedInventory; //导入方法依赖的package包/类
/**
* Returns false if the inventory has any room to place items in
*/
private boolean isInventoryFull(IInventory inventoryIn, EnumFacing side)
{
if (inventoryIn instanceof ISidedInventory)
{
ISidedInventory isidedinventory = (ISidedInventory)inventoryIn;
int[] aint = isidedinventory.getSlotsForFace(side);
for (int k : aint)
{
ItemStack itemstack1 = isidedinventory.getStackInSlot(k);
if (itemstack1.func_190926_b() || itemstack1.func_190916_E() != itemstack1.getMaxStackSize())
{
return false;
}
}
}
else
{
int i = inventoryIn.getSizeInventory();
for (int j = 0; j < i; ++j)
{
ItemStack itemstack = inventoryIn.getStackInSlot(j);
if (itemstack.func_190926_b() || itemstack.func_190916_E() != itemstack.getMaxStackSize())
{
return false;
}
}
}
return true;
}
示例12: isInventoryEmpty
import net.minecraft.inventory.ISidedInventory; //导入方法依赖的package包/类
/**
* Returns false if the specified IInventory contains any items
*/
private static boolean isInventoryEmpty(IInventory inventoryIn, EnumFacing side)
{
if (inventoryIn instanceof ISidedInventory)
{
ISidedInventory isidedinventory = (ISidedInventory)inventoryIn;
int[] aint = isidedinventory.getSlotsForFace(side);
for (int i : aint)
{
if (!isidedinventory.getStackInSlot(i).func_190926_b())
{
return false;
}
}
}
else
{
int j = inventoryIn.getSizeInventory();
for (int k = 0; k < j; ++k)
{
if (!inventoryIn.getStackInSlot(k).func_190926_b())
{
return false;
}
}
}
return true;
}
示例13: update
import net.minecraft.inventory.ISidedInventory; //导入方法依赖的package包/类
@Override
public void update(){
super.update();
if(!getWorld().isRemote){
boolean powerChanged = (lastSyncPowerStored != getEnergyStored() && shouldDoWorkThisTick(5));
if(powerChanged) {
lastSyncPowerStored = getEnergyStored();
NBTTagCompound nbt = new NBTTagCompound();
nbt.setInteger("Power", getEnergyStored());
CrystalModNetwork.sendToAllAround(new PacketTileMessage(getPos(), "UpdatePower", nbt), this);
}
ISidedInventory inv = getInventory();
if(inv !=null){
EnumFacing face = EnumFacing.getFront(facing);
int[] slots = inv.getSlotsForFace(face.getOpposite());
for(int i = 0; i < slots.length; i++){
int s = slots[i];
ItemStack stack = inv.getStackInSlot(s);
if(ItemStackTools.isValid(stack)){
if(canChargeItem(stack)){
chargeItem(stack);
}
}
}
}
}
}
示例14: InventoryRange
import net.minecraft.inventory.ISidedInventory; //导入方法依赖的package包/类
public InventoryRange(IInventory inv, EnumFacing side) {
this.inv = inv;
this.face = side;
if (inv instanceof ISidedInventory) {
sidedInv = (ISidedInventory) inv;
slots = sidedInv.getSlotsForFace(face);
} else {
slots = new int[inv.getSizeInventory()];
for (int i = 0; i < slots.length; i++) {
slots[i] = i;
}
}
}
示例15: isInventoryEmpty
import net.minecraft.inventory.ISidedInventory; //导入方法依赖的package包/类
private static boolean isInventoryEmpty(IInventory inventoryIn, EnumFacing side)
{
if (inventoryIn instanceof ISidedInventory)
{
ISidedInventory isidedinventory = (ISidedInventory)inventoryIn;
int[] aint = isidedinventory.getSlotsForFace(side);
for (int i : aint)
{
if (isidedinventory.getStackInSlot(i) != null)
{
return false;
}
}
}
else
{
int j = inventoryIn.getSizeInventory();
for (int k = 0; k < j; ++k)
{
if (inventoryIn.getStackInSlot(k) != null)
{
return false;
}
}
}
return true;
}