コード例 #1
0
ファイル: Entity.java プロジェクト: MadMockers/mc-dev
  public EntityItem a(int i1, int j1, float f1) {
    EntityItem entityitem = new EntityItem(l, p, q + (double) f1, r, new ItemStack(i1, j1));

    entityitem.c = 10;
    l.a(entityitem);
    return entityitem;
  }
コード例 #2
0
ファイル: BlockJukeBox.java プロジェクト: plleg/mc-dev
  public void dropRecord(World world, int i, int j, int k) {
    if (!world.isStatic) {
      TileEntityRecordPlayer tileentityrecordplayer =
          (TileEntityRecordPlayer) world.getTileEntity(i, j, k);

      if (tileentityrecordplayer != null) {
        ItemStack itemstack = tileentityrecordplayer.record;

        if (itemstack != null) {
          world.triggerEffect(1005, i, j, k, 0);
          world.a((String) null, i, j, k);
          tileentityrecordplayer.record = null;
          tileentityrecordplayer.update();
          world.setData(i, j, k, 0);
          float f = 0.7F;
          double d0 = (double) (world.random.nextFloat() * f) + (double) (1.0F - f) * 0.5D;
          double d1 = (double) (world.random.nextFloat() * f) + (double) (1.0F - f) * 0.2D + 0.6D;
          double d2 = (double) (world.random.nextFloat() * f) + (double) (1.0F - f) * 0.5D;
          ItemStack itemstack1 = itemstack.cloneItemStack();
          EntityItem entityitem =
              new EntityItem(world, (double) i + d0, (double) j + d1, (double) k + d2, itemstack1);

          entityitem.pickupDelay = 10;
          world.addEntity(entityitem);
        }
      }
    }
  }
コード例 #3
0
  public void dropNaturally(World world, int i, int j, int k, int l, float f, int i1) {
    super.dropNaturally(world, i, j, k, l, f, i1);
    if (!world.isStatic) {
      Item item = null;

      if (this.blockFruit == Block.PUMPKIN) {
        item = Item.PUMPKIN_SEEDS;
      }

      if (this.blockFruit == Block.MELON) {
        item = Item.MELON_SEEDS;
      }

      for (int j1 = 0; j1 < 3; ++j1) {
        if (world.random.nextInt(15) <= l) {
          float f1 = 0.7F;
          float f2 = world.random.nextFloat() * f1 + (1.0F - f1) * 0.5F;
          float f3 = world.random.nextFloat() * f1 + (1.0F - f1) * 0.5F;
          float f4 = world.random.nextFloat() * f1 + (1.0F - f1) * 0.5F;
          EntityItem entityitem =
              new EntityItem(
                  world,
                  (double) ((float) i + f2),
                  (double) ((float) j + f3),
                  (double) ((float) k + f4),
                  new ItemStack(item));

          entityitem.pickupDelay = 10;
          world.addEntity(entityitem);
        }
      }
    }
  }
コード例 #4
0
  /** Ejects the current record inside of the jukebox. */
  public void ejectRecord(World par1World, int par2, int par3, int par4) {
    if (!par1World.isRemote) {
      TileEntityRecordPlayer var5 =
          (TileEntityRecordPlayer) par1World.getBlockTileEntity(par2, par3, par4);

      if (var5 != null) {
        ItemStack var6 = var5.func_96097_a();

        if (var6 != null) {
          par1World.playAuxSFX(1005, par2, par3, par4, 0);
          par1World.playRecord((String) null, par2, par3, par4);
          var5.func_96098_a((ItemStack) null);
          par1World.setBlockMetadataWithNotify(par2, par3, par4, 0, 2);
          float var7 = 0.7F;
          double var8 =
              (double) (par1World.rand.nextFloat() * var7) + (double) (1.0F - var7) * 0.5D;
          double var10 =
              (double) (par1World.rand.nextFloat() * var7) + (double) (1.0F - var7) * 0.2D + 0.6D;
          double var12 =
              (double) (par1World.rand.nextFloat() * var7) + (double) (1.0F - var7) * 0.5D;
          ItemStack var14 = var6.copy();
          EntityItem var15 =
              new EntityItem(
                  par1World,
                  (double) par2 + var8,
                  (double) par3 + var10,
                  (double) par4 + var12,
                  var14);
          var15.delayBeforeCanPickup = 10;
          par1World.spawnEntityInWorld(var15);
        }
      }
    }
  }
