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


Java Item.getLocation方法代码示例

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


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

示例1: onItemDrop

import org.bukkit.entity.Item; //导入方法依赖的package包/类
@EventHandler
public void onItemDrop(PlayerDropItemEvent event)
{
	System.out.println("Item drop");
	Item item = event.getItemDrop();
	ItemStack stack = item.getItemStack();
	Location location = item.getLocation();
	Player player = event.getPlayer();
	String playerName = player == null ? "null" : player.getName();
	
	DropItemObsel obsel = new DropItemObsel(
			new Date().getTime(),
			stack.getType().toString(),
			stack.getAmount(),
			stack.getData().getData(),
			location.getBlockX(),
			location.getBlockY(),
			location.getBlockZ(),
			location.getWorld().getName(),
			playerName);
	JSONObselManager.getInstance().addObsel(obsel);
}
 
开发者ID:Lyon1-Asterix,项目名称:Minetrace,代码行数:23,代码来源:MinetraceListener.java

示例2: onItemPickup

import org.bukkit.entity.Item; //导入方法依赖的package包/类
@EventHandler
public void onItemPickup(PlayerPickupItemEvent event)
{
	System.out.println("Item pickup");
	Item item = event.getItem();
	ItemStack stack = item.getItemStack();
	Location location = item.getLocation();
	Player player = event.getPlayer();
	String playerName = player == null ? "null" : player.getName();
	
	PickupItemObsel obsel = new PickupItemObsel(
			new Date().getTime(),
			stack.getType().toString(),
			stack.getAmount(),
			stack.getData().getData(),
			location.getBlockX(),
			location.getBlockY(),
			location.getBlockZ(),
			location.getWorld().getName(),
			playerName);
	JSONObselManager.getInstance().addObsel(obsel);
}
 
开发者ID:Lyon1-Asterix,项目名称:Minetrace,代码行数:23,代码来源:MinetraceListener.java

示例3: onDrop

import org.bukkit.entity.Item; //导入方法依赖的package包/类
@EventHandler
public void onDrop(ItemSpawnEvent event)
{
	if(event.isCancelled()) return;
	final Item itemDrop = event.getEntity();
	if(itemDrop.getItemStack().getType() == Material.BOWL)
	{
	    final Runnable task = new Runnable()
	    {
	    	public void run()
	    	{
	    		if(itemDrop.getItemStack().getAmount() != 1) return;
	    		Location itemLocation = itemDrop.getLocation();
	    		if(itemLocation.getBlock().getType() == Material.WATER || itemLocation.getBlock().getType() == Material.STATIONARY_WATER)
	    		{
	    			itemDrop.remove();
	    			
	    	      	ItemStack i_beetroot = new ItemStack(Material.BEETROOT_SOUP, 1);
	    	      	ItemMeta beetrootMeta= i_beetroot.getItemMeta();
	    	      	beetrootMeta.setDisplayName(ChatColor.RESET + Survival.instance.Words.get("Water Bowl"));
	    	      	i_beetroot.setItemMeta(beetrootMeta);
	    	      	
	    			itemDrop.getWorld().dropItem(itemLocation, i_beetroot);
	    		}
            }
	    };
	    
	    Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(Survival.instance, task, 20L);
	}
}
 
开发者ID:FattyMieo,项目名称:SurvivalPlus,代码行数:31,代码来源:WaterBowl.java

示例4: setHolder

import org.bukkit.entity.Item; //导入方法依赖的package包/类
@Override
public void setHolder(Item item) {
	loc = item.getLocation();
}
 
开发者ID:DevotedMC,项目名称:ExilePearl,代码行数:5,代码来源:MockPearl.java

示例5: WorldCoord

import org.bukkit.entity.Item; //导入方法依赖的package包/类
public WorldCoord(final Item item) {
	this(item.getLocation());
}
 
开发者ID:NoChanceSD,项目名称:AncientGates,代码行数:4,代码来源:WorldCoord.java

示例6: execute

import org.bukkit.entity.Item; //导入方法依赖的package包/类
@Override
public boolean execute(Location loc) {
    int thresholdDist = RADIUS * RADIUS;
    loc.add(0.5, 0.5, 0.5);
    for (final Item item : getItemEntities(loc.getWorld())) {
        if (!item.isValid()) {
            // important, since we're looking at entities cached in the last second
            continue;
        }
        double dist = loc.distanceSquared(item.getLocation());
        if (dist >= thresholdDist) {
            continue;
        }
        final ItemStack onGround = item.getItemStack();
        ItemStack buffer = getItemRouter().getBufferItem();
        Location itemLoc = item.getLocation();
        if (item.getPickupDelay() <= 0
                && getFilter().shouldPass(onGround)
                && rightDirection(itemLoc, loc)
                && (buffer == null || buffer.isSimilar(onGround))
                && STBUtil.getMetadataValue(item, STB_VACUUMED) == null) {
            double rtrY = loc.getY();
            Vector vel = loc.subtract(itemLoc).toVector().normalize().multiply(Math.min(dist * 0.06, 0.7));
            if (itemLoc.getY() < rtrY) {
                vel.setY(vel.getY() + (rtrY - itemLoc.getY()) / 10);
            }
            item.setMetadata(STB_VACUUMED, new FixedMetadataValue(getProviderPlugin(), getItemRouter()));
            item.setVelocity(vel);
            Bukkit.getScheduler().runTaskLater(getProviderPlugin(), new Runnable() {
                @Override
                public void run() {
                    if (item.isValid()) {
                        ItemStack newBuffer = getItemRouter().getBufferItem();
                        int toSlurp = 0;
                        if (newBuffer == null) {
                            toSlurp = onGround.getAmount();
                            getItemRouter().setBufferItem(onGround);
                            item.remove();
                        } else if (newBuffer.isSimilar(onGround)) {
                            toSlurp = Math.min(onGround.getAmount(), newBuffer.getType().getMaxStackSize() - newBuffer.getAmount());
                            getItemRouter().setBufferAmount(newBuffer.getAmount() + toSlurp);
                            onGround.setAmount(onGround.getAmount() - toSlurp);
                            if (onGround.getAmount() == 0) {
                                item.remove();
                            } else {
                                item.setItemStack(onGround);
                            }
                        }
                        if (toSlurp > 0) {
                            getItemRouter().playParticles();
                            getItemRouter().update(false);
                        }
                    }
                }
            }, (long) (dist / 3));
        }
    }
    return false; // any work done is deferred
}
 
开发者ID:desht,项目名称:sensibletoolbox,代码行数:60,代码来源:VacuumModule.java


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