use of net.glowstone.entity.objects.GlowItem in project Glowstone by GlowstoneMC.
the class GlowWorld method dropItemNaturally.
@Override
public GlowItem dropItemNaturally(Location location, ItemStack item) {
double xs = random.nextFloat() * 0.7F + (1.0F - 0.7F) * 0.5D;
double ys = random.nextFloat() * 0.7F + (1.0F - 0.7F) * 0.5D;
double zs = random.nextFloat() * 0.7F + (1.0F - 0.7F) * 0.5D;
location = location.clone().add(xs, ys, zs);
GlowItem dropItem = new GlowItem(location, item);
dropItem.setVelocity(new Vector(0, 0.01F, 0));
return dropItem;
}
use of net.glowstone.entity.objects.GlowItem in project Glowstone by GlowstoneMC.
the class GlowPlayer method drop.
@Override
public GlowItem drop(ItemStack stack) {
GlowItem dropping = super.drop(stack);
if (dropping != null) {
PlayerDropItemEvent event = new PlayerDropItemEvent(this, dropping);
EventFactory.callEvent(event);
if (event.isCancelled()) {
dropping.remove();
dropping = null;
} else {
incrementStatistic(Statistic.DROP, stack.getAmount());
}
}
return dropping;
}
use of net.glowstone.entity.objects.GlowItem in project Glowstone by GlowstoneMC.
the class GlowHumanEntity method drop.
/**
* Spawns a new {@link GlowItem} in the world, as if this HumanEntity had
* dropped it. Note that this does NOT remove the item from the inventory.
*
* @param stack The item to drop
* @return the GlowItem that was generated, or null if the spawning was cancelled
* @throws IllegalArgumentException if the stack is empty
*/
public GlowItem drop(ItemStack stack) {
checkArgument(!InventoryUtil.isEmpty(stack), "stack must not be empty");
Location dropLocation = location.clone().add(0, getEyeHeight(true) - 0.3, 0);
GlowItem dropItem = world.dropItem(dropLocation, stack);
Vector vel = location.getDirection().multiply(new Vector(0.11F, 0.0F, 0.11F));
vel.setY(0.006F);
dropItem.setVelocity(vel);
return dropItem;
}
Aggregations