コード例 #5
0
  public static boolean addEntityItem(IInventory iinventory, EntityItem entityitem) {
    boolean flag = false;

    if (entityitem == null) {
      return false;
    } else {
      // CraftBukkit start
      InventoryPickupItemEvent event =
          new InventoryPickupItemEvent(
              iinventory.getOwner().getInventory(),
              (org.bukkit.entity.Item) entityitem.getBukkitEntity());
      entityitem.world.getServer().getPluginManager().callEvent(event);
      if (event.isCancelled()) {
        return false;
      }
      // CraftBukkit end

      ItemStack itemstack = entityitem.getItemStack().cloneItemStack();
      ItemStack itemstack1 = addItem(iinventory, itemstack, -1);

      if (itemstack1 != null && itemstack1.count != 0) {
        entityitem.setItemStack(itemstack1);
      } else {
        flag = true;
        entityitem.die();
      }

      return flag;
    }
  }
コード例 #6
0
ファイル: Entity.java プロジェクト: dested/CraftbukkitMaps
  public EntityItem a(ItemStack itemstack, float f) {
    EntityItem entityitem =
        new EntityItem(this.world, this.locX, this.locY + (double) f, this.locZ, itemstack);

    entityitem.pickupDelay = 10;
    this.world.addEntity(entityitem);
    return entityitem;
  }
コード例 #7
0
 public void pickupItemOnBounds(EntityItem e) {
   if (getBounds().intersects(e.getBounds()) && pickupItemOnBounds) {
     if (e.getLinkedItem(this) instanceof Weapon) {
       weaponEquipped = (Weapon) e.getLinkedItem(this);
       e.removeItem(e);
     }
   }
 }
コード例 #8
0
 public void fromSectionValue(Object aValue) {
   if (aValue instanceof ArrayList) {
     for (Object lItem : ((ArrayList) aValue)) {
       EntityItem lEnt = new EntityItem();
       lEnt.quest = quest;
       lEnt.fromSectionValue(lItem);
       add(lEnt);
     }
   }
 }
コード例 #9
0
ファイル: Entity.java プロジェクト: randyzingle/javaalg
  public EntityItem a(ItemStack itemstack, float f) {
    if (itemstack.count != 0 && itemstack.getItem() != null) {
      EntityItem entityitem =
          new EntityItem(this.world, this.locX, this.locY + (double) f, this.locZ, itemstack);

      entityitem.p();
      this.world.addEntity(entityitem);
      return entityitem;
    } else {
      return null;
    }
  }
コード例 #10
0
ファイル: EntityMySheep.java プロジェクト: EALS634/MyPet
  public boolean handlePlayerInteraction(EntityHuman entityhuman) {
    if (super.handlePlayerInteraction(entityhuman)) {
      return true;
    }

    ItemStack itemStack = entityhuman.inventory.getItemInHand();

    if (getOwner().equals(entityhuman) && itemStack != null && canUseItem()) {
      if (itemStack.getItem() == Items.DYE
          && itemStack.getData() <= 15
          && itemStack.getData() != getMyPet().getColor().getDyeData()
          && !getMyPet().isSheared()) {
        getMyPet().setColor(DyeColor.getByDyeData((byte) itemStack.getData()));
        if (!entityhuman.abilities.canInstantlyBuild) {
          if (--itemStack.count <= 0) {
            entityhuman.inventory.setItem(entityhuman.inventory.itemInHandIndex, null);
          }
        }
        return true;
      } else if (itemStack.getItem() == Items.SHEARS
          && MySheep.CAN_BE_SHEARED
          && !getMyPet().isSheared()) {
        getMyPet().setSheared(true);
        int woolDropCount = 1 + this.random.nextInt(3);

        for (int j = 0; j < woolDropCount; ++j) {
          EntityItem entityitem =
              this.a(new ItemStack(Blocks.WOOL, 1, getMyPet().getColor().getDyeData()), 1.0F);

          entityitem.motY += (double) this.random.nextFloat() * 0.05F;
          entityitem.motX += (double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.1F);
          entityitem.motZ += (double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.1F);
        }
        makeSound("mob.sheep.shear", 1.0F, 1.0F);
        if (!entityhuman.abilities.canInstantlyBuild) {
          itemStack.damage(1, entityhuman);
        }
        return true;
      } else if (MySheep.GROW_UP_ITEM.compare(itemStack)
          && getMyPet().isBaby()
          && getOwner().getPlayer().isSneaking()) {
        if (!entityhuman.abilities.canInstantlyBuild) {
          if (--itemStack.count <= 0) {
            entityhuman.inventory.setItem(entityhuman.inventory.itemInHandIndex, null);
          }
        }
        getMyPet().setBaby(false);
        return true;
      }
    }
    return false;
  }
