本文整理汇总了Java中org.spongepowered.api.item.inventory.Inventory.set方法的典型用法代码示例。如果您正苦于以下问题:Java Inventory.set方法的具体用法?Java Inventory.set怎么用?Java Inventory.set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.spongepowered.api.item.inventory.Inventory
的用法示例。
在下文中一共展示了Inventory.set方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getInventory
import org.spongepowered.api.item.inventory.Inventory; //导入方法依赖的package包/类
@Override
public Inventory getInventory() {
Inventory woop = Inventory.builder()
.property(InventoryDimension.PROPERTY_NAME, InventoryDimension.of(9,1))
.property(InventoryTitle.PROPERTY_NAME,InventoryTitle.of(Text.of(TextColors.DARK_RED,"INVALID CRATE TYPE!")))
.listener(InteractInventoryEvent.class, evt ->{
if(!(evt instanceof InteractInventoryEvent.Open) && !(evt instanceof InteractInventoryEvent.Close)){
evt.setCancelled(true);
}
//System.out.println(evt.getClass());
})
.build(plugin);
woop.offer(ItemStack.of(ItemTypes.BARRIER,256*2 + 64));
for(Inventory e : woop.slots()){
ItemStack b = e.peek().get();
b.setQuantity(1);
e.set(b);
}
return woop;
}
示例2: performRemoval
import org.spongepowered.api.item.inventory.Inventory; //导入方法依赖的package包/类
private void performRemoval(LookupLine line) {
World w = Sponge.getServer().getWorld(line.getWorld()).orElse(null);
if (w == null) return;
if (line.getTarget() instanceof ItemType) {
Optional<TileEntity> te = w.getTileEntity(line.getPos());
if (te.isPresent() && te.get() instanceof TileEntityCarrier) {
TileEntityCarrier c = (TileEntityCarrier) te.get();
Inventory i = c.getInventory();
Inventory slot = i.query(new SlotIndex(line.getSlot()));
slot.set(ItemStack.of(ItemTypes.NONE, 0));
}
} else if (line.getTarget() instanceof BlockType) {
BlockState block = BlockState.builder().blockType(BlockTypes.AIR).build();
w.setBlock(line.getPos(), block, Cause.source(container).build());
}
}
示例3: setInventory
import org.spongepowered.api.item.inventory.Inventory; //导入方法依赖的package包/类
public boolean setInventory(Player player, Inventory inventory, SlotIndex pos)
{
if (!this.plugin.getScriptManager().execute(player, this.requirements))
{
return false;
}
try
{
inventory.set(this.serializer.apply(player, this.serializedStack));
return true;
}
catch (InvalidDataException e)
{
String posString = VirtualChestInventory.slotIndexToKey(pos);
throw new InvalidDataException("Find error when generating item at " + posString, e);
}
}
示例4: load
import org.spongepowered.api.item.inventory.Inventory; //导入方法依赖的package包/类
@Override
public void load(Player player, String saveName) {
Iterator<Inventory> slots = player.getInventory().slots().iterator();
List<JsonElement> persistedInventoryContents = getInventoryContents(player, saveName);
for (int i = 0; slots.hasNext(); ++i) {
Inventory slot = slots.next();
if (i < persistedInventoryContents.size()) {
try {
ItemStack stack = deserializeItemStack(persistedInventoryContents.get(i));
slot.set(stack);
continue;
} catch (IOException e) {
e.printStackTrace();
}
}
slot.set(newItemStack(ItemTypes.NONE));
}
}
示例5: updateInv
import org.spongepowered.api.item.inventory.Inventory; //导入方法依赖的package包/类
private void updateInv(int state){
int slotNum = 0;
for(Inventory e : disp.slots()){
double speed = 3;
double confettiSpeed = 2;
if(slotNum != 4) {
if (tickCount == 0 || Math.round(tickCount / confettiSpeed) > Math.round((tickCount - 1) / confettiSpeed)) {
e.set(confetti());
} else {
e.set(e.peek().get());
}
}else if(holder == null){
try {
int i = itemIndexSelected();
e.set(((CrateReward)items.get(i)[1]).getDisplayItem());
holder = (CrateReward)items.get(i)[1];
ourplr.playSound(SoundTypes.ENTITY_FIREWORK_LAUNCH,ourplr.getLocation().getPosition(),1);
} catch (RandomItemSelectionFailureException e1) {
plugin.logger.error("Random Item Selection failed in Roulette Crate View: " + vc.displayName);
}
//e.set(((CrateRewardHolder)items.get(Math.round(tickCount/2) % items.size())[1]).getDisplayItem());
}else{
e.set(e.peek().get());
}
slotNum++;
}
}
示例6: performAddition
import org.spongepowered.api.item.inventory.Inventory; //导入方法依赖的package包/类
private void performAddition(LookupLine line) {
//TODO: Debug this function, blocks are not being added
World w = Sponge.getServer().getWorld(line.getWorld()).orElse(null);
if (w == null) return;
if (line.getTarget() instanceof ItemType) {
Optional<TileEntity> te = w.getTileEntity(line.getPos());
if (te.isPresent() && te.get() instanceof TileEntityCarrier) {
TileEntityCarrier c = (TileEntityCarrier) te.get();
Inventory i = c.getInventory();
ItemType type = (ItemType) line.getTarget();
ItemStack stack = ItemStack.builder()
.fromContainer(line.getDataAsView())
.itemType(type)
.quantity(line.getCount())
.build();
Inventory slot = i.query(new SlotIndex(line.getSlot()));
slot.set(stack);
}
} else if (line.getTarget() instanceof BlockType) {
BlockState block = BlockState.builder().build(line.getDataAsView()).orElse(null);
if (block != null)
w.setBlock(line.getPos(), block, Cause.source(container).build());
}
}
示例7: updateInv
import org.spongepowered.api.item.inventory.Inventory; //导入方法依赖的package包/类
private void updateInv(int state){
int secRemain = (10 - Math.round(tickCount / 20));
if(secRemain < 0)
stopped = true;
int slotNum = 0;
for(Inventory e : disp.slots()){
double speed = 3;
double confettiSpeed = 2;
if(slotNum != 4) {
if(stopped) {
if (tickCount == 0 || Math.round(tickCount / confettiSpeed) > Math.round((tickCount - 1) / confettiSpeed)) {
e.set(confetti());
} else {
e.set(e.peek().get());
}
}else{
ItemStack border;
if(Math.floor(slotNum / 3) != 1){
border = ItemStack.builder().itemType(ItemTypes.STAINED_GLASS_PANE).add(Keys.DYE_COLOR,DyeColors.BLACK).build();
}else{
border = ItemStack.builder().itemType(ItemTypes.STAINED_GLASS_PANE).add(Keys.DYE_COLOR,DyeColors.GRAY).build();
}
border.offer(Keys.DISPLAY_NAME,Text.of(TextStyles.RESET,"HuskyCrates"));
ArrayList<Text> itemLore = new ArrayList<>();
itemLore.add(Text.of(TextColors.DARK_GRAY, "Click anywhere to stop!"));
itemLore.add(Text.of(TextColors.DARK_GRAY, "Seconds remaining: " + secRemain));
border.offer(Keys.ITEM_LORE, itemLore);
e.set(border);
}
}else if(!stopped&&(tickCount == 0 || Math.round(tickCount/speed) > Math.round((tickCount-1)/speed))){
try {
int i = itemIndexSelected();
e.set(((CrateReward)items.get(i)[1]).getDisplayItem());
holder = (CrateReward)items.get(i)[1];
ourplr.playSound(SoundTypes.UI_BUTTON_CLICK,ourplr.getLocation().getPosition(),0.25);
} catch (RandomItemSelectionFailureException e1) {
plugin.logger.error("Random Item Selection failed in Roulette Crate View: " + vc.displayName);
}
//e.set(((CrateRewardHolder)items.get(Math.round(tickCount/2) % items.size())[1]).getDisplayItem());
}else{
if(stopped && !firedEnd){
if(secRemain < 0){
outOfTime = true;
ourplr.playSound(SoundTypes.BLOCK_GLASS_BREAK,ourplr.getLocation().getPosition(),1);
}
Sponge.getScheduler().createTaskBuilder().execute(task -> {
updater.cancel();
ourplr.closeInventory();
handleReward(holder);
ourplr.playSound(SoundTypes.ENTITY_EXPERIENCE_ORB_PICKUP,ourplr.getLocation().getPosition(),1);
}).delay(3, TimeUnit.SECONDS).submit(HuskyCrates.instance);
firedEnd = true;
}
e.set(e.peek().get());
}
slotNum++;
}
}