本文整理汇总了Java中org.bukkit.World.dropItem方法的典型用法代码示例。如果您正苦于以下问题:Java World.dropItem方法的具体用法?Java World.dropItem怎么用?Java World.dropItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.World
的用法示例。
在下文中一共展示了World.dropItem方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onFurnaceSmelt
import org.bukkit.World; //导入方法依赖的package包/类
/**
* Handles the action of smelting all items at once, exploding the furnace, and dropping the smelted items on the
* ground.
*
* @param event The event
*/
@EventHandler(ignoreCancelled = true)
public void onFurnaceSmelt(FurnaceSmeltEvent event) {
ItemStack resultItem = event.getResult();
final Material result = resultItem.getType();
//TODO: Verify that the "smelting amount" contains any extra ingredients
final int amount = ((Furnace) event.getBlock().getState()).getInventory().getSmelting().getAmount();
event.getSource().setType(Material.AIR);
resultItem.setType(Material.AIR);
Block block = event.getBlock();
block.setType(Material.AIR);
Location location = block.getLocation().add(0.5, 0.5, 0.5);
World world = location.getWorld();
world.createExplosion(location, 7);
world.dropItem(location, new ItemStack(result, amount));
}
示例2: onAttemptRespawn
import org.bukkit.World; //导入方法依赖的package包/类
@EventHandler
public void onAttemptRespawn(PlayerInteractEvent event) {
Player player = event.getPlayer();
ItemStack item = event.getItem();
if (item == null || item.getType() != Material.END_CRYSTAL) return;
if (plugin.getConfig().getBoolean("allow-crystal-respawns")) return;
World world = player.getWorld();
EndWorldWrapper worldWrapper = plugin.getDEDManager().getWorldWrapper(world);
if (worldWrapper.isRespawnInProgress() || !world.getEntitiesByClass(EnderDragon.class).isEmpty()) {
Set<EnderCrystal> crystals = PortalCrystal.getAllSpawnedCrystals(world);
// Check for 3 crystals because PlayerInteractEvent is fired first
if (crystals.size() < 3) return;
for (EnderCrystal crystal : crystals) {
crystal.getLocation().getBlock().setType(Material.AIR); // Remove fire
world.dropItem(crystal.getLocation(), END_CRYSTAL_ITEM);
crystal.remove();
}
plugin.getNMSAbstract().sendActionBar(ChatColor.RED + "You cannot manually respawn a dragon!", player);
player.sendMessage(ChatColor.RED + "You cannot manually respawn a dragon!");
event.setCancelled(true);
}
}
示例3: add
import org.bukkit.World; //导入方法依赖的package包/类
public void add(ItemStack stack) {
World world = block.getWorld();
Location location = block.getLocation().add(0, 1, 0.5);
ItemStack cloned = stack.clone();
cloned.setAmount(1);
Item entity = world.dropItem(location, cloned);
entity.setVelocity(new Vector(0, 0, 0));
entity.teleport(location);
entity.setGravity(false);
entity.setGlowing(true);
entity.setPickupDelay(Integer.MAX_VALUE);
stack.setAmount(stack.getAmount() - 1);
BukkitRunnable runnable = new BukkitRunnable() {
int tickCount = 0;
int speed = 8;
// Circle maths!
double unit = 2 * Math.PI / (speed * 10);
double divisor = speed * Math.PI;
@Override
public void run() {
entity.setVelocity(
new Vector(Math.sin(unit * tickCount) / divisor, 0, Math.cos(unit * tickCount) / divisor));
tickCount++;
if (tickCount == speed * 10) {
tickCount = 0;
}
}
};
runnable.runTaskTimer(MystiCraft.getInstance(), 1, 1);
items.put(entity, runnable);
String spell = getSpell();
if (spell != null) {
book.setCustomName("Ready to craft: " + spell);
book.setCustomNameVisible(true);
} else {
book.setCustomNameVisible(false);
}
}