本文整理汇总了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);
}
示例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);
}
示例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);
}
}
示例4: setHolder
import org.bukkit.entity.Item; //导入方法依赖的package包/类
@Override
public void setHolder(Item item) {
loc = item.getLocation();
}
示例5: WorldCoord
import org.bukkit.entity.Item; //导入方法依赖的package包/类
public WorldCoord(final Item item) {
this(item.getLocation());
}
示例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
}