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


Java World.dropItem方法代码示例

本文整理汇总了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));
}
 
开发者ID:twizmwazin,项目名称:OpenUHC,代码行数:24,代码来源:Overcook.java

示例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);
	}
}
 
开发者ID:2008Choco,项目名称:DragonEggDrop,代码行数:28,代码来源:DragonLifeListeners.java

示例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);
	}
}
 
开发者ID:mcardy,项目名称:MystiCraft,代码行数:43,代码来源:CraftingOperation.java


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