Ejemplo n.º 1
0
        public virtual void dropBlockAsItemWithChance(World world, int i, int j, int k, int l, float f)
        {
            if (world.singleplayerWorld)
            {
                return;
            }
            int i1 = quantityDropped(world.rand);

            for (int j1 = 0; j1 < i1; j1++)
            {
                if (world.rand.nextFloat() > f)
                {
                    continue;
                }
                int k1 = idDropped(l, world.rand);
                if (k1 > 0)
                {
                    float  f1         = 0.7F;
                    double d          = (world.rand.nextFloat() * f1) + (1.0F - f1) * 0.5D;
                    double d1         = (world.rand.nextFloat() * f1) + (1.0F - f1) * 0.5D;
                    double d2         = (world.rand.nextFloat() * f1) + (1.0F - f1) * 0.5D;
                    var    entityitem = new EntityItem(world, i + d, j + d1, k + d2,
                                                       new ItemStack(k1, 1, damageDropped(l)));
                    entityitem.delayBeforeCanPickup = 10;
                    world.entityJoinedWorld(entityitem);
                }
            }
        }
Ejemplo n.º 2
0
        public virtual EntityItem entityDropItem(ItemStack itemstack, float f)
        {
            var entityitem = new EntityItem(worldObj, posX, posY + f, posZ, itemstack);

            entityitem.delayBeforeCanPickup = 10;
            worldObj.entityJoinedWorld(entityitem);
            return(entityitem);
        }
Ejemplo n.º 3
0
 public Packet21PickupSpawn(EntityItem entityitem)
 {
     entityId   = entityitem.entityId;
     itemID     = entityitem.item.itemID;
     count      = entityitem.item.stackSize;
     itemDamage = entityitem.item.getItemDamage();
     xPosition  = MathHelper.floor_double(entityitem.posX * 32D);
     yPosition  = MathHelper.floor_double(entityitem.posY * 32D);
     zPosition  = MathHelper.floor_double(entityitem.posZ * 32D);
     rotation   = (byte)(int)(entityitem.motionX * 128D);
     pitch      = (byte)(int)(entityitem.motionY * 128D);
     roll       = (byte)(int)(entityitem.motionZ * 128D);
 }
Ejemplo n.º 4
0
 public Packet21PickupSpawn(EntityItem entityitem)
 {
     entityId = entityitem.entityId;
     itemID = entityitem.item.itemID;
     count = entityitem.item.stackSize;
     itemDamage = entityitem.item.getItemDamage();
     xPosition = MathHelper.floor_double(entityitem.posX*32D);
     yPosition = MathHelper.floor_double(entityitem.posY*32D);
     zPosition = MathHelper.floor_double(entityitem.posZ*32D);
     rotation = (byte) (int) (entityitem.motionX*128D);
     pitch = (byte) (int) (entityitem.motionY*128D);
     roll = (byte) (int) (entityitem.motionZ*128D);
 }
Ejemplo n.º 5
0
        public override void harvestBlock(World world, int i, int j, int k, int l)
        {
            int    i1         = Item.snowball.shiftedIndex;
            float  f          = 0.7F;
            double d          = (world.rand.nextFloat() * f) + (1.0F - f) * 0.5D;
            double d1         = (world.rand.nextFloat() * f) + (1.0F - f) * 0.5D;
            double d2         = (world.rand.nextFloat() * f) + (1.0F - f) * 0.5D;
            var    entityitem = new EntityItem(world, i + d, j + d1, k + d2,
                                               new ItemStack(i1, 1, 0));

            entityitem.delayBeforeCanPickup = 10;
            world.entityJoinedWorld(entityitem);
            world.setBlockWithNotify(i, j, k, 0);
        }
Ejemplo n.º 6
0
 public override bool attackEntityFrom(Entity entity, int i)
 {
     if (!worldObj.singleplayerWorld && !func_21069_f_() && (entity is EntityLiving))
     {
         setSheared(true);
         int j = 1 + rand.nextInt(3);
         for (int k = 0; k < j; k++)
         {
             EntityItem entityitem = entityDropItem(new ItemStack(Block.cloth.blockID, 1, getFleeceColor()), 1.0F);
             entityitem.motionY += rand.nextFloat() * 0.05F;
             entityitem.motionX += (rand.nextFloat() - rand.nextFloat()) * 0.1F;
             entityitem.motionZ += (rand.nextFloat() - rand.nextFloat()) * 0.1F;
         }
     }
     return(base.attackEntityFrom(entity, i));
 }
