• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java CraftItem类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



CraftItem类属于org.bukkit.craftbukkit.entity包,在下文中一共展示了CraftItem类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: a

import org.bukkit.craftbukkit.entity.CraftItem; //导入依赖的package包/类
public EntityItem a(ItemStack itemstack, boolean flag, boolean flag1) {
    if (itemstack == null) {
        return null;
    } else if (itemstack.count == 0) {
        return null;
    } else {
        EntityItem entityitem = new EntityItem(this.world, this.locX, this.locY - 0.30000001192092896D + (double) this.getHeadHeight(), this.locZ, itemstack);

        entityitem.pickupDelay = 40;
        if (flag1) {
            entityitem.b(this.getName());
        }

        float f = 0.1F;
        float f1;

        if (flag) {
            f1 = this.random.nextFloat() * 0.5F;
            float f2 = this.random.nextFloat() * 3.1415927F * 2.0F;

            entityitem.motX = (double) (-MathHelper.sin(f2) * f1);
            entityitem.motZ = (double) (MathHelper.cos(f2) * f1);
            entityitem.motY = 0.20000000298023224D;
        } else {
            f = 0.3F;
            entityitem.motX = (double) (-MathHelper.sin(this.yaw / 180.0F * 3.1415927F) * MathHelper.cos(this.pitch / 180.0F * 3.1415927F) * f);
            entityitem.motZ = (double) (MathHelper.cos(this.yaw / 180.0F * 3.1415927F) * MathHelper.cos(this.pitch / 180.0F * 3.1415927F) * f);
            entityitem.motY = (double) (-MathHelper.sin(this.pitch / 180.0F * 3.1415927F) * f + 0.1F);
            f = 0.02F;
            f1 = this.random.nextFloat() * 3.1415927F * 2.0F;
            f *= this.random.nextFloat();
            entityitem.motX += Math.cos((double) f1) * (double) f;
            entityitem.motY += (double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.1F);
            entityitem.motZ += Math.sin((double) f1) * (double) f;
        }

        // CraftBukkit start - fire PlayerDropItemEvent
        Player player = (Player) this.getBukkitEntity();
        CraftItem drop = new CraftItem(this.world.getServer(), entityitem);

        PlayerDropItemEvent event = new PlayerDropItemEvent(player, drop);
        this.world.getServer().getPluginManager().callEvent(event);

        if (event.isCancelled()) {
            org.bukkit.inventory.ItemStack cur = player.getInventory().getItemInHand();
            if (flag1 && (cur == null || cur.getAmount() == 0)) {
                // The complete stack was dropped
                player.getInventory().setItemInHand(drop.getItemStack());
            } else if (flag1 && cur.isSimilar(drop.getItemStack()) && drop.getItemStack().getAmount() == 1) {
                // Only one item is dropped
                cur.setAmount(cur.getAmount() + 1);
                player.getInventory().setItemInHand(cur);
            } else {
                // Fallback
                player.getInventory().addItem(drop.getItemStack());
            }
            return null;
        }
        // CraftBukkit end

        this.a(entityitem);
        this.a(StatisticList.s, 1);
        return entityitem;
    }
}
 
开发者ID:OvercastNetwork,项目名称:CraftBukkit,代码行数:66,代码来源:EntityHuman.java


示例2: a

import org.bukkit.craftbukkit.entity.CraftItem; //导入依赖的package包/类
public EntityItem a(ItemStack itemstack, boolean flag) {
    if (itemstack == null) {
        return null;
    } else if (itemstack.count == 0) {
        return null;
    } else {
        EntityItem entityitem = new EntityItem(this.world, this.locX, this.locY - 0.30000001192092896D + (double) this.getHeadHeight(), this.locZ, itemstack);

        entityitem.pickupDelay = 40;
        float f = 0.1F;
        float f1;

        if (flag) {
            f1 = this.random.nextFloat() * 0.5F;
            float f2 = this.random.nextFloat() * 3.1415927F * 2.0F;

            entityitem.motX = (double) (-MathHelper.sin(f2) * f1);
            entityitem.motZ = (double) (MathHelper.cos(f2) * f1);
            entityitem.motY = 0.20000000298023224D;
        } else {
            f = 0.3F;
            entityitem.motX = (double) (-MathHelper.sin(this.yaw / 180.0F * 3.1415927F) * MathHelper.cos(this.pitch / 180.0F * 3.1415927F) * f);
            entityitem.motZ = (double) (MathHelper.cos(this.yaw / 180.0F * 3.1415927F) * MathHelper.cos(this.pitch / 180.0F * 3.1415927F) * f);
            entityitem.motY = (double) (-MathHelper.sin(this.pitch / 180.0F * 3.1415927F) * f + 0.1F);
            f = 0.02F;
            f1 = this.random.nextFloat() * 3.1415927F * 2.0F;
            f *= this.random.nextFloat();
            entityitem.motX += Math.cos((double) f1) * (double) f;
            entityitem.motY += (double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.1F);
            entityitem.motZ += Math.sin((double) f1) * (double) f;
        }

        // CraftBukkit start
        Player player = (Player) this.getBukkitEntity();
        CraftItem drop = new CraftItem(this.world.getServer(), entityitem);

        PlayerDropItemEvent event = new PlayerDropItemEvent(player, drop);
        this.world.getServer().getPluginManager().callEvent(event);

        if (event.isCancelled()) {
            player.getInventory().addItem(drop.getItemStack());
            return null;
        }
        // CraftBukkit end

        this.a(entityitem);
        this.a(StatisticList.v, 1);
        return entityitem;
    }
}
 
