コード例 #1
0
  public void handleVehicleSpawn(Packet23VehicleSpawn var1) {
    double var2 = (double) var1.xPosition / 32.0D;
    double var4 = (double) var1.yPosition / 32.0D;
    double var6 = (double) var1.zPosition / 32.0D;
    Object var8 = null;
    if (var1.type == 10) {
      var8 = new EntityMinecart(this.worldClient, var2, var4, var6, 0);
    }

    if (var1.type == 11) {
      var8 = new EntityMinecart(this.worldClient, var2, var4, var6, 1);
    }

    if (var1.type == 12) {
      var8 = new EntityMinecart(this.worldClient, var2, var4, var6, 2);
    }

    if (var1.type == 90) {
      var8 = new EntityFish(this.worldClient, var2, var4, var6);
    }

    if (var1.type == 60) {
      var8 = new EntityArrow(this.worldClient, var2, var4, var6);
    }

    if (var1.type == 61) {
      var8 = new EntitySnowball(this.worldClient, var2, var4, var6);
    }

    if (var1.type == 63) {
      var8 =
          new EntityFireball(
              this.worldClient,
              var2,
              var4,
              var6,
              (double) var1.field_28047_e / 8000.0D,
              (double) var1.field_28046_f / 8000.0D,
              (double) var1.field_28045_g / 8000.0D);
      var1.field_28044_i = 0;
    }

    if (var1.type == 62) {
      var8 = new EntityEgg(this.worldClient, var2, var4, var6);
    }

    if (var1.type == 1) {
      var8 = new EntityBoat(this.worldClient, var2, var4, var6);
    }

    if (var1.type == 50) {
      var8 = new EntityTNTPrimed(this.worldClient, var2, var4, var6);
    }

    if (var1.type == 70) {
      var8 = new EntityFallingSand(this.worldClient, var2, var4, var6, Block.sand.blockID);
    }

    if (var1.type == 71) {
      var8 = new EntityFallingSand(this.worldClient, var2, var4, var6, Block.gravel.blockID);
    }

    if (var8 != null) {
      ((Entity) var8).serverPosX = var1.xPosition;
      ((Entity) var8).serverPosY = var1.yPosition;
      ((Entity) var8).serverPosZ = var1.zPosition;
      ((Entity) var8).rotationYaw = 0.0F;
      ((Entity) var8).rotationPitch = 0.0F;
      ((Entity) var8).entityId = var1.entityId;
      this.worldClient.func_712_a(var1.entityId, (Entity) var8);
      if (var1.field_28044_i > 0) {
        if (var1.type == 60) {
          Entity var9 = this.getEntityByID(var1.field_28044_i);
          if (var9 instanceof EntityLiving) {
            ((EntityArrow) var8).shootingEntity = (EntityLiving) var9;
          }
        }

        ((Entity) var8)
            .setVelocity(
                (double) var1.field_28047_e / 8000.0D,
                (double) var1.field_28046_f / 8000.0D,
                (double) var1.field_28045_g / 8000.0D);
      }
    }
  }
