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


Java Item.offer方法代码示例

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


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

示例1: give

import org.spongepowered.api.entity.Item; //导入方法依赖的package包/类
public void give(Player player) {
	this.checkCache();
	for (ItemStackSnapshot iss : itemStacksCache) {
		InventoryTransactionResult result = player.getInventory().offer(iss.createStack());
		for (ItemStackSnapshot is : result.getRejectedItems()) {
			Item item = (Item) player.getLocation().getExtent().createEntity(EntityTypes.ITEM, player.getLocation().getPosition());
			item.offer(Keys.REPRESENTED_ITEM, is.copy());
			player.getWorld().spawnEntity(item, Cause.of(NamedCause.source(player), NamedCause.owner("BetterKits")));
		}
	}

	for (String command : this.getCommands()) {
		try {
			Sponge.getCommandManager().process(Sponge.getServer().getConsole(), command.replace("%name", player.getName()).replace("%uuid", player.getUniqueId().toString()));
		} catch (Throwable e) {
			e.printStackTrace();
		}
	}
}
 
开发者ID:KaiKikuchi,项目名称:BetterKits,代码行数:20,代码来源:Kit.java

示例2: spawnItem

import org.spongepowered.api.entity.Item; //导入方法依赖的package包/类
public void spawnItem(Location<World> location, ItemStackSnapshot snapshot, Object notifier) {
    World world = location.getExtent();
    Item rejectedItem = (Item) world.createEntity(EntityTypes.ITEM, location.getPosition());

    Cause cause = Cause.source(
            EntitySpawnCause.builder()
                    .entity(rejectedItem)
                    .type(SpawnTypes.PLUGIN)
                    .build()
            )
            .owner(CustomItemLibrary.getInstance().getPluginContainer())
            .notifier(notifier)
            .build();

    rejectedItem.offer(Keys.REPRESENTED_ITEM, snapshot);
    world.spawnEntity(rejectedItem, cause);
}
 
开发者ID:Limeth,项目名称:CustomItemLibrary,代码行数:18,代码来源:Util.java

示例3: onEntityDrop

import org.spongepowered.api.entity.Item; //导入方法依赖的package包/类
@Listener
public void onEntityDrop(DropItemEvent.Destruct event, @Named(NamedCause.SOURCE) EntitySpawnCause spawnCause) {
  Entity entity = spawnCause.getEntity();
  if (!(entity instanceof Animal)) {
    return;
  }

  Optional<TheButcherShopInstance> optInst = manager.getApplicableZone(entity);
  if (!optInst.isPresent()) {
    return;
  }

  event.getEntities().clear();

  Item item = (Item) entity.getLocation().createEntity(EntityTypes.ITEM);
  item.offer(Keys.REPRESENTED_ITEM, newItemStack("skree:unpackaged_meat").createSnapshot());

  event.getEntities().add(item);
}
 
开发者ID:Skelril,项目名称:Skree,代码行数:20,代码来源:TheButcherShopListener.java

示例4: sweepFloor

import org.spongepowered.api.entity.Item; //导入方法依赖的package包/类
public void sweepFloor() {

    for (Item item : getContained(Item.class)) {

      if (!contains(item)) {
        continue;
      }

      ItemType id = item.getItemType();
      for (ItemType aItem : ITEMS) {
        if (aItem == id) {
          ItemStackSnapshot snapshot = item.get(Keys.REPRESENTED_ITEM).get();
          int newAmt = (int) (snapshot.getCount() * .8);
          if (newAmt < 1) {
            item.remove();
          } else {
            ItemStack newStack = snapshot.createStack();
            newStack.setQuantity(newAmt);
            item.offer(Keys.REPRESENTED_ITEM, newStack.createSnapshot());
          }
          break;
        }
      }
    }
  }
 
开发者ID:Skelril,项目名称:Skree,代码行数:26,代码来源:CursedMineInstance.java

示例5: dropItem

import org.spongepowered.api.entity.Item; //导入方法依赖的package包/类
/**
 * Faire drop un item pied du joueur
 * @param itemstack L'itemstack
 */
public void dropItem(final ItemStack itemstack) {
	Entity entity = this.getWorld().createEntity(EntityTypes.ITEM, this.getLocation().getPosition());
	if (entity instanceof Item) {
		Item item = (Item) entity;
		item.offer(Keys.REPRESENTED_ITEM, itemstack.createSnapshot());
		this.getWorld().spawnEntity(item, Cause.source(this.getPlayer().get()).build());
	}
}
 
开发者ID:EverCraft,项目名称:EverAPI,代码行数:13,代码来源:EPlayer.java

示例6: createItem

import org.spongepowered.api.entity.Item; //导入方法依赖的package包/类
private static Item createItem(World world, Vector3d pos, ItemStack stack, boolean noPickup) {
    Item itemEntity = (Item) world.createEntity(EntityTypes.ITEM, pos);
    itemEntity.offer(Keys.REPRESENTED_ITEM, stack.createSnapshot());
    if (noPickup) {
        itemEntity.tryOffer(Keys.INFINITE_PICKUP_DELAY, true);
        itemEntity.tryOffer(Keys.INFINITE_DESPAWN_DELAY, true);
    }
    return itemEntity;
}
 
开发者ID:simon816,项目名称:Industrialization,代码行数:10,代码来源:ItemStackHolder.java

示例7: dropItem

import org.spongepowered.api.entity.Item; //导入方法依赖的package包/类
public static void dropItem(Player p, ItemStack itemStack) {
	Entity optional = p.getLocation().getExtent()
			.createEntity(EntityTypes.ITEM, p.getLocation()
					.getPosition()
					.add(TrigMath.cos((p.getRotation().getX() - 90) % 360) * 0.2, 1,
							TrigMath.sin((p.getRotation().getX() - 90) % 360) * 0.2));
	Vector3d rotation = p.getRotation();
	Vector3d direction = Quaterniond.fromAxesAnglesDeg(rotation.getX(), -rotation.getY(), rotation.getZ()).getDirection();
	Item item = (Item) optional;
	item.offer(Keys.VELOCITY, direction.mul(0.33));
	item.offer(Keys.REPRESENTED_ITEM, itemStack.createSnapshot());
	item.offer(Keys.PICKUP_DELAY, 50);
	p.getLocation().getExtent().spawnEntity(item);

}
 
开发者ID:NeumimTo,项目名称:NT-RPG,代码行数:16,代码来源:ItemStackUtils.java

示例8: dropItem

import org.spongepowered.api.entity.Item; //导入方法依赖的package包/类
@Override
public void dropItem(ItemStackSnapshot snapshot, Cause cause) {
  Item item = (Item) getExtent().createEntity(EntityTypes.ITEM, getPos());
  item.offer(Keys.REPRESENTED_ITEM, snapshot);
  item.setVelocity(new Vector3d(0, 0, 0));
  getExtent().spawnEntity(item, cause);
}
 
开发者ID:Skelril,项目名称:Skree,代码行数:8,代码来源:FixedPointItemDropper.java

示例9: dropItem

import org.spongepowered.api.entity.Item; //导入方法依赖的package包/类
public void dropItem(ItemStackSnapshot snapshot, Cause cause) {
  Item item = (Item) getExtent().createEntity(EntityTypes.ITEM, getPos());
  item.offer(Keys.REPRESENTED_ITEM, snapshot);
  getExtent().spawnEntity(item, cause);
}
 
开发者ID:Skelril,项目名称:Skree,代码行数:6,代码来源:ItemDropper.java


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