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


Java InventoryPlayer.getStackInSlot方法代碼示例

本文整理匯總了Java中net.minecraft.entity.player.InventoryPlayer.getStackInSlot方法的典型用法代碼示例。如果您正苦於以下問題:Java InventoryPlayer.getStackInSlot方法的具體用法?Java InventoryPlayer.getStackInSlot怎麽用?Java InventoryPlayer.getStackInSlot使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在net.minecraft.entity.player.InventoryPlayer的用法示例。


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

示例1: getDankNullForStack

import net.minecraft.entity.player.InventoryPlayer; //導入方法依賴的package包/類
public static ItemStack getDankNullForStack(EntityPlayer player, ItemStack stack) {
	InventoryPlayer playerInv = player.inventory;
	ItemStack dankNullItem = ItemStack.EMPTY;
	int invSize = playerInv.getSizeInventory();
	if (invSize <= 0) {
		return ItemStack.EMPTY;
	}
	for (int i = 0; i < invSize; i++) {
		ItemStack itemStack = playerInv.getStackInSlot(i);
		if (!itemStack.isEmpty()) {
			if ((itemStack.getItem() instanceof ItemDankNull)) {
				if (!isFiltered(getNewDankNullInventory(itemStack), stack).isEmpty()) {
					dankNullItem = itemStack;
					break;
				}
			}
		}
	}
	return dankNullItem;
}
 
開發者ID:p455w0rd,項目名稱:DankNull,代碼行數:21,代碼來源:DankNullUtils.java

示例2: getDankNull

import net.minecraft.entity.player.InventoryPlayer; //導入方法依賴的package包/類
@Nonnull
public static ItemStack getDankNull(EntityPlayer player) {
	InventoryPlayer playerInv = player.inventory;
	ItemStack dankNullItem = ItemStack.EMPTY;
	if (!player.getHeldItemMainhand().isEmpty()) {
		if ((player.getHeldItemMainhand().getItem() instanceof ItemDankNull)) {
			dankNullItem = player.getHeldItem(EnumHand.MAIN_HAND);
		}
		else if ((!player.getHeldItemOffhand().isEmpty()) && ((player.getHeldItemOffhand().getItem() instanceof ItemDankNull))) {
			dankNullItem = player.getHeldItem(EnumHand.OFF_HAND);
		}
	}
	else if (!player.getHeldItemOffhand().isEmpty()) {
		if ((player.getHeldItemOffhand().getItem() instanceof ItemDankNull)) {
			dankNullItem = player.getHeldItem(EnumHand.OFF_HAND);
		}
		else if ((!player.getHeldItemMainhand().isEmpty()) && ((player.getHeldItemMainhand().getItem() instanceof ItemDankNull))) {
			dankNullItem = player.getHeldItem(EnumHand.MAIN_HAND);
		}
	}
	if (dankNullItem.isEmpty()) {
		int invSize = playerInv.getSizeInventory();
		if (invSize <= 0) {
			return ItemStack.EMPTY;
		}
		for (int i = 0; i < invSize; i++) {
			ItemStack itemStack = playerInv.getStackInSlot(i);
			if (!itemStack.isEmpty()) {
				if ((itemStack.getItem() instanceof ItemDankNull)) {
					dankNullItem = itemStack;
					break;
				}
			}
		}
	}
	return dankNullItem;
}
 
開發者ID:p455w0rd,項目名稱:DankNull,代碼行數:38,代碼來源:DankNullUtils.java

示例3: ContainerDankNull