コード例 #11
0
ファイル: Block.java プロジェクト: Resistance/mc-dev
  protected void a(World world, int i, int j, int k, ItemStack itemstack) {
    if (!world.isStatic) {
      float f = 0.7F;
      double d0 = (double) (world.random.nextFloat() * f) + (double) (1.0F - f) * 0.5D;
      double d1 = (double) (world.random.nextFloat() * f) + (double) (1.0F - f) * 0.5D;
      double d2 = (double) (world.random.nextFloat() * f) + (double) (1.0F - f) * 0.5D;
      EntityItem entityitem =
          new EntityItem(world, (double) i + d0, (double) j + d1, (double) k + d2, itemstack);

      entityitem.pickupDelay = 10;
      world.addEntity(entityitem);
    }
  }
コード例 #12
0
ファイル: BlockSnow.java プロジェクト: CollinJ/mc-dev
  public void g(World world, int i, int j, int k, int l) {
    int i1 = Item.aB.ba;
    float f = 0.7F;
    double d1 = (double) (world.l.nextFloat() * f) + (double) (1.0F - f) * 0.5D;
    double d2 = (double) (world.l.nextFloat() * f) + (double) (1.0F - f) * 0.5D;
    double d3 = (double) (world.l.nextFloat() * f) + (double) (1.0F - f) * 0.5D;
    EntityItem entityitem =
        new EntityItem(
            world, (double) i + d1, (double) j + d2, (double) k + d3, new ItemStack(i1, 1, 0));

    entityitem.c = 10;
    world.a(((Entity) (entityitem)));
    world.e(i, j, k, 0);
  }
コード例 #13
0
ファイル: EntityMinecart.java プロジェクト: plleg/mc-dev
  public void die() {
    if (this.h) {
      for (int i = 0; i < this.getSize(); ++i) {
        ItemStack itemstack = this.getItem(i);

        if (itemstack != null) {
          float f = this.random.nextFloat() * 0.8F + 0.1F;
          float f1 = this.random.nextFloat() * 0.8F + 0.1F;
          float f2 = this.random.nextFloat() * 0.8F + 0.1F;

          while (itemstack.count > 0) {
            int j = this.random.nextInt(21) + 10;

            if (j > itemstack.count) {
              j = itemstack.count;
            }

            itemstack.count -= j;
            EntityItem entityitem =
                new EntityItem(
                    this.world,
                    this.locX + (double) f,
                    this.locY + (double) f1,
                    this.locZ + (double) f2,
                    new ItemStack(itemstack.id, j, itemstack.getData()));

            if (itemstack.hasTag()) {
              entityitem.itemStack.setTag((NBTTagCompound) itemstack.getTag().clone());
            }

            float f3 = 0.05F;

            entityitem.motX = (double) ((float) this.random.nextGaussian() * f3);
            entityitem.motY = (double) ((float) this.random.nextGaussian() * f3 + 0.2F);
            entityitem.motZ = (double) ((float) this.random.nextGaussian() * f3);
            this.world.addEntity(entityitem);
          }
        }
      }
    }

    super.die();
    if (this.g != null) {
      this.g.a();
    }
  }
コード例 #14
0
  public void remove(World world, int i, int j, int k) {
    TileEntityDispenser tileentitydispenser = (TileEntityDispenser) world.getTileEntity(i, j, k);

    if (tileentitydispenser != null) {
      for (int l = 0; l < tileentitydispenser.getSize(); ++l) {
        ItemStack itemstack = tileentitydispenser.getItem(l);

        if (itemstack != null) {
          float f = this.a.nextFloat() * 0.8F + 0.1F;
          float f1 = this.a.nextFloat() * 0.8F + 0.1F;
          float f2 = this.a.nextFloat() * 0.8F + 0.1F;

          while (itemstack.count > 0) {
            int i1 = this.a.nextInt(21) + 10;

            if (i1 > itemstack.count) {
              i1 = itemstack.count;
            }

            itemstack.count -= i1;
            EntityItem entityitem =
                new EntityItem(
                    world,
                    (double) ((float) i + f),
                    (double) ((float) j + f1),
                    (double) ((float) k + f2),
                    new ItemStack(itemstack.id, i1, itemstack.getData()));

            if (itemstack.hasTag()) {
              entityitem.itemStack.setTag((NBTTagCompound) itemstack.getTag().clone());
            }

            float f3 = 0.05F;

            entityitem.motX = (double) ((float) this.a.nextGaussian() * f3);
            entityitem.motY = (double) ((float) this.a.nextGaussian() * f3 + 0.2F);
            entityitem.motZ = (double) ((float) this.a.nextGaussian() * f3);
            world.addEntity(entityitem);
          }
        }
      }
    }

    super.remove(world, i, j, k);
  }
