Search in sources :

Example 6 with GlowItem

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;
}
Also used : Vector(org.bukkit.util.Vector) GlowItem(net.glowstone.entity.objects.GlowItem)

Example 7 with GlowItem

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;
}
Also used : GlowItem(net.glowstone.entity.objects.GlowItem)

Example 8 with GlowItem

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;
}
Also used : Vector(org.bukkit.util.Vector) GlowItem(net.glowstone.entity.objects.GlowItem) Location(org.bukkit.Location)

Aggregations

GlowItem (net.glowstone.entity.objects.GlowItem)8 ItemStack (org.bukkit.inventory.ItemStack)4 Vector (org.bukkit.util.Vector)3 GlowBlock (net.glowstone.block.GlowBlock)2 Location (org.bukkit.Location)2 GlowWorld (net.glowstone.GlowWorld)1 GlowBlockState (net.glowstone.block.GlowBlockState)1 BlockContainer (net.glowstone.block.blocktype.BlockContainer)1 BlockType (net.glowstone.block.blocktype.BlockType)1 ContainerEntity (net.glowstone.block.entity.ContainerEntity)1 ItemTimedUsage (net.glowstone.block.itemtype.ItemTimedUsage)1 ItemType (net.glowstone.block.itemtype.ItemType)1 GlowPlayer (net.glowstone.entity.GlowPlayer)1 Block (org.bukkit.block.Block)1 BlockFace (org.bukkit.block.BlockFace)1 Action (org.bukkit.event.block.Action)1 BlockBreakEvent (org.bukkit.event.block.BlockBreakEvent)1 BlockDamageEvent (org.bukkit.event.block.BlockDamageEvent)1 BlockDispenseEvent (org.bukkit.event.block.BlockDispenseEvent)1 PlayerInteractEvent (org.bukkit.event.player.PlayerInteractEvent)1