Ejemplo n.º 7
0
 public override void onBlockDestroyedByPlayer(World world, int i, int j, int k, int l)
 {
     base.onBlockDestroyedByPlayer(world, i, j, k, l);
     if (!world.singleplayerWorld)
     {
         for (int i1 = 0; i1 < 3; i1++)
         {
             if (world.rand.nextInt(15) <= l)
             {
                 float f          = 0.7F;
                 float f1         = world.rand.nextFloat() * f + (1.0F - f) * 0.5F;
                 float f2         = world.rand.nextFloat() * f + (1.0F - f) * 0.5F;
                 float f3         = world.rand.nextFloat() * f + (1.0F - f) * 0.5F;
                 var   entityitem = new EntityItem(world, i + f1, j + f2, k + f3,
                                                   new ItemStack(Item.seeds));
                 entityitem.delayBeforeCanPickup = 10;
                 world.entityJoinedWorld(entityitem);
             }
         }
     }
 }
Ejemplo n.º 8
0
        public override void onBlockRemoval(World world, int i, int j, int k)
        {
            var tileentitychest = (TileEntityChest)world.getBlockTileEntity(i, j, k);

            for (int l = 0; l < tileentitychest.getSizeInventory(); l++)
            {
                ItemStack itemstack = tileentitychest.getStackInSlot(l);
                if (itemstack == null)
                {
                    continue;
                }
                float f  = random.nextFloat() * 0.8F + 0.1F;
                float f1 = random.nextFloat() * 0.8F + 0.1F;
                float f2 = random.nextFloat() * 0.8F + 0.1F;
                do
                {
                    if (itemstack.stackSize <= 0)
                    {
                        goto label0;
                    }
                    int i1 = random.nextInt(21) + 10;
                    if (i1 > itemstack.stackSize)
                    {
                        i1 = itemstack.stackSize;
                    }
                    itemstack.stackSize -= i1;
                    var entityitem = new EntityItem(world, i + f, j + f1, k + f2,
                                                    new ItemStack(itemstack.itemID, i1, itemstack.getItemDamage()));
                    float f3 = 0.05F;
                    entityitem.motionX = (float)random.nextGaussian() * f3;
                    entityitem.motionY = (float)random.nextGaussian() * f3 + 0.2F;
                    entityitem.motionZ = (float)random.nextGaussian() * f3;
                    world.entityJoinedWorld(entityitem);
                } while (true);
            }
label0:
            base.onBlockRemoval(world, i, j, k);
        }
Ejemplo n.º 9
0
        public int func_6143_c()
        {
            byte byte0 = 0;

            if (bobber != null)
            {
                double d  = angler.posX - posX;
                double d2 = angler.posY - posY;
                double d4 = angler.posZ - posZ;
                double d6 = MathHelper.sqrt_double(d * d + d2 * d2 + d4 * d4);
                double d8 = 0.10000000000000001D;
                bobber.motionX += d * d8;
                bobber.motionY += d2 * d8 + MathHelper.sqrt_double(d6) * 0.080000000000000002D;
                bobber.motionZ += d4 * d8;
                byte0           = 3;
            }
            else if (ticksCatchable > 0)
            {
                var    entityitem = new EntityItem(worldObj, posX, posY, posZ, new ItemStack(Item.fishRaw));
                double d1         = angler.posX - posX;
                double d3         = angler.posY - posY;
                double d5         = angler.posZ - posZ;
                double d7         = MathHelper.sqrt_double(d1 * d1 + d3 * d3 + d5 * d5);
                double d9         = 0.10000000000000001D;
                entityitem.motionX = d1 * d9;
                entityitem.motionY = d3 * d9 + MathHelper.sqrt_double(d7) * 0.080000000000000002D;
                entityitem.motionZ = d5 * d9;
                worldObj.entityJoinedWorld(entityitem);
                byte0 = 1;
            }
            if (inGround)
            {
                byte0 = 2;
            }
            setEntityDead();
            angler.fishEntity = null;
            return(byte0);
        }