开发者ID:AlmuraDev,项目名称:Almura-Server,代码行数:51,代码来源:EntityHuman.java


示例3: func_146097_a

import org.bukkit.craftbukkit.entity.CraftItem; //导入依赖的package包/类
public EntityItem func_146097_a(ItemStack p_146097_1_, boolean p_146097_2_, boolean p_146097_3_)
{
    if (p_146097_1_ == null)
    {
        return null;
    }
    else if (p_146097_1_.stackSize == 0)
    {
        return null;
    }
    else
    {
        EntityItem entityitem = new EntityItem(this.worldObj, this.posX, this.posY - 0.30000001192092896D + (double)this.getEyeHeight(), this.posZ, p_146097_1_);
        entityitem.delayBeforeCanPickup = 40;

        if (p_146097_3_)
        {
            entityitem.func_145799_b(this.getCommandSenderName());
        }

        float f = 0.1F;
        float f1;

        if (p_146097_2_)
        {
            f1 = this.rand.nextFloat() * 0.5F;
            float f2 = this.rand.nextFloat() * (float)Math.PI * 2.0F;
            entityitem.motionX = (double)(-MathHelper.sin(f2) * f1);
            entityitem.motionZ = (double)(MathHelper.cos(f2) * f1);
            entityitem.motionY = 0.20000000298023224D;
        }
        else
        {
            f = 0.3F;
            entityitem.motionX = (double)(-MathHelper.sin(this.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI) * f);
            entityitem.motionZ = (double)(MathHelper.cos(this.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI) * f);
            entityitem.motionY = (double)(-MathHelper.sin(this.rotationPitch / 180.0F * (float)Math.PI) * f + 0.1F);
            f = 0.02F;
            f1 = this.rand.nextFloat() * (float)Math.PI * 2.0F;
            f *= this.rand.nextFloat();
            entityitem.motionX += Math.cos((double)f1) * (double)f;
            entityitem.motionY += (double)((this.rand.nextFloat() - this.rand.nextFloat()) * 0.1F);
            entityitem.motionZ += Math.sin((double)f1) * (double)f;
        }

        // CraftBukkit start
        Player player = (Player) this.getBukkitEntity();
        CraftItem drop = new CraftItem(this.worldObj.getServer(), entityitem);
        PlayerDropItemEvent event = new PlayerDropItemEvent(player, drop);
        this.worldObj.getServer().getPluginManager().callEvent(event);

        if (event.isCancelled())
        {
            player.getInventory().addItem(drop.getItemStack());
            return null;
        }

        // CraftBukkit end
        this.joinEntityItemWithWorld(entityitem);
        this.addStat(StatList.dropStat, 1);
        return entityitem;
    }
}
 
开发者ID:xtrafrancyz,项目名称:Cauldron,代码行数:64,代码来源:EntityPlayer.java


示例4: a