コード例 #15
0
  public void w() {
    if (this.b) {
      for (int i0 = 0; i0 < this.j_(); ++i0) {
        ItemStack itemstack = this.a(i0);

        if (itemstack != null) {
          float f0 = this.ab.nextFloat() * 0.8F + 0.1F;
          float f1 = this.ab.nextFloat() * 0.8F + 0.1F;
          float f2 = this.ab.nextFloat() * 0.8F + 0.1F;

          while (itemstack.a > 0) {
            int i1 = this.ab.nextInt(21) + 10;

            if (i1 > itemstack.a) {
              i1 = itemstack.a;
            }

            itemstack.a -= i1;
            EntityItem entityitem =
                new EntityItem(
                    this.q,
                    this.u + (double) f0,
                    this.v + (double) f1,
                    this.w + (double) f2,
                    new ItemStack(itemstack.c, i1, itemstack.k()));

            if (itemstack.p()) {
              entityitem.d().d((NBTTagCompound) itemstack.q().b());
            }

            float f3 = 0.05F;

            entityitem.x = (double) ((float) this.ab.nextGaussian() * f3);
            entityitem.y = (double) ((float) this.ab.nextGaussian() * f3 + 0.2F);
            entityitem.z = (double) ((float) this.ab.nextGaussian() * f3);
            this.q.d((Entity) entityitem);
          }
        }
      }
    }

    super.w();
  }
コード例 #16
0
  public void remove(World world, int i, int j, int k, int l, int i1) {
    TileEntity tileentity = world.getTileEntity(i, j, k);

    if (tileentity instanceof TileEntityBrewingStand) {
      TileEntityBrewingStand tileentitybrewingstand = (TileEntityBrewingStand) tileentity;

      for (int j1 = 0; j1 < tileentitybrewingstand.getSize(); ++j1) {
        ItemStack itemstack = tileentitybrewingstand.getItem(j1);

        if (itemstack != null) {
          float f = this.a.nextFloat() * 0.8F + 0.1F;
          float f1 = this.a.nextFloat() * 0.8F + 0.1F;
          float f2 = this.a.nextFloat() * 0.8F + 0.1F;

          while (itemstack.count > 0) {
            int k1 = this.a.nextInt(21) + 10;

            if (k1 > itemstack.count) {
              k1 = itemstack.count;
            }

            itemstack.count -= k1;
            EntityItem entityitem =
                new EntityItem(
                    world,
                    (double) ((float) i + f),
                    (double) ((float) j + f1),
                    (double) ((float) k + f2),
                    new ItemStack(itemstack.id, k1, itemstack.getData()));
            float f3 = 0.05F;

            entityitem.motX = (double) ((float) this.a.nextGaussian() * f3);
            entityitem.motY = (double) ((float) this.a.nextGaussian() * f3 + 0.2F);
            entityitem.motZ = (double) ((float) this.a.nextGaussian() * f3);
            world.addEntity(entityitem);
          }
        }
      }
    }

    super.remove(world, i, j, k, l, i1);
  }
コード例 #17
0
ファイル: EntityWither.java プロジェクト: DaMarine/Alkazia
  protected void dropDeathLoot(boolean flag, int i) {
    EntityItem entityitem = this.a(Items.NETHER_STAR, 1);

    if (entityitem != null) {
      entityitem.u();
    }

    if (!this.world.isStatic) {
      Iterator iterator =
          this.world
              .a(EntityHuman.class, this.getBoundingBox().grow(50.0D, 100.0D, 50.0D))
              .iterator();

      while (iterator.hasNext()) {
        EntityHuman entityhuman = (EntityHuman) iterator.next();

        entityhuman.b((Statistic) AchievementList.J);
      }
    }
  }