Ejemplo n.º 10
0
        public void dropPlayerItemWithRandomChoice(ItemStack itemstack, bool flag)
        {
            if (itemstack == null)
            {
                return;
            }
            var entityitem = new EntityItem(worldObj, posX,
                                            (posY - 0.30000001192092896D) + getEyeHeight(), posZ,
                                            itemstack);

            entityitem.delayBeforeCanPickup = 40;
            float f = 0.1F;

            if (flag)
            {
                float f2 = rand.nextFloat() * 0.5F;
                float f4 = rand.nextFloat() * 3.141593F * 2.0F;
                entityitem.motionX = -MathHelper.sin(f4) * f2;
                entityitem.motionZ = MathHelper.cos(f4) * f2;
                entityitem.motionY = 0.20000000298023224D;
            }
            else
            {
                float f1 = 0.3F;
                entityitem.motionX = -MathHelper.sin((rotationYaw / 180F) * 3.141593F) *
                                     MathHelper.cos((rotationPitch / 180F) * 3.141593F) * f1;
                entityitem.motionZ = MathHelper.cos((rotationYaw / 180F) * 3.141593F) *
                                     MathHelper.cos((rotationPitch / 180F) * 3.141593F) * f1;
                entityitem.motionY = -MathHelper.sin((rotationPitch / 180F) * 3.141593F) * f1 + 0.1F;
                f1 = 0.02F;
                float f3 = rand.nextFloat() * 3.141593F * 2.0F;
                f1 *= rand.nextFloat();
                entityitem.motionX += Math.cos(f3) * f1;
                entityitem.motionY += (rand.nextFloat() - rand.nextFloat()) * 0.1F;
                entityitem.motionZ += Math.sin(f3) * f1;
            }
            joinEntityItemWithWorld(entityitem);
        }
Ejemplo n.º 11
0
        public override void setEntityDead()
        {
            for (int i = 0; i < getSizeInventory(); i++)
            {
                ItemStack itemstack = getStackInSlot(i);
                if (itemstack == null)
                {
                    continue;
                }
                float f  = rand.nextFloat() * 0.8F + 0.1F;
                float f1 = rand.nextFloat() * 0.8F + 0.1F;
                float f2 = rand.nextFloat() * 0.8F + 0.1F;
                do
                {
                    if (itemstack.stackSize <= 0)
                    {
                        break;
                    }
                    int j = rand.nextInt(21) + 10;
                    if (j > itemstack.stackSize)
                    {
                        j = itemstack.stackSize;
                    }
                    itemstack.stackSize -= j;
                    var entityitem = new EntityItem(worldObj, posX + f, posY + f1,
                                                    posZ + f2,
                                                    new ItemStack(itemstack.itemID, j, itemstack.getItemDamage()));
                    float f3 = 0.05F;
                    entityitem.motionX = (float)rand.nextGaussian() * f3;
                    entityitem.motionY = (float)rand.nextGaussian() * f3 + 0.2F;
                    entityitem.motionZ = (float)rand.nextGaussian() * f3;
                    worldObj.entityJoinedWorld(entityitem);
                } while (true);
            }

            base.setEntityDead();
        }
Ejemplo n.º 12
0
        public override void setEntityDead()
        {
            for (int i = 0; i < getSizeInventory(); i++)
            {
                ItemStack itemstack = getStackInSlot(i);
                if (itemstack == null)
                {
                    continue;
                }
                float f = rand.nextFloat()*0.8F + 0.1F;
                float f1 = rand.nextFloat()*0.8F + 0.1F;
                float f2 = rand.nextFloat()*0.8F + 0.1F;
                do
                {
                    if (itemstack.stackSize <= 0)
                    {
                        break;
                    }
                    int j = rand.nextInt(21) + 10;
                    if (j > itemstack.stackSize)
                    {
                        j = itemstack.stackSize;
                    }
                    itemstack.stackSize -= j;
                    var entityitem = new EntityItem(worldObj, posX + f, posY + f1,
                                                    posZ + f2,
                                                    new ItemStack(itemstack.itemID, j, itemstack.getItemDamage()));
                    float f3 = 0.05F;
                    entityitem.motionX = (float) rand.nextGaussian()*f3;
                    entityitem.motionY = (float) rand.nextGaussian()*f3 + 0.2F;
                    entityitem.motionZ = (float) rand.nextGaussian()*f3;
                    worldObj.entityJoinedWorld(entityitem);
                } while (true);
            }

            base.setEntityDead();
        }
Ejemplo n.º 13
0
 public void joinEntityItemWithWorld(EntityItem entityitem)
 {
     worldObj.entityJoinedWorld(entityitem);
 }
