本文整理匯總了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);
}
}