コード例 #18
0
  public boolean handlePlayerInteraction(EntityHuman entityhuman) {
    if (super.handlePlayerInteraction(entityhuman)) {
      return true;
    }

    ItemStack itemStack = entityhuman.inventory.getItemInHand();

    if (getOwner().equals(entityhuman) && itemStack != null && canUseItem()) {
      if (itemStack.id == Item.SHEARS.id && getOwner().getPlayer().isSneaking()) {
        if (!canEquip()) {
          return false;
        }
        for (EquipmentSlot slot : EquipmentSlot.values()) {
          ItemStack itemInSlot = ((MySkeleton) myPet).getEquipment(slot);
          if (itemInSlot != null) {
            EntityItem entityitem = this.a(itemInSlot.cloneItemStack(), 1.0F);
            entityitem.motY += (double) (this.random.nextFloat() * 0.05F);
            entityitem.motX +=
                (double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.1F);
            entityitem.motZ +=
                (double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.1F);
            setPetEquipment(slot.getSlotId(), null);
          }
        }
        return true;
      } else if (checkForEquipment(itemStack) && getOwner().getPlayer().isSneaking()) {
        if (!canEquip()) {
          return false;
        }
        EquipmentSlot slot = EquipmentSlot.getSlotById(b(itemStack));
        ItemStack itemInSlot = ((MySkeleton) myPet).getEquipment(slot);
        if (itemInSlot != null && !entityhuman.abilities.canInstantlyBuild) {
          EntityItem entityitem = this.a(itemInSlot.cloneItemStack(), 1.0F);
          entityitem.motY += (double) (this.random.nextFloat() * 0.05F);
          entityitem.motX += (double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.1F);
          entityitem.motZ += (double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.1F);
        }
        ItemStack itemStackClone = itemStack.cloneItemStack();
        itemStackClone.count = 1;
        setPetEquipment(b(itemStack), itemStackClone);
        if (!entityhuman.abilities.canInstantlyBuild) {
          --itemStack.count;
        }
        if (itemStack.count <= 0) {
          entityhuman.inventory.setItem(entityhuman.inventory.itemInHandIndex, null);
        }
        return true;
      }
    }
    return false;
  }
コード例 #19
0
ファイル: EntityMyIronGolem.java プロジェクト: jjm223/MyPet
  public boolean handlePlayerInteraction(EntityHuman entityhuman) {
    if (super.handlePlayerInteraction(entityhuman)) {
      return true;
    }

    ItemStack itemStack = entityhuman.inventory.getItemInHand();

    if (getOwner().equals(entityhuman) && itemStack != null && canUseItem()) {
      if (itemStack.getItem() == Item.getItemOf(Blocks.RED_FLOWER)
          && !getMyPet().hasFlower()
          && getOwner().getPlayer().isSneaking()) {
        getMyPet().setFlower(CraftItemStack.asBukkitCopy(itemStack));
        if (!entityhuman.abilities.canInstantlyBuild) {
          if (--itemStack.count <= 0) {
            entityhuman.inventory.setItem(entityhuman.inventory.itemInHandIndex, null);
          }
        }
        return true;
      } else if (itemStack.getItem() == Items.SHEARS
          && getMyPet().hasFlower()
          && getOwner().getPlayer().isSneaking()) {
        EntityItem entityitem = this.a(CraftItemStack.asNMSCopy(getMyPet().getFlower()), 1.0F);
        entityitem.motY += (double) (this.random.nextFloat() * 0.05F);
        entityitem.motX += (double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.1F);
        entityitem.motZ += (double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.1F);

        makeSound("mob.sheep.shear", 1.0F, 1.0F);
        getMyPet().setFlower(null);
        if (!entityhuman.abilities.canInstantlyBuild) {
          itemStack.damage(1, entityhuman);
        }

        return true;
      }
    }
    return false;
  }
コード例 #20
0
  public void a(DamageSource damagesource) {
    super.a(damagesource);

    for (int i0 = 0; i0 < this.j_(); ++i0) {
      ItemStack itemstack = this.a(i0);

      if (itemstack != null) {
        float f0 = this.ab.nextFloat() * 0.8F + 0.1F;
        float f1 = this.ab.nextFloat() * 0.8F + 0.1F;
        float f2 = this.ab.nextFloat() * 0.8F + 0.1F;

        while (itemstack.a > 0) {
          int i1 = this.ab.nextInt(21) + 10;

          if (i1 > itemstack.a) {
            i1 = itemstack.a;
          }

          itemstack.a -= i1;
          EntityItem entityitem =
              new EntityItem(
                  this.q,
                  this.u + (double) f0,
                  this.v + (double) f1,
                  this.w + (double) f2,
                  new ItemStack(itemstack.c, i1, itemstack.k()));
          float f3 = 0.05F;

          entityitem.x = (double) ((float) this.ab.nextGaussian() * f3);
          entityitem.y = (double) ((float) this.ab.nextGaussian() * f3 + 0.2F);
          entityitem.z = (double) ((float) this.ab.nextGaussian() * f3);
          this.q.d((Entity) entityitem);
        }
      }
    }
  }