Ejemplo n.º 14
0
 public void dropPlayerItemWithRandomChoice(ItemStack itemstack, bool flag)
 {
     if (itemstack == null)
     {
         return;
     }
     var entityitem = new EntityItem(worldObj, posX,
                                     (posY - 0.30000001192092896D) + getEyeHeight(), posZ,
                                     itemstack);
     entityitem.delayBeforeCanPickup = 40;
     float f = 0.1F;
     if (flag)
     {
         float f2 = rand.nextFloat()*0.5F;
         float f4 = rand.nextFloat()*3.141593F*2.0F;
         entityitem.motionX = -MathHelper.sin(f4)*f2;
         entityitem.motionZ = MathHelper.cos(f4)*f2;
         entityitem.motionY = 0.20000000298023224D;
     }
     else
     {
         float f1 = 0.3F;
         entityitem.motionX = -MathHelper.sin((rotationYaw/180F)*3.141593F)*
                              MathHelper.cos((rotationPitch/180F)*3.141593F)*f1;
         entityitem.motionZ = MathHelper.cos((rotationYaw/180F)*3.141593F)*
                              MathHelper.cos((rotationPitch/180F)*3.141593F)*f1;
         entityitem.motionY = -MathHelper.sin((rotationPitch/180F)*3.141593F)*f1 + 0.1F;
         f1 = 0.02F;
         float f3 = rand.nextFloat()*3.141593F*2.0F;
         f1 *= rand.nextFloat();
         entityitem.motionX += Math.cos(f3)*f1;
         entityitem.motionY += (rand.nextFloat() - rand.nextFloat())*0.1F;
         entityitem.motionZ += Math.sin(f3)*f1;
     }
     joinEntityItemWithWorld(entityitem);
 }
Ejemplo n.º 15
0
 public virtual EntityItem entityDropItem(ItemStack itemstack, float f)
 {
     var entityitem = new EntityItem(worldObj, posX, posY + f, posZ, itemstack);
     entityitem.delayBeforeCanPickup = 10;
     worldObj.entityJoinedWorld(entityitem);
     return entityitem;
 }
Ejemplo n.º 16
0
 public virtual void dropBlockAsItemWithChance(World world, int i, int j, int k, int l, float f)
 {
     if (world.singleplayerWorld)
     {
         return;
     }
     int i1 = quantityDropped(world.rand);
     for (int j1 = 0; j1 < i1; j1++)
     {
         if (world.rand.nextFloat() > f)
         {
             continue;
         }
         int k1 = idDropped(l, world.rand);
         if (k1 > 0)
         {
             float f1 = 0.7F;
             double d = (world.rand.nextFloat()*f1) + (1.0F - f1)*0.5D;
             double d1 = (world.rand.nextFloat()*f1) + (1.0F - f1)*0.5D;
             double d2 = (world.rand.nextFloat()*f1) + (1.0F - f1)*0.5D;
             var entityitem = new EntityItem(world, i + d, j + d1, k + d2,
                                             new ItemStack(k1, 1, damageDropped(l)));
             entityitem.delayBeforeCanPickup = 10;
             world.entityJoinedWorld(entityitem);
         }
     }
 }
Ejemplo n.º 17
0
 public void joinEntityItemWithWorld(EntityItem entityitem)
 {
     worldObj.entityJoinedWorld(entityitem);
 }
