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


Java InventoryPlayer.getSizeInventory方法代碼示例

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


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

示例1: getParameters

import net.minecraft.entity.player.InventoryPlayer; //導入方法依賴的package包/類
private boolean getParameters(String parameter, List<Integer> parsedParams)
{
    String[] params = parameter.split(" ");
    if (params.length != 2)
    {
        System.out.println("Malformed parameter string (" + parameter + ") - expected <x> <y>");
        return false;   // Error - incorrect number of parameters.
    }
    Integer lhs, rhs;
    try
    {
        lhs = Integer.valueOf(params[0]);
        rhs = Integer.valueOf(params[1]);
    }
    catch (NumberFormatException e)
    {
        System.out.println("Malformed parameter string (" + parameter + ") - " + e.getMessage());
        return false;
    }
    if (lhs == null || rhs == null)
    {
        System.out.println("Malformed parameter string (" + parameter + ")");
        return false;   // Error - incorrect parameters.
    }
    InventoryPlayer inv = Minecraft.getMinecraft().thePlayer.inventory;
    if (lhs < 0 || lhs >= inv.getSizeInventory() || rhs < 0 || rhs >= inv.getSizeInventory())
    {
        System.out.println("Inventory swap parameters out of bounds - must be between 0 and " + (inv.getSizeInventory() - 1));
        return false;   // Out of bounds.
    }
    parsedParams.add(lhs);
    parsedParams.add(rhs);
    return true;
}
 
開發者ID:Yarichi,項目名稱:Proyecto-DASI,代碼行數:35,代碼來源:InventoryCommandsImplementation.java

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: getHotBarItems

import net.minecraft.entity.player.InventoryPlayer; //導入方法依賴的package包/類
private List<ItemStack> getHotBarItems(EntityPlayer player) {
	InventoryPlayer inv = player.inventory;
	List<ItemStack> items = new ArrayList<>();
	for (int i = 0; i < inv.getSizeInventory(); i++) {
		if (InventoryPlayer.isHotbar(i)) {
			items.add(inv.getStackInSlot(i));
		}
	}
	return items;
}
 
開發者ID:ToroCraft,項目名稱:NemesisSystem,代碼行數:11,代碼來源: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

示例8: findFirstAvailableSlotFor

import net.minecraft.entity.player.InventoryPlayer; //導入方法依賴的package包/類
@SuppressWarnings("SuspiciousNameCombination")
   public static int findFirstAvailableSlotFor(ItemStack is, Optional<Map<Pair<Integer, Integer>, Boolean>> data, EntityPlayer player)
{
	InventoryPlayer inventory = player.inventory;
	for (int i = 0; i < inventory.getSizeInventory(); ++i)
	{
		ItemStack stack = player.inventory.getStackInSlot(i);
		if (ItemStack.areItemsEqual(stack, is) && ItemStack.areItemStackTagsEqual(stack, is))
		{
			int max = Math.min(player.openContainer != null ? player.openContainer.getSlot(i).getItemStackLimit(stack) : inventory.getInventoryStackLimit(), stack.getMaxStackSize());
			if (stack.getCount() < max)
			{
				return Short.MAX_VALUE + i;
			}
		}
	}
	
	for (int i = 0; i < 9; ++i)
	{
		if (inventory.getStackInSlot(i).isEmpty())
		{
			return i;
		}
	}
	
	Map<Pair<Integer, Integer>, Boolean> lookup = data.orElseGet(() -> PlayerInventoryHelper.getSlotData(player));
	Pair<Byte, Byte> volume = getVolume(is);
	slotLoop: for (int i = 9; i < 36; ++i)
	{
		int x = (i - 9) % 9;
		int y = (i - 9) / 9;
		if (x + volume.getLeft() > 9 || y + volume.getRight() > 3)
		{
			continue;
		}
		
		Pair<Integer, Integer> pos = Pair.of(x, y);
		if (lookup.containsKey(pos) && lookup.get(pos))
		{
			continue;
		}
		
		for (int dx = x; dx < x + volume.getLeft(); ++dx)
		{
			for (int dy = y; dy < y + volume.getRight(); ++dy)
			{
				pos = Pair.of(dx, dy);
				if (dx >= 9 || dy >= 3 || (lookup.containsKey(pos) && lookup.get(pos)))
				{
				    continue slotLoop;
				}
			}
		}
		
		return i;
	}
	
	return -1;
}
 
開發者ID:V0idWa1k3r,項目名稱:ExPetrum,代碼行數:60,代碼來源:PlayerInventoryHelper.java


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