import org.bukkit.craftbukkit.entity.CraftItem; //导入依赖的package包/类
@Nullable
public EntityItem a(@Nullable ItemStack itemstack, boolean flag, boolean flag1) {
    if (itemstack == null) {
        return null;
    } else if (itemstack.count == 0) {
        return null;
    } else {
        double d0 = this.locY - 0.30000001192092896D + (double) this.getHeadHeight();
        EntityItem entityitem = new EntityItem(this.world, this.locX, d0, this.locZ, itemstack);

        entityitem.a(40);
        if (flag1) {
            entityitem.e(this.getName());
        }

        float f;
        float f1;

        if (flag) {
            f = this.random.nextFloat() * 0.5F;
            f1 = this.random.nextFloat() * 6.2831855F;
            entityitem.motX = (double) (-MathHelper.sin(f1) * f);
            entityitem.motZ = (double) (MathHelper.cos(f1) * f);
            entityitem.motY = 0.20000000298023224D;
        } else {
            f = 0.3F;
            entityitem.motX = (double) (-MathHelper.sin(this.yaw * 0.017453292F) * MathHelper.cos(this.pitch * 0.017453292F) * f);
            entityitem.motZ = (double) (MathHelper.cos(this.yaw * 0.017453292F) * MathHelper.cos(this.pitch * 0.017453292F) * f);
            entityitem.motY = (double) (-MathHelper.sin(this.pitch * 0.017453292F) * f + 0.1F);
            f1 = this.random.nextFloat() * 6.2831855F;
            f = 0.02F * this.random.nextFloat();
            entityitem.motX += Math.cos((double) f1) * (double) f;
            entityitem.motY += (double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.1F);
            entityitem.motZ += Math.sin((double) f1) * (double) f;
        }

        // CraftBukkit start - fire PlayerDropItemEvent
        Player player = (Player) this.getBukkitEntity();
        CraftItem drop = new CraftItem(this.world.getServer(), entityitem);

        PlayerDropItemEvent event = new PlayerDropItemEvent(player, drop);
        this.world.getServer().getPluginManager().callEvent(event);

        if (event.isCancelled()) {
            org.bukkit.inventory.ItemStack cur = player.getInventory().getItemInHand();
            if (flag1 && (cur == null || cur.getAmount() == 0)) {
                // The complete stack was dropped
                player.getInventory().setItemInHand(drop.getItemStack());
            } else if (flag1 && cur.isSimilar(drop.getItemStack()) && drop.getItemStack().getAmount() == 1) {
                // Only one item is dropped
                cur.setAmount(cur.getAmount() + 1);
                player.getInventory().setItemInHand(cur);
            } else {
                // Fallback
                player.getInventory().addItem(drop.getItemStack());
            }
            return null;
        }
        // CraftBukkit end

        ItemStack itemstack1 = this.a(entityitem);

        if (flag1) {
            if (itemstack1 != null) {
                this.a(StatisticList.e(itemstack1.getItem()), itemstack.count);
            }

            this.b(StatisticList.x);
        }

        return entityitem;
    }
}
 
开发者ID:bergerkiller,项目名称:SpigotSource,代码行数:74,代码来源:EntityHuman.java


示例5: a

import org.bukkit.craftbukkit.entity.CraftItem; //导入依赖的package包/类
public EntityItem a(ItemStack itemstack, boolean flag) {
    if (itemstack == null) {
        return null;
    } else {
        EntityItem entityitem = new EntityItem(this.world, this.locX, this.locY - 0.30000001192092896D + (double) this.getHeadHeight(), this.locZ, itemstack);

        entityitem.pickupDelay = 40;
        float f = 0.1F;
        float f1;

        if (flag) {
            f1 = this.random.nextFloat() * 0.5F;
            float f2 = this.random.nextFloat() * 3.1415927F * 2.0F;

            entityitem.motX = (double) (-MathHelper.sin(f2) * f1);
            entityitem.motZ = (double) (MathHelper.cos(f2) * f1);
            entityitem.motY = 0.20000000298023224D;
        } else {
            f = 0.3F;
            entityitem.motX = (double) (-MathHelper.sin(this.yaw / 180.0F * 3.1415927F) * MathHelper.cos(this.pitch / 180.0F * 3.1415927F) * f);
            entityitem.motZ = (double) (MathHelper.cos(this.yaw / 180.0F * 3.1415927F) * MathHelper.cos(this.pitch / 180.0F * 3.1415927F) * f);
            entityitem.motY = (double) (-MathHelper.sin(this.pitch / 180.0F * 3.1415927F) * f + 0.1F);
            f = 0.02F;
            f1 = this.random.nextFloat() * 3.1415927F * 2.0F;
            f *= this.random.nextFloat();
            entityitem.motX += Math.cos((double) f1) * (double) f;
            entityitem.motY += (double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.1F);
            entityitem.motZ += Math.sin((double) f1) * (double) f;
        }

        // CraftBukkit start
        Player player = (Player) this.getBukkitEntity();
        CraftItem drop = new CraftItem(this.world.getServer(), entityitem);

        PlayerDropItemEvent event = new PlayerDropItemEvent(player, drop);
        this.world.getServer().getPluginManager().callEvent(event);

        if (event.isCancelled()) {
            player.getInventory().addItem(drop.getItemStack());
            return null;
        }
        // CraftBukkit end

        this.a(entityitem);
        this.a(StatisticList.v, 1);
        return entityitem;
    }
}
 
开发者ID:didoupimpon,项目名称:Craft-city,代码行数:49,代码来源:EntityHuman.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Font类代码示例发布时间:2022-05-23
下一篇:
Java MaterialAboutItemOnClickAction类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap