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