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