Пример #1
1
  public void onUpdate() {
    if (this.rumble > 0) {
      this.rumble--;
    }

    if (this.rumble < 0) {
      this.rumble++;
    }

    if (this.timeSinceEntityEntry > 0) {
      this.timeSinceEntityEntry--;
    }

    if (this.reversed) {
      this.dataWatcher.updateObject(21, Integer.valueOf(1));
    }

    if (this.reversed) {
      if (this.worldObj.getBlockMaterial((int) this.posX, (int) this.posY - 5, (int) this.posZ)
              != Material.air
          || this.motionY == 0) {
        if (this.riddenByEntity != null) {
          this.riddenByEntity.mountEntity(this);
        }

        GCUtil.createNewExplosion(worldObj, this, this.posX, this.posY, this.posZ, 6, false);

        if (this.riddenByEntity != null
            && this.riddenByEntity instanceof EntityPlayer
            && !((EntityPlayer) this.riddenByEntity).capabilities.isCreativeMode) {
          EntityItem var14 =
              new EntityItem(
                  this.worldObj,
                  MathHelper.floor_double(this.riddenByEntity.posX + 0.5D),
                  MathHelper.floor_double(this.riddenByEntity.posY + 1D),
                  MathHelper.floor_double(this.riddenByEntity.posZ + 0.5D),
                  new ItemStack(GCItems.spaceship));

          float var15 = 0.05F;
          var14.motionX = (double) ((float) this.rand.nextGaussian() * var15);
          var14.motionY = (double) ((float) this.rand.nextGaussian() * var15 + 0.2F);
          var14.motionZ = (double) ((float) this.rand.nextGaussian() * var15);
          this.worldObj.spawnEntityInWorld(var14);
        } else if (this.riddenByEntity == null) {
          EntityItem var14 =
              new EntityItem(
                  this.worldObj,
                  MathHelper.floor_double(this.posX + 0.5D),
                  MathHelper.floor_double(this.posY + 1D),
                  MathHelper.floor_double(this.posZ + 0.5D),
                  new ItemStack(GCItems.spaceship));

          float var15 = 0.05F;
          var14.motionX = (double) ((float) this.rand.nextGaussian() * var15);
          var14.motionY = (double) ((float) this.rand.nextGaussian() * var15 + 0.2F);
          var14.motionZ = (double) ((float) this.rand.nextGaussian() * var15);
          this.worldObj.spawnEntityInWorld(var14);
        }

        this.setDead();
      }
    }

    if (this.riddenByEntity != null) {
      if (this.failedLaunch && this.timeSinceLaunch >= 100) {
        this.riddenByEntity.posX += (this.rumble) / 20F;
        this.riddenByEntity.posZ += (this.rumble) / 20F;
      } else {
        this.riddenByEntity.posX += (this.rumble) / 30F;
        this.riddenByEntity.posZ += (this.rumble) / 30F;
      }

      if (FMLClientHandler.instance().getClient().gameSettings.keyBindLeft.pressed) {
        this.rotationYaw -= 0.5F;
      }

      if (FMLClientHandler.instance().getClient().gameSettings.keyBindRight.pressed) {
        this.rotationYaw += 0.5F;
      }
    }

    if (this.posY > 450D && !this.reversed) {
      this.teleport();
    }

    if (this.func_70496_j() > 0) {
      this.func_70497_h(this.func_70496_j() - 1);
    }

    if (this.getDamage() > 0) {
      this.setDamage(this.getDamage() - 1);
    }

    if (this.posY < -64.0D || this.posY > 500D && this.dataWatcher.getWatchableObjectInt(21) == 0) {
      this.kill();
    }

    if (this.ignite == 0) {
      this.timeUntilLaunch = 400;
    }

    if (this.launched) {
      this.timeSinceLaunch++;
    } else {
      this.timeSinceLaunch = 0;
    }

    if (this.timeUntilLaunch > 0 && ignite == 1) {
      this.timeUntilLaunch--;
    }

    if (this.timeUntilLaunch == 0 && ignite == 1) {
      this.launched = true;
      this.ignite = 0;
    }

    this.moveEntity(this.motionX, this.motionY, this.motionZ);

    int i;

    if (this.timeUntilLaunch >= 100) {
      i = Math.abs((int) this.timeUntilLaunch / 100);
    } else {
      i = 1;
    }

    if ((this.ignite == 1 || launched)) {
      this.performHurtAnimation();

      this.rumble = (float) (rand.nextInt(3)) - 3;
    }

    if ((this.launched || this.rand.nextInt(i) == 0)
        && this.dataWatcher.getWatchableObjectInt(21) == 0) {
      this.spawnParticles(this.launched);
    }

    if (this.worldObj.isRemote) {
      this.rotationPitch -= Float.valueOf(this.getFailedLaunch()) / 2;

      this.rotationYaw += Float.valueOf(this.getFailedLaunch()) * 2.0F;

      this.setPosition(this.posX, this.posY, this.posZ);
      this.setRotation(this.rotationYaw, this.rotationPitch);
    } else {
      this.prevPosX = this.posX;
      this.prevPosY = this.posY;
      this.prevPosZ = this.posZ;

      if (this.launched && !reversed) {
        this.motionY += 0.005D;
      }

      if (this.failedLaunch) {
        if (this.timeSinceLaunch > 100) {
          this.setFailedLaunch(1);
          this.motionX += 0.005D;
          this.motionZ += 0.005D;
        }

        if (this.timeSinceLaunch > 200) {
          this.worldObj.createExplosion(this, this.posX, this.posY, this.posZ, 20);

          this.spawnParticlesExplosion();

          this.setDead();
        }
      }

      int var1 = MathHelper.floor_double(this.posX);
      int var2 = MathHelper.floor_double(this.posY);
      int var3 = MathHelper.floor_double(this.posZ);

      if (BlockRail.isRailBlockAt(this.worldObj, var1, var2 - 1, var3)) {
        --var2;
      }

      double var4 = 0.4D;
      double var6 = 0.0078125D;
      int var8 = this.worldObj.getBlockId(var1, var2, var3);
    }

    this.setRotation(this.rotationYaw, this.rotationPitch);
  }
Пример #2
0
 protected void updateFailChance(EntityPlayer player) {
   if (this.rand.nextInt(100) < GCUtil.getSpaceshipFailChance(player)) {
     this.failedLaunch = true;
   } else {
     this.failedLaunch = false;
   }
 }
Пример #3
0
  protected void placeTreasureAtCurrentPosition(
      World var1, Random var2, int var3, int var4, int var5, StructureBoundingBox var7) {
    int var8 = this.getXWithOffset(var3, var5);
    int var9 = this.getYWithOffset(var4);
    int var10 = this.getZWithOffset(var3, var5);

    if (var7.isVecInside(var8, var9, var10)
        && var1.getBlockId(var8, var9, var10) != Block.chest.blockID) {
      GCUtil.generateChestContents(var1, var2, var8, var9, var10);
    }
  }