コード例 #1
0
  public void receive(Entity entity, int i) {
    if (!entity.dead && !this.world.isStatic) {
      EntityTracker entitytracker = ((WorldServer) this.world).getTracker();

      if (entity instanceof EntityItem) {
        entitytracker.a(entity, (Packet) (new PacketPlayOutCollect(entity.getId(), this.getId())));
      }

      if (entity instanceof EntityArrow) {
        entitytracker.a(entity, (Packet) (new PacketPlayOutCollect(entity.getId(), this.getId())));
      }

      if (entity instanceof EntityExperienceOrb) {
        entitytracker.a(entity, (Packet) (new PacketPlayOutCollect(entity.getId(), this.getId())));
      }
    }
  }
コード例 #2
0
  private Packet<?> e() {
    if (this.tracker.dead) {
      // CraftBukkit start - Remove useless error spam, just return
      // EntityTrackerEntry.d.warn("Fetching addPacket for removed entity");
      return null;
      // CraftBukkit end
    }

    if (this.tracker instanceof EntityPlayer) {
      return new PacketPlayOutNamedEntitySpawn((EntityHuman) this.tracker);
    } else if (this.tracker instanceof IAnimal) {
      this.headYaw = MathHelper.d(this.tracker.getHeadRotation() * 256.0F / 360.0F);
      return new PacketPlayOutSpawnEntityLiving((EntityLiving) this.tracker);
    } else if (this.tracker instanceof EntityPainting) {
      return new PacketPlayOutSpawnEntityPainting((EntityPainting) this.tracker);
    } else if (this.tracker instanceof EntityItem) {
      return new PacketPlayOutSpawnEntity(this.tracker, 2, 1);
    } else if (this.tracker instanceof EntityMinecartAbstract) {
      EntityMinecartAbstract entityminecartabstract = (EntityMinecartAbstract) this.tracker;

      return new PacketPlayOutSpawnEntity(this.tracker, 10, entityminecartabstract.v().a());
    } else if (this.tracker instanceof EntityBoat) {
      return new PacketPlayOutSpawnEntity(this.tracker, 1);
    } else if (this.tracker instanceof EntityExperienceOrb) {
      return new PacketPlayOutSpawnEntityExperienceOrb((EntityExperienceOrb) this.tracker);
    } else if (this.tracker instanceof EntityFishingHook) {
      EntityHuman entityhuman = ((EntityFishingHook) this.tracker).l();

      return new PacketPlayOutSpawnEntity(
          this.tracker, 90, entityhuman == null ? this.tracker.getId() : entityhuman.getId());
    } else {
      Entity entity;

      if (this.tracker instanceof EntitySpectralArrow) {
        entity = ((EntitySpectralArrow) this.tracker).shooter;
        return new PacketPlayOutSpawnEntity(
            this.tracker, 91, 1 + (entity == null ? this.tracker.getId() : entity.getId()));
      } else if (this.tracker instanceof EntityTippedArrow) {
        entity = ((EntityArrow) this.tracker).shooter;
        return new PacketPlayOutSpawnEntity(
            this.tracker, 60, 1 + (entity == null ? this.tracker.getId() : entity.getId()));
      } else if (this.tracker instanceof EntitySnowball) {
        return new PacketPlayOutSpawnEntity(this.tracker, 61);
      } else if (this.tracker instanceof EntityLlamaSpit) {
        return new PacketPlayOutSpawnEntity(this.tracker, 68);
      } else if (this.tracker instanceof EntityPotion) {
        return new PacketPlayOutSpawnEntity(this.tracker, 73);
      } else if (this.tracker instanceof EntityThrownExpBottle) {
        return new PacketPlayOutSpawnEntity(this.tracker, 75);
      } else if (this.tracker instanceof EntityEnderPearl) {
        return new PacketPlayOutSpawnEntity(this.tracker, 65);
      } else if (this.tracker instanceof EntityEnderSignal) {
        return new PacketPlayOutSpawnEntity(this.tracker, 72);
      } else if (this.tracker instanceof EntityFireworks) {
        return new PacketPlayOutSpawnEntity(this.tracker, 76);
      } else if (this.tracker instanceof EntityFireball) {
        EntityFireball entityfireball = (EntityFireball) this.tracker;
        PacketPlayOutSpawnEntity packetplayoutspawnentity = null;
        byte b0 = 63;

        if (this.tracker instanceof EntitySmallFireball) {
          b0 = 64;
        } else if (this.tracker instanceof EntityDragonFireball) {
          b0 = 93;
        } else if (this.tracker instanceof EntityWitherSkull) {
          b0 = 66;
        }

        if (entityfireball.shooter != null) {
          packetplayoutspawnentity =
              new PacketPlayOutSpawnEntity(
                  this.tracker, b0, ((EntityFireball) this.tracker).shooter.getId());
        } else {
          packetplayoutspawnentity = new PacketPlayOutSpawnEntity(this.tracker, b0, 0);
        }

        packetplayoutspawnentity.a((int) (entityfireball.dirX * 8000.0D));
        packetplayoutspawnentity.b((int) (entityfireball.dirY * 8000.0D));
        packetplayoutspawnentity.c((int) (entityfireball.dirZ * 8000.0D));
        return packetplayoutspawnentity;
      } else if (this.tracker instanceof EntityShulkerBullet) {
        PacketPlayOutSpawnEntity packetplayoutspawnentity1 =
            new PacketPlayOutSpawnEntity(this.tracker, 67, 0);

        packetplayoutspawnentity1.a((int) (this.tracker.motX * 8000.0D));
        packetplayoutspawnentity1.b((int) (this.tracker.motY * 8000.0D));
        packetplayoutspawnentity1.c((int) (this.tracker.motZ * 8000.0D));
        return packetplayoutspawnentity1;
      } else if (this.tracker instanceof EntityEgg) {
        return new PacketPlayOutSpawnEntity(this.tracker, 62);
      } else if (this.tracker instanceof EntityEvokerFangs) {
        return new PacketPlayOutSpawnEntity(this.tracker, 79);
      } else if (this.tracker instanceof EntityTNTPrimed) {
        return new PacketPlayOutSpawnEntity(this.tracker, 50);
      } else if (this.tracker instanceof EntityEnderCrystal) {
        return new PacketPlayOutSpawnEntity(this.tracker, 51);
      } else if (this.tracker instanceof EntityFallingBlock) {
        EntityFallingBlock entityfallingblock = (EntityFallingBlock) this.tracker;

        return new PacketPlayOutSpawnEntity(
            this.tracker, 70, Block.getCombinedId(entityfallingblock.getBlock()));
      } else if (this.tracker instanceof EntityArmorStand) {
        return new PacketPlayOutSpawnEntity(this.tracker, 78);
      } else if (this.tracker instanceof EntityItemFrame) {
        EntityItemFrame entityitemframe = (EntityItemFrame) this.tracker;

        return new PacketPlayOutSpawnEntity(
            this.tracker,
            71,
            entityitemframe.direction.get2DRotationValue(),
            entityitemframe.getBlockPosition());
      } else if (this.tracker instanceof EntityLeash) {
        EntityLeash entityleash = (EntityLeash) this.tracker;

        return new PacketPlayOutSpawnEntity(this.tracker, 77, 0, entityleash.getBlockPosition());
      } else if (this.tracker instanceof EntityAreaEffectCloud) {
        return new PacketPlayOutSpawnEntity(this.tracker, 3);
      } else {
        throw new IllegalArgumentException(
            "Don\'t know how to add " + this.tracker.getClass() + "!");
      }
    }
  }