Exemplo n.º 1
0
 public Packet getDescriptionPacket() {
   return GCCorePacketManager.getPacket(
       GalacticraftCore.CHANNELENTITIES,
       this,
       this.buggyType,
       this.buggyFuelTank.getFluid() != null ? this.buggyFuelTank.getFluid().amount : 0);
 }
Exemplo n.º 2
0
  @Override
  public void onUpdate() {
    super.onUpdate();

    if (!this.worldObj.isRemote) {
      PacketDispatcher.sendPacketToAllAround(
          this.posX,
          this.posY,
          this.posZ,
          this.getPacketRange(),
          this.worldObj.provider.dimensionId,
          GCCorePacketManager.getPacket(
              GalacticraftCore.CHANNELENTITIES,
              this,
              this.getNetworkedData(new ArrayList<Object>())));
    }
  }
  @Override
  public void onUpdate() {
    if (this.ticks >= Long.MAX_VALUE) {
      this.ticks = 1;
    }

    this.ticks++;

    super.onUpdate();

    if (this.worldObj.isRemote
        && (this.riddenByEntity == null
            || !(this.riddenByEntity instanceof EntityPlayer)
            || !FMLClientHandler.instance().getClient().thePlayer.equals(this.riddenByEntity))) {
      double x;
      double y;
      double var12;
      double z;
      if (this.boatPosRotationIncrements > 0) {
        x = this.posX + (this.boatX - this.posX) / this.boatPosRotationIncrements;
        y = this.posY + (this.boatY - this.posY) / this.boatPosRotationIncrements;
        z = this.posZ + (this.boatZ - this.posZ) / this.boatPosRotationIncrements;
        var12 = MathHelper.wrapAngleTo180_double(this.boatYaw - this.rotationYaw);
        this.rotationYaw = (float) (this.rotationYaw + var12 / this.boatPosRotationIncrements);
        this.rotationPitch =
            (float)
                (this.rotationPitch
                    + (this.boatPitch - this.rotationPitch) / this.boatPosRotationIncrements);
        --this.boatPosRotationIncrements;
        this.setPosition(x, y, z);
        this.setRotation(this.rotationYaw, this.rotationPitch);
      } else {
        x = this.posX + this.motionX;
        y = this.posY + this.motionY;
        z = this.posZ + this.motionZ;
        if (this.riddenByEntity != null) {
          this.setPosition(x, y, z);
        }

        if (this.onGround) {
          this.motionX *= 0.5D;
          this.motionY *= 0.5D;
          this.motionZ *= 0.5D;
        }

        this.motionX *= 0.9900000095367432D;
        this.motionY *= 0.949999988079071D;
        this.motionZ *= 0.9900000095367432D;
      }
      return;
    }

    if (this.dataWatcher.getWatchableObjectInt(this.timeSinceHit) > 0) {
      this.dataWatcher.updateObject(
          this.timeSinceHit,
          Integer.valueOf(this.dataWatcher.getWatchableObjectInt(this.timeSinceHit) - 1));
    }

    if (this.dataWatcher.getWatchableObjectInt(this.currentDamage) > 0) {
      this.dataWatcher.updateObject(
          this.currentDamage,
          Integer.valueOf(this.dataWatcher.getWatchableObjectInt(this.currentDamage) - 1));
    }

    final byte var20 = 5;
    final double var2 = 0.0D;
    int var4;

    for (var4 = 0; var4 < var20; ++var4) {}

    if (var2 < 1.0D) {
      this.motionY -= 0.04D;
    }

    if (this.riddenByEntity == null) {
      this.yOffset = 5;
    }

    if (this.inWater && this.speed > 0.2D) {
      this.worldObj.playSoundEffect(
          (float) this.posX,
          (float) this.posY,
          (float) this.posZ,
          "random.fizz",
          0.5F,
          2.6F + (this.worldObj.rand.nextFloat() - this.worldObj.rand.nextFloat()) * 0.8F);
    }

    this.speed *= 0.98D;

    if (this.speed > this.maxSpeed) {
      this.speed = this.maxSpeed;
    }

    if (this.isCollidedHorizontally) {
      this.speed *= 0.9;
      this.motionY = 0.1D;
    }

    if (this.worldObj.isRemote
        && this.buggyFuelTank.getFluid() != null
        && this.buggyFuelTank.getFluid().amount > 0) {
      this.motionX = -(this.speed * Math.cos((this.rotationYaw - 90F) * Math.PI / 180.0D));
      this.motionZ = -(this.speed * Math.sin((this.rotationYaw - 90F) * Math.PI / 180.0D));
    }

    if (this.worldObj.isRemote) {
      this.moveEntity(this.motionX, this.motionY, this.motionZ);
      this.wheelRotationX +=
          (this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ)
              * 250.0F
              * (this.speed < 0 ? 1 : -1);
      this.wheelRotationZ = Math.max(-30.0F, Math.min(30.0F, this.wheelRotationZ * 0.9F));
      this.radarDishRotation.x = Math.sin(this.ticks * 0.05) * 50.0F;
      this.radarDishRotation.z = Math.cos(this.ticks * 0.1) * 50.0F;
    }

    if (!this.worldObj.isRemote && Math.abs(this.motionX * this.motionZ) > 0.000001) {
      double d = this.motionX * this.motionX + this.motionZ * this.motionZ;

      if (d == 0) {
        d += 0.0001F;
      }

      int speedMod = MathHelper.floor_double(2 / d);

      if (speedMod == 0 || this.ticks % speedMod == 0) {
        this.removeFuel(1);
      }
    }

    this.prevPosX = this.posX;
    this.prevPosY = this.posY;
    this.prevPosZ = this.posZ;

    if (this.worldObj.isRemote) {
      PacketDispatcher.sendPacketToServer(GCCorePacketEntityUpdate.buildUpdatePacket(this));
    }

    if (!this.worldObj.isRemote && this.ticks % 5 == 0) {
      PacketDispatcher.sendPacketToAllAround(
          this.posX,
          this.posY,
          this.posZ,
          50,
          this.dimension,
          GCCorePacketEntityUpdate.buildUpdatePacket(this));
    }

    if (!this.worldObj.isRemote && this.ticks % 5 == 0) {
      GCCorePacketManager.sendPacketToClients(
          this.getDescriptionPacket(), this.worldObj, new Vector3(this), 50);
    }
  }