当前位置: 首页>>代码示例>>Java>>正文


Java Slot.peek方法代码示例

本文整理汇总了Java中org.spongepowered.api.item.inventory.Slot.peek方法的典型用法代码示例。如果您正苦于以下问题:Java Slot.peek方法的具体用法?Java Slot.peek怎么用?Java Slot.peek使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.spongepowered.api.item.inventory.Slot的用法示例。


在下文中一共展示了Slot.peek方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: CachedInventory

import org.spongepowered.api.item.inventory.Slot; //导入方法依赖的package包/类
public CachedInventory(Inventory inv) {
    super(inv, false);

    this.name = inv.getName().get();
    this.capacity = inv.capacity();
    this.totalItems = inv.totalItems();
    this.type = new CachedCatalogType(inv.getArchetype());

    items = new ArrayList<>();
    try {
        for (Inventory subInv : inv.slots()) {
            Slot slot = (Slot) subInv;
            Optional<ItemStack> optItem = slot.peek();
            optItem.ifPresent(itemStack -> items.add(itemStack.copy()));
        }
    } catch (AbstractMethodError ignored) {}
}
 
开发者ID:Valandur,项目名称:Web-API,代码行数:18,代码来源:CachedInventory.java

示例2: serialize

import org.spongepowered.api.item.inventory.Slot; //导入方法依赖的package包/类
@Override
public void serialize(T object, DataView dataView) {
    super.serialize(object, dataView);
    final ObjectSerializer<LanternItemStack> itemStackSerializer =  ObjectSerializerRegistry.get().get(LanternItemStack.class).get();
    final List<DataView> itemViews = new ArrayList<>();
    final Inventory inventory = object.getInventory();
    final Iterable<Slot> slots = inventory.slots();
    for (Slot slot : slots) {
        final Optional<ItemStack> optItemStack = slot.peek();
        if (!optItemStack.isPresent()) {
            continue;
        }
        final DataView itemView = itemStackSerializer.serialize((LanternItemStack) optItemStack.get());
        //noinspection ConstantConditions
        itemView.set(SLOT, (byte) inventory.getProperty(slot, SlotIndex.class, null).get().getValue().intValue());
        itemViews.add(itemView);
    }
    dataView.set(ITEMS, itemViews);
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:20,代码来源:ContainerTileEntityStore.java

示例3: clear

import org.spongepowered.api.item.inventory.Slot; //导入方法依赖的package包/类
@Override
@SuppressWarnings("deprecation")
public int clear(int id, int data) {
    int removed = 0;
    for (Slot slot : this.getHandle().<Slot>slots()) {
        Optional<org.spongepowered.api.item.inventory.ItemStack> stackOptional = slot.peek();
        if (stackOptional.isPresent()) {
            org.spongepowered.api.item.inventory.ItemStack stack = stackOptional.get();
            if (id == -1 || stack.getItem() == MaterialConverter.asItem(Material.getMaterial(id))) {
                int damage = DurabilityConverter.getDamageValue(stack.getContainers());
                if (data == -1 || damage == data) {
                    removed += stack.getQuantity();
                    slot.clear();
                }
            }
        }
    }
    return removed;
}
 
开发者ID:LapisBlue,项目名称:Pore,代码行数:20,代码来源:PorePlayerInventory.java

示例4: countItems

import org.spongepowered.api.item.inventory.Slot; //导入方法依赖的package包/类
public int countItems(Inventory i, ItemType type){
	int count = 0;
	
	for (Inventory isl : i.query(QueryOperationTypes.ITEM_TYPE.of(type)).slots()){
		Slot sl = (Slot) isl;
		Optional<ItemStack> ois = sl.peek();
		if (ois.isPresent()){
			count += ois.get().getQuantity();
		}
	}
	
	return count;
}
 
开发者ID:TBlueF,项目名称:RottenFood,代码行数:14,代码来源:RottenFood.java

示例5: serializeEnderChest

import org.spongepowered.api.item.inventory.Slot; //导入方法依赖的package包/类
private static List<DataView> serializeEnderChest(GridInventory enderChestInventory) {
    final List<DataView> itemViews = new ArrayList<>();
    final Iterable<Slot> slots = enderChestInventory.slots();
    for (Slot slot : slots) {
        final Optional<ItemStack> optItemStack = slot.peek();
        if (!optItemStack.isPresent()) {
            continue;
        }
        final DataView itemView = ItemStackStore.INSTANCE.serialize((LanternItemStack) optItemStack.get());
        itemView.set(SLOT, (byte) enderChestInventory.getProperty(slot, SlotIndex.class, null).get().getValue().intValue());
        itemViews.add(itemView);
    }

    return itemViews;
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:16,代码来源:UserStore.java

示例6: serializeSlot

import org.spongepowered.api.item.inventory.Slot; //导入方法依赖的package包/类
private static void serializeSlot(int index, Slot slot, ObjectSerializer<LanternItemStack> itemStackSerializer, List<DataView> views) {
    final Optional<ItemStack> optItemStack = slot.peek();
    if (!optItemStack.isPresent()) {
        return;
    }
    final ItemStack itemStack = optItemStack.get();
    final DataView itemView = itemStackSerializer.serialize((LanternItemStack) itemStack);
    itemView.set(SLOT, (byte) index);
    views.add(itemView);
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:11,代码来源:UserStore.java

示例7: remove

import org.spongepowered.api.item.inventory.Slot; //导入方法依赖的package包/类
@Override
public void remove(Material material) throws IllegalArgumentException {
    for (Slot slot : this.getHandle().<Slot>slots()) {
        Optional<org.spongepowered.api.item.inventory.ItemStack> stack = slot.peek();
        if (stack.isPresent()) {
            if (stack.get().getItem() == MaterialConverter.asItem(material)) {
                slot.clear();
                return;
            }
        }
    }
}
 
开发者ID:LapisBlue,项目名称:Pore,代码行数:13,代码来源:PoreInventory.java


注:本文中的org.spongepowered.api.item.inventory.Slot.peek方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。