public void sendInventoryToClients() {
   NBTTagCompound nbt = new NBTTagCompound();
   this.writeToNBT(nbt);
   PacketManager.sendPacketToClients(
       PacketManager.getPacket(
           ModularForceFieldSystem.CHANNEL, this, TilePacketType.INVENTORY.ordinal(), nbt));
 }
  public void setMainBlock(Vector3 mainBlock) {
    this.mainBlockPosition = mainBlock;

    if (!this.worldObj.isRemote) {
      PacketManager.sendPacketToClients(this.getDescriptionPacket());
    }
  }
  @Override
  protected void actionPerformed(GuiButton guiButton) {
    super.actionPerformed(guiButton);

    if (guiButton.id == 1) {
      PacketDispatcher.sendPacketToServer(
          PacketManager.getPacket(
              ZhuYao.CHANNEL, this.tileEntity, TPacketType.TOGGLE_MODE.ordinal()));
    }
  }
  @Override
  public void onReceivePacket(int packetID, ByteArrayDataInput dataStream) throws IOException {
    super.onReceivePacket(packetID, dataStream);

    if (this.worldObj.isRemote) {
      if (packetID == TilePacketType.DESCRIPTION.ordinal()
          || packetID == TilePacketType.INVENTORY.ordinal()) {
        this.readFromNBT(PacketManager.readNBTTagCompound(dataStream));
      }
    }
  }
 @Override
 public Packet getDescriptionPacket() {
   if (this.mainBlockPosition != null) {
     return PacketManager.getPacket(
         "BasicComponents",
         this,
         this.mainBlockPosition.x,
         this.mainBlockPosition.y,
         this.mainBlockPosition.z);
   }
   return null;
 }
Ejemplo n.º 6
0
  @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);
    }

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

      if (d != 0
          && !this.worldObj.isRemote
          && d != 0
          && this.ticks % MathHelper.floor_double(2 / d) == 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) {
      PacketManager.sendPacketToClients(
          this.getDescriptionPacket(), this.worldObj, new Vector3(this), 50);
    }
  }