コード例 #21
0
  private Packet b() {
    if (this.tracker.dead) {
      System.out.println("Fetching addPacket for removed entity");
    }

    if (this.tracker instanceof EntityItem) {
      EntityItem entityitem = (EntityItem) this.tracker;
      Packet21PickupSpawn packet21pickupspawn = new Packet21PickupSpawn(entityitem);

      entityitem.locX = (double) packet21pickupspawn.b / 32.0D;
      entityitem.locY = (double) packet21pickupspawn.c / 32.0D;
      entityitem.locZ = (double) packet21pickupspawn.d / 32.0D;
      return packet21pickupspawn;
    } else if (this.tracker instanceof EntityPlayer) {
      return new Packet20NamedEntitySpawn((EntityHuman) this.tracker);
    } else {
      if (this.tracker instanceof EntityMinecart) {
        EntityMinecart entityminecart = (EntityMinecart) this.tracker;

        if (entityminecart.type == 0) {
          return new Packet23VehicleSpawn(this.tracker, 10);
        }

        if (entityminecart.type == 1) {
          return new Packet23VehicleSpawn(this.tracker, 11);
        }

        if (entityminecart.type == 2) {
          return new Packet23VehicleSpawn(this.tracker, 12);
        }
      }

      if (this.tracker instanceof EntityBoat) {
        return new Packet23VehicleSpawn(this.tracker, 1);
      } else if (!(this.tracker instanceof IAnimal)
          && !(this.tracker instanceof EntityEnderDragon)) {
        if (this.tracker instanceof EntityFishingHook) {
          EntityHuman entityhuman = ((EntityFishingHook) this.tracker).owner;

          return new Packet23VehicleSpawn(
              this.tracker, 90, entityhuman != null ? entityhuman.id : this.tracker.id);
        } else if (this.tracker instanceof EntityArrow) {
          Entity entity = ((EntityArrow) this.tracker).shooter;

          return new Packet23VehicleSpawn(
              this.tracker, 60, entity != null ? entity.id : this.tracker.id);
        } else if (this.tracker instanceof EntitySnowball) {
          return new Packet23VehicleSpawn(this.tracker, 61);
        } else if (this.tracker instanceof EntityPotion) {
          return new Packet23VehicleSpawn(
              this.tracker, 73, ((EntityPotion) this.tracker).getPotionValue());
        } else if (this.tracker instanceof EntityThrownExpBottle) {
          return new Packet23VehicleSpawn(this.tracker, 75);
        } else if (this.tracker instanceof EntityEnderPearl) {
          return new Packet23VehicleSpawn(this.tracker, 65);
        } else if (this.tracker instanceof EntityEnderSignal) {
          return new Packet23VehicleSpawn(this.tracker, 72);
        } else {
          Packet23VehicleSpawn packet23vehiclespawn;

          if (this.tracker instanceof EntitySmallFireball) {
            EntitySmallFireball entitysmallfireball = (EntitySmallFireball) this.tracker;

            packet23vehiclespawn = null;
            if (entitysmallfireball.shooter != null) {
              packet23vehiclespawn =
                  new Packet23VehicleSpawn(this.tracker, 64, entitysmallfireball.shooter.id);
            } else {
              packet23vehiclespawn = new Packet23VehicleSpawn(this.tracker, 64, 0);
            }

            packet23vehiclespawn.e = (int) (entitysmallfireball.dirX * 8000.0D);
            packet23vehiclespawn.f = (int) (entitysmallfireball.dirY * 8000.0D);
            packet23vehiclespawn.g = (int) (entitysmallfireball.dirZ * 8000.0D);
            return packet23vehiclespawn;
          } else if (this.tracker instanceof EntityFireball) {
            EntityFireball entityfireball = (EntityFireball) this.tracker;

            packet23vehiclespawn = null;
            if (entityfireball.shooter != null) {
              packet23vehiclespawn =
                  new Packet23VehicleSpawn(
                      this.tracker, 63, ((EntityFireball) this.tracker).shooter.id);
            } else {
              packet23vehiclespawn = new Packet23VehicleSpawn(this.tracker, 63, 0);
            }

            packet23vehiclespawn.e = (int) (entityfireball.dirX * 8000.0D);
            packet23vehiclespawn.f = (int) (entityfireball.dirY * 8000.0D);
            packet23vehiclespawn.g = (int) (entityfireball.dirZ * 8000.0D);
            return packet23vehiclespawn;
          } else if (this.tracker instanceof EntityEgg) {
            return new Packet23VehicleSpawn(this.tracker, 62);
          } else if (this.tracker instanceof EntityTNTPrimed) {
            return new Packet23VehicleSpawn(this.tracker, 50);
          } else if (this.tracker instanceof EntityEnderCrystal) {
            return new Packet23VehicleSpawn(this.tracker, 51);
          } else if (this.tracker instanceof EntityFallingBlock) {
            EntityFallingBlock entityfallingblock = (EntityFallingBlock) this.tracker;

            return new Packet23VehicleSpawn(
                this.tracker, 70, entityfallingblock.id | entityfallingblock.data << 16);
          } else if (this.tracker instanceof EntityPainting) {
            return new Packet25EntityPainting((EntityPainting) this.tracker);
          } else if (this.tracker instanceof EntityExperienceOrb) {
            return new Packet26AddExpOrb((EntityExperienceOrb) this.tracker);
          } else {
            throw new IllegalArgumentException(
                "Don\'t know how to add " + this.tracker.getClass() + "!");
          }
        }
      } else {
        this.i = MathHelper.d(this.tracker.am() * 256.0F / 360.0F);
        return new Packet24MobSpawn((EntityLiving) this.tracker);
      }
    }
  }