Ejemplo n.º 18
0
        private void dispenseItem(World world, int i, int j, int k, Random random)
        {
            int   l  = world.getBlockMetadata(i, j, k);
            float f  = 0.0F;
            float f1 = 0.0F;

            if (l == 3)
            {
                f1 = 1.0F;
            }
            else if (l == 2)
            {
                f1 = -1F;
            }
            else if (l == 5)
            {
                f = 1.0F;
            }
            else
            {
                f = -1F;
            }
            var       tileentitydispenser = (TileEntityDispenser)world.getBlockTileEntity(i, j, k);
            ItemStack itemstack           = tileentitydispenser.getRandomStackFromInventory();
            double    d  = i + f * 0.5D + 0.5D;
            double    d1 = j + 0.5D;
            double    d2 = k + f1 * 0.5D + 0.5D;

            if (itemstack == null)
            {
                world.playSoundEffect(i, j, k, "random.click", 1.0F, 1.2F);
            }
            else
            {
                if (itemstack.itemID == Item.arrow.shiftedIndex)
                {
                    var entityarrow = new EntityArrow(world, d, d1, d2);
                    entityarrow.setArrowHeading(f, 0.10000000149011612D, f1, 1.1F, 6F);
                    world.entityJoinedWorld(entityarrow);
                    world.playSoundEffect(i, j, k, "random.bow", 1.0F, 1.2F);
                }
                else if (itemstack.itemID == Item.egg.shiftedIndex)
                {
                    var entityegg = new EntityEgg(world, d, d1, d2);
                    entityegg.func_20078_a(f, 0.10000000149011612D, f1, 1.1F, 6F);
                    world.entityJoinedWorld(entityegg);
                    world.playSoundEffect(i, j, k, "random.bow", 1.0F, 1.2F);
                }
                else if (itemstack.itemID == Item.snowball.shiftedIndex)
                {
                    var entitysnowball = new EntitySnowball(world, d, d1, d2);
                    entitysnowball.func_6141_a(f, 0.10000000149011612D, f1, 1.1F, 6F);
                    world.entityJoinedWorld(entitysnowball);
                    world.playSoundEffect(i, j, k, "random.bow", 1.0F, 1.2F);
                }
                else
                {
                    var    entityitem = new EntityItem(world, d, d1 - 0.29999999999999999D, d2, itemstack);
                    double d3         = random.nextDouble() * 0.10000000000000001D + 0.20000000000000001D;
                    entityitem.motionX  = f * d3;
                    entityitem.motionY  = 0.20000000298023224D;
                    entityitem.motionZ  = f1 * d3;
                    entityitem.motionX += random.nextGaussian() * 0.0074999998323619366D * 6D;
                    entityitem.motionY += random.nextGaussian() * 0.0074999998323619366D * 6D;
                    entityitem.motionZ += random.nextGaussian() * 0.0074999998323619366D * 6D;
                    world.entityJoinedWorld(entityitem);
                    world.playSoundEffect(i, j, k, "random.click", 1.0F, 1.0F);
                }
                for (int i1 = 0; i1 < 10; i1++)
                {
                    double d4  = random.nextDouble() * 0.20000000000000001D + 0.01D;
                    double d5  = d + f * 0.01D + (random.nextDouble() - 0.5D) * f1 * 0.5D;
                    double d6  = d1 + (random.nextDouble() - 0.5D) * 0.5D;
                    double d7  = d2 + f1 * 0.01D + (random.nextDouble() - 0.5D) * f * 0.5D;
                    double d8  = f * d4 + random.nextGaussian() * 0.01D;
                    double d9  = -0.029999999999999999D + random.nextGaussian() * 0.01D;
                    double d10 = f1 * d4 + random.nextGaussian() * 0.01D;
                    world.spawnParticle("smoke", d5, d6, d7, d8, d9, d10);
                }
            }
        }
Ejemplo n.º 19
0
        public override void onBlockRemoval(World world, int i, int j, int k)
        {
            var tileentitychest = (TileEntityChest) world.getBlockTileEntity(i, j, k);

            for (int l = 0; l < tileentitychest.getSizeInventory(); l++)
            {
                ItemStack itemstack = tileentitychest.getStackInSlot(l);
                if (itemstack == null)
                {
                    continue;
                }
                float f = random.nextFloat()*0.8F + 0.1F;
                float f1 = random.nextFloat()*0.8F + 0.1F;
                float f2 = random.nextFloat()*0.8F + 0.1F;
                do
                {
                    if (itemstack.stackSize <= 0)
                    {
                        goto label0;
                    }
                    int i1 = random.nextInt(21) + 10;
                    if (i1 > itemstack.stackSize)
                    {
                        i1 = itemstack.stackSize;
                    }
                    itemstack.stackSize -= i1;
                    var entityitem = new EntityItem(world, i + f, j + f1, k + f2,
                                                    new ItemStack(itemstack.itemID, i1, itemstack.getItemDamage()));
                    float f3 = 0.05F;
                    entityitem.motionX = (float) random.nextGaussian()*f3;
                    entityitem.motionY = (float) random.nextGaussian()*f3 + 0.2F;
                    entityitem.motionZ = (float) random.nextGaussian()*f3;
                    world.entityJoinedWorld(entityitem);
                } while (true);
            }
            label0:
            base.onBlockRemoval(world, i, j, k);
        }