import net.minecraft.entity.player.InventoryPlayer; //導入方法依賴的package包/類
public ContainerDankNull(EntityPlayer player, InventoryDankNull inv) {
	inventoryDankNull = inv;
	InventoryPlayer playerInv = player.inventory;
	ItemStack dankNull = inv.getDankNull();
	int lockedSlot = -1;
	int numRows = dankNull.getItemDamage() + 1;
	for (int i = 0; i < playerInv.getSizeInventory(); i++) {
		ItemStack currStack = playerInv.getStackInSlot(i);
		if (!currStack.isEmpty() && currStack == dankNull) {
			lockedSlot = i;
		}
	}
	for (int i = 0; i < 9; i++) {
		addSlotToContainer(new SlotHotbar(player.inventory, i, i * 20 + (9 + i), 90 + (numRows - 1) + (numRows * 20 + 6), lockedSlot == i));

	}
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 9; j++) {
			addSlotToContainer(new SlotPlayerInventory(player.inventory, j + i * 9 + 9, j * 20 + (9 + j), 149 + (numRows - 1) + i - (6 - numRows) * 20 + i * 20));
		}
	}
	for (int i = 0; i < numRows; i++) {
		for (int j = 0; j < 9; j++) {
			addSlotToContainer(new SlotDankNull(inventoryDankNull, j + i * 9, j * 20 + (9 + j), 19 + i + i * 20));
		}
	}
}
 
開發者ID:p455w0rd,項目名稱:DankNull,代碼行數:28,代碼來源:ContainerDankNull.java

示例4: combineSlots

import net.minecraft.entity.player.InventoryPlayer; //導入方法依賴的package包/類
static void combineSlots(EntityPlayerMP player, int dst, int add)
{
    InventoryPlayer inv = player.inventory;
    ItemStack dstStack = inv.getStackInSlot(dst);
    ItemStack addStack = inv.getStackInSlot(add);

    if (addStack == null)
        return;    // Combination is a no-op.

    if (dstStack == null)   // Do a straight move - nothing to combine with.
    {
        inv.setInventorySlotContents(dst, addStack);
        inv.setInventorySlotContents(add, null);
        return;
    }

    // Check we can combine. This logic comes from InventoryPlayer.storeItemStack():
    boolean itemsMatch = dstStack.getItem() == addStack.getItem();
    boolean dstCanStack = dstStack.isStackable() && dstStack.stackSize < dstStack.getMaxStackSize() && dstStack.stackSize < inv.getInventoryStackLimit();
    boolean subTypesMatch = !dstStack.getHasSubtypes() || dstStack.getMetadata() == addStack.getMetadata();
    boolean tagsMatch = ItemStack.areItemStackTagsEqual(dstStack, addStack);
    if (itemsMatch && dstCanStack && subTypesMatch && tagsMatch)
    {
        // We can combine, so figure out how much we have room for:
        int limit = Math.min(dstStack.getMaxStackSize(), inv.getInventoryStackLimit());
        int room = limit - dstStack.stackSize;
        if (addStack.stackSize > room)
        {
            // Not room for all of it, so shift across as much as possible.
            addStack.stackSize -= room;
            dstStack.stackSize += room;
        }
        else
        {
            // Room for the whole lot, so empty out the add slot.
            dstStack.stackSize += addStack.stackSize;
            inv.setInventorySlotContents(add, null);
        }
    }
}
 
開發者ID:Yarichi,項目名稱:Proyecto-DASI,代碼行數:41,代碼來源:InventoryCommandsImplementation.java

示例5: swapSlots

import net.minecraft.entity.player.InventoryPlayer; //導入方法依賴的package包/類
static void swapSlots(EntityPlayerMP player, int lhs, int rhs)
{
    InventoryPlayer inv = player.inventory;
    ItemStack srcStack = inv.getStackInSlot(lhs);
    ItemStack dstStack = inv.getStackInSlot(rhs);
    inv.setInventorySlotContents(lhs, dstStack);
    inv.setInventorySlotContents(rhs, srcStack);
}
 
開發者ID:Yarichi,項目名稱:Proyecto-DASI,代碼行數:9,代碼來源:InventoryCommandsImplementation.java

示例6: logHotBarItems

import net.minecraft.entity.player.InventoryPlayer; //導入方法依賴的package包/類
private void logHotBarItems(EntityPlayer player) {
	InventoryPlayer inv = player.inventory;
	for (int i = 0; i < inv.getSizeInventory(); i++) {
		if (InventoryPlayer.isHotbar(i)) {
			ItemStack stack = inv.getStackInSlot(i);
			System.out.println(stack.getTagCompound());
		}
	}
}
 
