当前位置: 首页>>代码示例>>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;未经允许,请勿转载。