コード例 #22
0
  // CraftBukkit - priv to public
  public void dispense(World world, int i, int j, int k, Random random) {
    int l = world.getData(i, j, k);
    byte b0 = 0;
    byte b1 = 0;

    if (l == 3) {
      b1 = 1;
    } else if (l == 2) {
      b1 = -1;
    } else if (l == 5) {
      b0 = 1;
    } else {
      b0 = -1;
    }

    TileEntityDispenser tileentitydispenser = (TileEntityDispenser) world.getTileEntity(i, j, k);

    if (tileentitydispenser != null) {
      // CraftBukkit start
      int dispenseSlot = tileentitydispenser.findDispenseSlot();
      ItemStack itemstack = null;
      if (dispenseSlot > -1) {
        itemstack = tileentitydispenser.getContents()[dispenseSlot];

        // Copy item stack, because we want it to have 1 item
        itemstack =
            new ItemStack(itemstack.id, 1, itemstack.getData(), itemstack.getEnchantments());
      }
      // CraftBukkit end

      double d0 = (double) i + (double) b0 * 0.6D + 0.5D;
      double d1 = (double) j + 0.5D;
      double d2 = (double) k + (double) b1 * 0.6D + 0.5D;

      if (itemstack == null) {
        world.triggerEffect(1001, i, j, k, 0);
      } else {
        // CraftBukkit start
        double d3 = random.nextDouble() * 0.1D + 0.2D;
        double motX = (double) b0 * d3;
        double motY = 0.20000000298023224D;
        double motZ = (double) b1 * d3;
        motX += random.nextGaussian() * 0.007499999832361937D * 6.0D;
        motY += random.nextGaussian() * 0.007499999832361937D * 6.0D;
        motZ += random.nextGaussian() * 0.007499999832361937D * 6.0D;

        org.bukkit.block.Block block = world.getWorld().getBlockAt(i, j, k);
        org.bukkit.inventory.ItemStack bukkitItem = new CraftItemStack(itemstack).clone();

        BlockDispenseEvent event =
            new BlockDispenseEvent(block, bukkitItem, new Vector(motX, motY, motZ));
        world.getServer().getPluginManager().callEvent(event);

        if (event.isCancelled()) {
          return;
        }

        if (event.getItem().equals(bukkitItem)) {
          // Actually remove the item
          tileentitydispenser.splitStack(dispenseSlot, 1);
        }

        motX = event.getVelocity().getX();
        motY = event.getVelocity().getY();
        motZ = event.getVelocity().getZ();

        itemstack = CraftItemStack.createNMSItemStack(event.getItem());
        // CraftBukkit end

        if (itemstack.id == Item.ARROW.id) {
          EntityArrow entityarrow = new EntityArrow(world, d0, d1, d2);

          entityarrow.shoot((double) b0, 0.10000000149011612D, (double) b1, 1.1F, 6.0F);
          entityarrow.fromPlayer = true;
          world.addEntity(entityarrow);
          world.triggerEffect(1002, i, j, k, 0);
        } else if (itemstack.id == Item.EGG.id) {
          EntityEgg entityegg = new EntityEgg(world, d0, d1, d2);

          entityegg.a((double) b0, 0.10000000149011612D, (double) b1, 1.1F, 6.0F);
          world.addEntity(entityegg);
          world.triggerEffect(1002, i, j, k, 0);
        } else if (itemstack.id == Item.SNOW_BALL.id) {
          EntitySnowball entitysnowball = new EntitySnowball(world, d0, d1, d2);

          entitysnowball.a((double) b0, 0.10000000149011612D, (double) b1, 1.1F, 6.0F);
          world.addEntity(entitysnowball);
          world.triggerEffect(1002, i, j, k, 0);
        } else if (itemstack.id == Item.POTION.id && ItemPotion.c(itemstack.getData())) {
          EntityPotion entitypotion = new EntityPotion(world, d0, d1, d2, itemstack.getData());

          entitypotion.a((double) b0, 0.10000000149011612D, (double) b1, 1.375F, 3.0F);
          world.addEntity(entitypotion);
          world.triggerEffect(1002, i, j, k, 0);
        } else if (itemstack.id == Item.EXP_BOTTLE.id) {
          EntityThrownExpBottle entitythrownexpbottle =
              new EntityThrownExpBottle(world, d0, d1, d2);

          entitythrownexpbottle.a((double) b0, 0.10000000149011612D, (double) b1, 1.375F, 3.0F);
          world.addEntity(entitythrownexpbottle);
          world.triggerEffect(1002, i, j, k, 0);
        } else if (itemstack.id == Item.MONSTER_EGG.id) {
          ItemMonsterEgg.a(
              world,
              itemstack.getData(),
              d0 + (double) b0 * 0.3D,
              d1 - 0.3D,
              d2 + (double) b1 * 0.3D);
          world.triggerEffect(1002, i, j, k, 0);
        } else if (itemstack.id == Item.FIREBALL.id) {
          EntitySmallFireball entitysmallfireball =
              new EntitySmallFireball(
                  world,
                  d0 + (double) b0 * 0.3D,
                  d1,
                  d2 + (double) b1 * 0.3D,
                  (double) b0 + random.nextGaussian() * 0.05D,
                  random.nextGaussian() * 0.05D,
                  (double) b1 + random.nextGaussian() * 0.05D);

          world.addEntity(entitysmallfireball);
          world.triggerEffect(1009, i, j, k, 0);
        } else {
          EntityItem entityitem = new EntityItem(world, d0, d1 - 0.3D, d2, itemstack);
          // CraftBukkit start
          // double d3 = random.nextDouble() * 0.1D + 0.2D; // Moved up
          entityitem.motX = motX;
          entityitem.motY = motY;
          entityitem.motZ = motZ;
          // CraftBukkit end
          world.addEntity(entityitem);
          world.triggerEffect(1000, i, j, k, 0);
        }

        world.triggerEffect(2000, i, j, k, b0 + 1 + (b1 + 1) * 3);
      }
    }
  }