開發者ID:ToroCraft,項目名稱:NemesisSystem,代碼行數:10,代碼來源:NemesisSystemCommand.java

示例7: update

import net.minecraft.entity.player.InventoryPlayer; //導入方法依賴的package包/類
@Override
public void update() {
    disCharging = false;
    charging = false;
    List<IPressurizable> chargingItems = new ArrayList<>();
    List<ItemStack> chargedStacks = new ArrayList<>();
    if (getChargingItem().getItem() instanceof IPressurizable) {
        chargingItems.add((IPressurizable) getChargingItem().getItem());
        chargedStacks.add(getChargingItem());
    }
    if (this.getUpgrades(EnumUpgrade.DISPENSER) > 0) {
        //creating a new word, 'entities padding'.
        List<Entity> entitiesPadding = getWorld().getEntitiesWithinAABB(Entity.class, new AxisAlignedBB(getPos().getX(), getPos().getY(), getPos().getZ(), getPos().getX() + 1, getPos().getY() + 2, getPos().getZ() + 1));
        for (Entity entity : entitiesPadding) {
            if (entity instanceof IPressurizable) {
                chargingItems.add((IPressurizable) entity);
                chargedStacks.add(null);
            } else if (entity instanceof EntityItem) {
                ItemStack entityStack = ((EntityItem) entity).getItem();
                if (entityStack.getItem() instanceof IPressurizable) {
                    chargingItems.add((IPressurizable) entityStack.getItem());
                    chargedStacks.add(entityStack);
                }
            } else if (entity instanceof EntityPlayer) {
                InventoryPlayer inv = ((EntityPlayer) entity).inventory;
                for (int i = 0; i < inv.getSizeInventory(); i++) {
                    ItemStack stack = inv.getStackInSlot(i);
                    if (stack.getItem() instanceof IPressurizable) {
                        chargingItems.add((IPressurizable) stack.getItem());
                        chargedStacks.add(stack);
                    }
                }
            }
        }
    }
    int speedMultiplier = (int) getSpeedMultiplierFromUpgrades();
    for (int i = 0; i < PneumaticValues.CHARGING_STATION_CHARGE_RATE * speedMultiplier; i++) {
        boolean charged = false;
        for (int j = 0; j < chargingItems.size(); j++) {
            IPressurizable chargingItem = chargingItems.get(j);
            ItemStack chargedItem = chargedStacks.get(j);
            if (chargingItem.getPressure(chargedItem) > getPressure() + 0.01F && chargingItem.getPressure(chargedItem) > 0F) {
                if (!getWorld().isRemote) {
                    chargingItem.addAir(chargedItem, -1);
                    addAir(1);
                }
                disCharging = true;
                renderAirProgress -= ANIMATION_AIR_SPEED;
                if (renderAirProgress < 0.0F) {
                    renderAirProgress += 1F;
                }
                charged = true;
            } else if (chargingItem.getPressure(chargedItem) < getPressure() - 0.01F && chargingItem.getPressure(chargedItem) < chargingItem.maxPressure(chargedItem)) {// if there is pressure, and the item isn't fully charged yet..
                if (!getWorld().isRemote) {
                    chargingItem.addAir(chargedItem, 1);
                    addAir(-1);
                }
                charging = true;
                renderAirProgress += ANIMATION_AIR_SPEED;
                if (renderAirProgress > 1.0F) {
                    renderAirProgress -= 1F;
                }
                charged = true;
            }
        }
        if (!charged) break;
    }

    if (!getWorld().isRemote && oldRedstoneStatus != shouldEmitRedstone()) {
        oldRedstoneStatus = shouldEmitRedstone();
        updateNeighbours();
    }

    super.update();

    if (!getWorld().isRemote) {
        List<Pair<EnumFacing, IAirHandler>> teList = getAirHandler(null).getConnectedPneumatics();
        if (teList.size() == 0) getAirHandler(null).airLeak(getRotation());
    }
}
 
開發者ID:TeamPneumatic,項目名稱:pnc-repressurized,代碼行數:81,代碼來源:TileEntityChargingStation.java


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