コード例 #2
0
  private Packet getPacketForThisEntity() {
    if (this.myEntity.isDead) {
      System.out.println("Fetching addPacket for removed entity");
    }

    if (this.myEntity instanceof EntityItem) {
      return new Packet23VehicleSpawn(this.myEntity, 2, 1);
    } else if (this.myEntity instanceof EntityPlayerMP) {
      return new Packet20NamedEntitySpawn((EntityPlayer) this.myEntity);
    } else {
      EntityMinecart var1;

      if (this.myEntity instanceof EntityMinecart) {
        var1 = (EntityMinecart) this.myEntity;

        if (var1.minecartType == 0) {
          return new Packet23VehicleSpawn(this.myEntity, 10);
        }

        if (var1.minecartType == 1) {
          return new Packet23VehicleSpawn(this.myEntity, 11);
        }

        if (var1.minecartType == 2) {
          return new Packet23VehicleSpawn(this.myEntity, 12);
        }
      }

      if (this.myEntity instanceof EntityBoat) {
        return new Packet23VehicleSpawn(this.myEntity, 1);
      } else if (!(this.myEntity instanceof IAnimals) && !(this.myEntity instanceof EntityDragon)) {
        if (this.myEntity instanceof EntityFishHook) {
          EntityPlayer var10 = ((EntityFishHook) this.myEntity).angler;
          return new Packet23VehicleSpawn(
              this.myEntity, 90, var10 != null ? var10.entityId : this.myEntity.entityId);
        } else if (this.myEntity instanceof EntityArrow) {
          Entity var8 = ((EntityArrow) this.myEntity).shootingEntity;
          return new Packet23VehicleSpawn(
              this.myEntity, 60, var8 != null ? var8.entityId : this.myEntity.entityId);
        } else if (this.myEntity instanceof EntitySnowball) {
          return new Packet23VehicleSpawn(this.myEntity, 61);
        } else if (this.myEntity instanceof EntityPotion) {
          return new Packet23VehicleSpawn(
              this.myEntity, 73, ((EntityPotion) this.myEntity).getPotionDamage());
        } else if (this.myEntity instanceof EntityExpBottle) {
          return new Packet23VehicleSpawn(this.myEntity, 75);
        } else if (this.myEntity instanceof EntityEnderPearl) {
          return new Packet23VehicleSpawn(this.myEntity, 65);
        } else if (this.myEntity instanceof EntityEnderEye) {
          return new Packet23VehicleSpawn(this.myEntity, 72);
        } else if (this.myEntity instanceof EntityFireworkRocket) {
          return new Packet23VehicleSpawn(this.myEntity, 76);
        } else {
          Packet23VehicleSpawn var4;

          if (this.myEntity instanceof EntityFireball) {
            EntityFireball var7 = (EntityFireball) this.myEntity;
            var1 = null;
            byte var9 = 63;

            if (this.myEntity instanceof EntitySmallFireball) {
              var9 = 64;
            } else if (this.myEntity instanceof EntityWitherSkull) {
              var9 = 66;
            }

            if (var7.shootingEntity != null) {
              var4 =
                  new Packet23VehicleSpawn(
                      this.myEntity,
                      var9,
                      ((EntityFireball) this.myEntity).shootingEntity.entityId);
            } else {
              var4 = new Packet23VehicleSpawn(this.myEntity, var9, 0);
            }

            var4.speedX = (int) (var7.accelerationX * 8000.0D);
            var4.speedY = (int) (var7.accelerationY * 8000.0D);
            var4.speedZ = (int) (var7.accelerationZ * 8000.0D);
            return var4;
          } else if (this.myEntity instanceof EntityEgg) {
            return new Packet23VehicleSpawn(this.myEntity, 62);
          } else if (this.myEntity instanceof EntityTNTPrimed) {
            return new Packet23VehicleSpawn(this.myEntity, 50);
          } else if (this.myEntity instanceof EntityEnderCrystal) {
            return new Packet23VehicleSpawn(this.myEntity, 51);
          } else if (this.myEntity instanceof EntityFallingSand) {
            EntityFallingSand var6 = (EntityFallingSand) this.myEntity;
            return new Packet23VehicleSpawn(this.myEntity, 70, var6.blockID | var6.metadata << 16);
          } else if (this.myEntity instanceof EntityPainting) {
            return new Packet25EntityPainting((EntityPainting) this.myEntity);
          } else if (this.myEntity instanceof EntityItemFrame) {
            EntityItemFrame var5 = (EntityItemFrame) this.myEntity;
            var4 = new Packet23VehicleSpawn(this.myEntity, 71, var5.hangingDirection);
            var4.xPosition = MathHelper.floor_float((float) (var5.xPosition * 32));
            var4.yPosition = MathHelper.floor_float((float) (var5.yPosition * 32));
            var4.zPosition = MathHelper.floor_float((float) (var5.zPosition * 32));
            return var4;
          } else if (this.myEntity instanceof EntityXPOrb) {
            return new Packet26EntityExpOrb((EntityXPOrb) this.myEntity);
          } else {
            Iterator var2 = ModLoader.getTrackers().values().iterator();
            EntityTrackerNonliving var3;

            do {
              if (!var2.hasNext()) {
                throw new IllegalArgumentException(
                    "Don\'t know how to add " + this.myEntity.getClass() + "!");
              }

              var3 = (EntityTrackerNonliving) var2.next();
            } while (!var3.entityClass.isAssignableFrom(this.myEntity.getClass()));

            return var3.mod.getSpawnPacket(this.myEntity, var3.id);
          }
        }
      } else {
        this.lastHeadMotion =
            MathHelper.floor_float(this.myEntity.setRotationYawHead() * 256.0F / 360.0F);
        return new Packet24MobSpawn((EntityLiving) this.myEntity);
      }
    }
  }