本文整理汇总了Java中net.minecraft.item.ItemStack.isEmpty方法的典型用法代码示例。如果您正苦于以下问题:Java ItemStack.isEmpty方法的具体用法?Java ItemStack.isEmpty怎么用?Java ItemStack.isEmpty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.item.ItemStack
的用法示例。
在下文中一共展示了ItemStack.isEmpty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: amountRequested
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@Override
public int amountRequested(ItemStack stack) {
int totalRequestingAmount = getTotalRequestedAmount(stack);
if (totalRequestingAmount > 0) {
IItemHandler inv = IOHelper.getInventoryForTE(getTileEntity());
int count = 0;
if (inv != null) {
for (int i = 0; i < inv.getSlots(); i++) {
ItemStack s = inv.getStackInSlot(i);
if (!s.isEmpty() && isItemEqual(s, stack)) {
count += s.getCount();
}
}
count += getIncomingItems(stack);
return Math.max(0, Math.min(stack.getCount(), totalRequestingAmount - count));
}
}
return 0;
}
示例2: handleGUIButtonPress
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@Override
public void handleGUIButtonPress(int buttonID, EntityPlayer player) {
switch (buttonID) {
case 0:
if (++redstoneMode > 1) redstoneMode = 0;
break;
case 1:
ItemStack stack = inventory.getStackInSlot(PROGRAM_SLOT);
NBTTagCompound tag = stack.isEmpty() ? null : stack.getTagCompound();
if (tag != null)
readProgWidgetsFromNBT(tag);
else
progWidgets.clear();
break;
case 2:
tryProgramDrone(player);
break;
case 9:
undo();
break;
case 10:
redo();
break;
}
sendDescriptionPacket();
}
示例3: extractItem
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@Nonnull
@Override
public ItemStack extractItem(int slot, int amount, boolean simulate) {
if (amount == 0) return ItemStack.EMPTY;
ItemStack existing = tile.getItemStack().copy();
if (existing.isEmpty()) return ItemStack.EMPTY;
if (tile.getAmount() <= amount) {
int newAmount = tile.getAmount();
if (!simulate) {
tile.setAmount(0);
outItems.setStackInSlot(0, ItemStack.EMPTY);
}
return ItemHandlerHelper.copyStackWithSize(existing, newAmount);
} else {
if (!simulate) {
tile.setAmount(tile.amount - amount);
}
return ItemHandlerHelper.copyStackWithSize(existing, amount);
}
}
示例4: renderItemInWorld
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@SideOnly(Side.CLIENT)
public static void renderItemInWorld(ItemStack stack){
if(!stack.isEmpty()){
Minecraft mc = Minecraft.getMinecraft();
RenderItem renderer = mc.getRenderItem();
TextureManager manager = mc.getTextureManager();
IBakedModel model = renderer.getItemModelWithOverrides(stack, null, null);
manager.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
manager.getTexture(TextureMap.LOCATION_BLOCKS_TEXTURE).setBlurMipmap(false, false);
GlStateManager.enableRescaleNormal();
GlStateManager.enableBlend();
GlStateManager.pushMatrix();
model = ForgeHooksClient.handleCameraTransforms(model, ItemCameraTransforms.TransformType.FIXED, false);
renderer.renderItem(stack, model);
GlStateManager.cullFace(GlStateManager.CullFace.BACK);
GlStateManager.popMatrix();
GlStateManager.disableRescaleNormal();
GlStateManager.disableBlend();
manager.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
manager.getTexture(TextureMap.LOCATION_BLOCKS_TEXTURE).restoreLastBlurMipmap();
}
}
示例5: canSmelt
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
* Returns true if the furnace can smelt an item, i.e. has a source item, destination stack isn't full, etc.
*/
private boolean canSmelt(int id)
{
int inputIndex = type.getFirstInputSlot(id);
int outputIndex = type.getFirstOutputSlot(id);
ItemStack input = itemHandler.getStackInSlot(inputIndex);
ItemStack output = itemHandler.getStackInSlot(outputIndex);
if (input.isEmpty())
{
return false;
} else
{
ItemStack res = FurnaceRecipes.instance().getSmeltingResult(input);
if (res.isEmpty())
return false;
if (output.isEmpty())
return true;
if (!output.isItemEqual(res))
return false;
int result = output.getCount() + res.getCount();
return result <= itemHandler.getSlotLimit(outputIndex) && result <= res.getMaxStackSize();
}
}
示例6: getBlocksFromString
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public static ArrayList<Block> getBlocksFromString(String blockName)
{
ArrayList<Block> blocks = new ArrayList<>();
if(!HarshenUtils.toArray(Blocks.AIR, null).contains(Block.getBlockFromName(blockName)))
blocks.add(Block.getBlockFromName(blockName));
for(ItemStack oreStack : OreDictionary.getOres(blockName))
if(oreStack.getItem() instanceof ItemBlock)
blocks.add(((ItemBlock)oreStack.getItem()).getBlock());
ArrayList<Block> finalBlocks = new ArrayList<>();
for(Block b : blocks)
{
NonNullList<ItemStack> items = NonNullList.create();
b.getSubBlocks(CreativeTabs.SEARCH, items);
for(ItemStack stack : items)
if(!stack.isEmpty())
finalBlocks.add(Block.getBlockFromItem(stack.getItem()));
else
finalBlocks.add(b);
}
return finalBlocks;
}
示例7: fillInventory
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@Override
public void fillInventory(IInventory inventory, Random rand, LootContext context)
{
TileEntityChest chest = (TileEntityChest) inventory;
CustomLootContext.Builder context$builder = new CustomLootContext.Builder((WorldServer) chest.getWorld());
context$builder.withChestPos(chest.getPos());
CustomLootContext customContext = context$builder.build();
List<ItemStack> list = this.generateLootForPools(rand, customContext);
List<Integer> list1 = this.getEmptySlotsRandomized(inventory, rand);
this.shuffleItems(list, list1.size(), rand);
for (ItemStack itemstack : list)
{
if (list1.isEmpty())
{
LootSlashConquer.LOGGER.warn("Tried to over-fill a container");
return;
}
if (itemstack.isEmpty())
{
inventory.setInventorySlotContents(((Integer)list1.remove(list1.size() - 1)).intValue(), ItemStack.EMPTY);
}
else
{
inventory.setInventorySlotContents(((Integer)list1.remove(list1.size() - 1)).intValue(), itemstack);
}
}
}
示例8: updateStatus
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public void updateStatus()
{
TileEntity te = world.getTileEntity(pos);
if (te != null && te instanceof TileTranslationDesk)
{
TileTranslationDesk ttd = (TileTranslationDesk) te;
ItemStack stack = ttd.handler.getStackInSlot(0);
if (panel.translating)
{
status = Status.TRANSLATING;
return;
}
entryName = null;
if (!stack.isEmpty())
{
for (Pair<IfEntry, IRSTranslatePapyrus> p : PurMag.INSTANCE.getIfRegistry().getAllResearchableSteps(IRSTranslatePapyrus.class, Minecraft.getMinecraft().player))
{
if (p.getRight().isSuitable(stack))
{
this.entryName = p.getLeft().getId();
this.stack = stack;
status = Status.CAN_TRANSLATE;
return;
}
}
status = Status.CANT_TRANSLATE;
return;
}
}
status = Status.NO_PAPYRUS;
}
示例9: isEmpty
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@Override
public boolean isEmpty () {
for (ItemStack stack : furnaceItemStacks) {
if (!stack.isEmpty())
return false;
}
return true;
}
示例10: getData
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public static WeaponData getData(ItemStack stack) {
WeaponData value = BLANK_DATA;
if(!stack.isEmpty() && stack.hasCapability(TF2weapons.WEAPONS_DATA_CAP, null)) {
value=stack.getCapability(TF2weapons.WEAPONS_DATA_CAP, null).inst;
if (value == BLANK_DATA && stack.hasTagCompound() && MapList.nameToData.containsKey(stack.getTagCompound().getString("Type")))
value = stack.getCapability(TF2weapons.WEAPONS_DATA_CAP, null).inst = MapList.nameToData.get(stack.getTagCompound().getString("Type"));
}
return value;
}
示例11: doImport
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
protected boolean doImport(int maxItems) {
boolean success = false;
// Suck from input inventory
IItemHandler handler = IOHelper.getInventoryForTE(IOHelper.getNeighbor(this, inputDir));
if (handler != null) {
for (int i = 0; i < maxItems; i++) {
LocatedItemStack extracted = IOHelper.extractOneItem(handler, true);
if (!extracted.stack.isEmpty()) {
ItemStack excess = ItemHandlerHelper.insertItem(inventory, extracted.stack, false);
if (excess.isEmpty()) {
handler.extractItem(extracted.slot, 1, false);
success = true;
} else {
break;
}
} else {
break;
}
}
}
// Suck in item entities
for (EntityItem entity : getNeighborItems(this, inputDir)) {
if (!entity.isDead) {
ItemStack remainder = IOHelper.insert(this, entity.getItem(), null, false);
if (remainder.isEmpty()) {
entity.setDead();
success = true;
}
}
}
return success;
}
示例12: matches
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@Override
public boolean matches(InventoryCrafting inv, World worldIn) {
ArrayList<ItemStack> stacks = new ArrayList<>();
for (int x = 0; x < inv.getSizeInventory(); x++) {
ItemStack stack = inv.getStackInSlot(x);
if (!stack.isEmpty())
if (stacks.size() < 2 && stack.getItem() instanceof ItemFromData && ItemFromData.getData(stack).getInt(PropertyType.COST) >= 6)
stacks.add(stack);
else
return false;
}
// System.out.println("matches "+(australium&&stack2!=null));
return stacks.size() == 2;
}
示例13: getSlotData
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@SuppressWarnings("SuspiciousNameCombination")
public static Map<Pair<Integer, Integer>, Boolean> getSlotData(EntityPlayer player)
{
HashMap<Pair<Integer, Integer>, Boolean> ret = Maps.newHashMap();
for (int i = 9; i < 36; ++i)
{
ItemStack is = player.inventory.getStackInSlot(i);
if (!is.isEmpty())
{
int x = (i - 9) % 9;
int y = (i - 9) / 9;
ret.put(Pair.of(x, y), true);
if (getVolume(is) != defaultVolume)
{
Pair<Byte, Byte> volume = getVolume(is);
for (byte b = 0; b < volume.getLeft(); ++b)
{
for (byte b1 = 0; b1 < volume.getRight(); ++b1)
{
ret.put(Pair.of(x + b, y + b1), true);
}
}
}
}
}
return ret;
}
示例14: getCraftingResult
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
* Returns an Item that is the result of this recipe
*/
@Override
@Nonnull
public ItemStack getCraftingResult(@Nonnull InventoryCrafting var1) {
ItemStack newOutput = this.output.copy();
ItemStack cartridge = ItemStack.EMPTY;
ItemStack portalgun = ItemStack.EMPTY;
for (int i = 0; i < var1.getSizeInventory(); ++i) {
ItemStack stack = var1.getStackInSlot(i);
if (!stack.isEmpty()) {
if (stack.getItem() instanceof CartridgeItem) {
cartridge = stack;
} else if (stack.getItem() instanceof EmptyPortalGunItem) {
portalgun = stack;
}
}
}
if (portalgun.hasTagCompound()) {
newOutput.setTagCompound(portalgun.getTagCompound().copy());
}
if (!cartridge.isEmpty()) {
int charge = CartridgeItem.getCharge(cartridge);
PortalGunItem.setCharge(newOutput, charge);
}
return newOutput;
}
示例15: shuffleItems
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
* shuffles items by changing their order and splitting stacks
*/
private void shuffleItems(List<ItemStack> stacks, int p_186463_2_, Random rand)
{
List<ItemStack> list = Lists.<ItemStack>newArrayList();
Iterator<ItemStack> iterator = stacks.iterator();
while (iterator.hasNext())
{
ItemStack itemstack = iterator.next();
if (itemstack.isEmpty())
{
iterator.remove();
}
else if (itemstack.getCount() > 1)
{
list.add(itemstack);
iterator.remove();
}
}
p_186463_2_ = p_186463_2_ - stacks.size();
while (p_186463_2_ > 0 && !list.isEmpty())
{
ItemStack itemstack2 = list.remove(MathHelper.getInt(rand, 0, list.size() - 1));
int i = MathHelper.getInt(rand, 1, itemstack2.getCount() / 2);
ItemStack itemstack1 = itemstack2.splitStack(i);
if (itemstack2.getCount() > 1 && rand.nextBoolean())
{
list.add(itemstack2);
}
else
{
stacks.add(itemstack2);
}
if (itemstack1.getCount() > 1 && rand.nextBoolean())
{
list.add(itemstack1);
}
else
{
stacks.add(itemstack1);
}
}
stacks.addAll(list);
Collections.shuffle(stacks, rand);
}