コード例 #23
0
ファイル: EntityHuman.java プロジェクト: Chocanto/mc-dev
  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;
      }

      this.a(entityitem);
      this.a(StatisticList.v, 1);
      return entityitem;
    }
  }
コード例 #24
0
ファイル: EntityMinecart.java プロジェクト: plleg/mc-dev
  public boolean damageEntity(DamageSource damagesource, int i) {
    if (!this.world.isStatic && !this.dead) {
      if (this.isInvulnerable()) {
        return false;
      } else {
        this.i(-this.k());
        this.h(10);
        this.K();
        this.setDamage(this.getDamage() + i * 10);
        if (damagesource.getEntity() instanceof EntityHuman
            && ((EntityHuman) damagesource.getEntity()).abilities.canInstantlyBuild) {
          this.setDamage(100);
        }

        if (this.getDamage() > 40) {
          if (this.passenger != null) {
            this.passenger.mount(this);
          }

          this.die();
          this.a(Item.MINECART.id, 1, 0.0F);
          if (this.type == 1) {
            EntityMinecart entityminecart = this;

            for (int j = 0; j < entityminecart.getSize(); ++j) {
              ItemStack itemstack = entityminecart.getItem(j);

              if (itemstack != null) {
                float f = this.random.nextFloat() * 0.8F + 0.1F;
                float f1 = this.random.nextFloat() * 0.8F + 0.1F;
                float f2 = this.random.nextFloat() * 0.8F + 0.1F;

                while (itemstack.count > 0) {
                  int k = this.random.nextInt(21) + 10;

                  if (k > itemstack.count) {
                    k = itemstack.count;
                  }

                  itemstack.count -= k;
                  EntityItem entityitem =
                      new EntityItem(
                          this.world,
                          this.locX + (double) f,
                          this.locY + (double) f1,
                          this.locZ + (double) f2,
                          new ItemStack(itemstack.id, k, itemstack.getData()));
                  float f3 = 0.05F;

                  entityitem.motX = (double) ((float) this.random.nextGaussian() * f3);
                  entityitem.motY = (double) ((float) this.random.nextGaussian() * f3 + 0.2F);
                  entityitem.motZ = (double) ((float) this.random.nextGaussian() * f3);
                  this.world.addEntity(entityitem);
                }
              }
            }

            this.a(Block.CHEST.id, 1, 0.0F);
          } else if (this.type == 2) {
            this.a(Block.FURNACE.id, 1, 0.0F);
          }
        }

        return true;
      }
    } else {
      return true;
    }
  }