@Override
  public void fromBytes(ByteBuf buf) {

    x = buf.readDouble();
    y = buf.readDouble();
    z = buf.readDouble();
  }
 @Override
 public void fromBytes(ByteBuf buf) {
   this.posX = buf.readDouble();
   this.posY = buf.readDouble();
   this.posZ = buf.readDouble();
   this.strength = buf.readFloat();
   this.showParticles = buf.readBoolean();
 }
 @Override
 public void decodeInto(ChannelHandlerContext ctx, ByteBuf buffer) {
   this.dim = buffer.readInt();
   this.x = buffer.readInt();
   this.y = buffer.readInt();
   this.z = buffer.readInt();
   this.rotation = buffer.readDouble();
   this.scale = buffer.readDouble();
 }
예제 #4
0
  public PositionRotationMessage decode(ByteBuf buffer) throws IOException {
    double x = buffer.readDouble();
    double y = buffer.readDouble();
    double z = buffer.readDouble();
    float rotation = buffer.readFloat();
    float pitch = buffer.readFloat();
    boolean onGround = buffer.readBoolean();

    return new PositionRotationMessage(x, y, z, rotation, pitch, onGround);
  }
예제 #5
0
  public PlayerPositionLookMessage decode(ByteBuf buffer) throws IOException {
    double x = buffer.readDouble();
    double y = buffer.readDouble();
    double headY = buffer.readDouble();
    double z = buffer.readDouble();
    float yaw = buffer.readFloat();
    float pitch = buffer.readFloat();
    boolean onGround = buffer.readBoolean();

    return new PlayerPositionLookMessage(onGround, x, y, headY, z, yaw, pitch);
  }
  @Override
  public void handlePacketData(ByteBuf dataStream) {
    if (!worldObj.isRemote) {
      int type = dataStream.readInt();

      switch (type) {
        case 0:
          if (getReactor() != null) getReactor().setInjectionRate(dataStream.readInt());
          break;
      }

      return;
    }

    super.handlePacketData(dataStream);

    if (worldObj.isRemote) {
      boolean formed = dataStream.readBoolean();

      if (formed) {
        if (getReactor() == null || !((FusionReactor) getReactor()).formed) {
          Mekanism.proxy.doGenericSparkle(
              this,
              new INodeChecker() {
                @Override
                public boolean isNode(TileEntity tile) {
                  return tile instanceof TileEntityReactorBlock;
                }
              });
        }

        if (getReactor() == null) {
          setReactor(new FusionReactor(this));
          MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord);
        }

        ((FusionReactor) getReactor()).formed = true;
        getReactor().setPlasmaTemp(dataStream.readDouble());
        getReactor().setCaseTemp(dataStream.readDouble());
        getReactor().setInjectionRate(dataStream.readInt());
        getReactor().setBurning(dataStream.readBoolean());
        fuelTank.setGas(new GasStack(GasRegistry.getGas("fusionFuelDT"), dataStream.readInt()));
        deuteriumTank.setGas(new GasStack(GasRegistry.getGas("deuterium"), dataStream.readInt()));
        tritiumTank.setGas(new GasStack(GasRegistry.getGas("tritium"), dataStream.readInt()));
        waterTank.setCapacity(dataStream.readInt());
        waterTank.setFluid(new FluidStack(FluidRegistry.getFluid("water"), dataStream.readInt()));
        steamTank.setCapacity(dataStream.readInt());
        steamTank.setFluid(new FluidStack(FluidRegistry.getFluid("steam"), dataStream.readInt()));
      } else if (getReactor() != null) {
        setReactor(null);
        MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord);
      }
    }
  }
예제 #7
0
 @Override
 public ServerPacket onMessage(ClientPacket message, MessageContext ctx) {
   ByteBuf buffer = message.buffer;
   byte mess = buffer.readByte();
   if (mess == 0) {
     double y = buffer.readDouble();
     double dy = buffer.readDouble();
     EntityPlayer player = ThutCore.proxy.getPlayer();
     y += player.getYOffset();
     player.motionY = Math.max(dy, player.motionY);
     ThutCore.proxy.getPlayer().setPosition(player.posX, y, player.posZ);
   }
   return null;
 }
 @Override
 public void decodeFrom(ChannelHandlerContext ctx, ByteBuf buffer) throws IOException {
   target = readDimensionPosFromBuffer(buffer);
   this.type = buffer.readInt();
   this.duration = buffer.readDouble();
   this.args = decodePrimitiveArrayFrom(buffer);
 }
예제 #9
0
  @Override
  public void fromBytes(ByteBuf buf) {
    posX = buf.readInt();
    posY = buf.readInt();
    posZ = buf.readInt();
    int size = buf.readInt();

    data = new ArrayList(size);
    for (int i = 0; i < size; i++) {
      byte tag = buf.readByte();
      if (tag == 0x00) {
        data.add(buf.readChar());
      } else if (tag == 0x01) {
        data.add(readString(buf));
      } else if (tag == 0x02) {
        data.add(buf.readFloat());
      } else if (tag == 0x03) {
        data.add(buf.readDouble());
      } else if (tag == 0x04) {
        data.add(buf.readByte());
      } else if (tag == 0x05) {
        data.add(buf.readLong());
      } else {
        data.add(buf.readInt());
      }
    }
  }
 @Override
 public void fromBytes(ByteBuf buf) {
   this.vehicleID = buf.readInt();
   this.posX = buf.readDouble();
   this.posY = buf.readDouble();
   this.posZ = buf.readDouble();
   this.motX = buf.readDouble();
   this.motY = buf.readDouble();
   this.motZ = buf.readDouble();
   this.yaw = buf.readFloat();
   this.pitch = buf.readFloat();
   this.roll = buf.readFloat();
   this.throttle = buf.readDouble();
   this.steeringAngle = buf.readFloat();
   this.ticksSinceEntered = buf.readInt();
   this.ticksSinceLeft = buf.readInt();
 }
  @Override
  public void handlePacketData(ByteBuf dataStream) {
    super.handlePacketData(dataStream);

    if (worldObj.isRemote) {
      producingEnergy = dataStream.readDouble();

      lastTransferLoss = dataStream.readDouble();
      lastEnvironmentLoss = dataStream.readDouble();

      int amount = dataStream.readInt();

      if (amount != 0) {
        lavaTank.setFluid(new FluidStack(FluidRegistry.LAVA, amount));
      } else {
        lavaTank.setFluid(null);
      }
    }
  }
 @Override
 public void readConfig(ByteBuf dataStream) throws IOException {
   generators.advancedSolarGeneration = dataStream.readDouble();
   generators.bioGeneration = dataStream.readDouble();
   generators.heatGeneration = dataStream.readDouble();
   generators.heatGenerationLava = dataStream.readDouble();
   generators.heatGenerationNether = dataStream.readDouble();
   generators.solarGeneration = dataStream.readDouble();
   generators.windGenerationMin = dataStream.readDouble();
   generators.windGenerationMax = dataStream.readDouble();
   generators.windGenerationMinY = dataStream.readInt();
   generators.windGenerationMaxY = dataStream.readInt();
 }
 public double getDouble() {
   return data.readDouble();
 }
예제 #14
0
 /**
  * Creates a new vector from the packet information in the byte buffer.
  *
  * @param buf Buffer to read from
  */
 public static Vector fromBytes(ByteBuf buf) {
   return new Vector(buf.readDouble(), buf.readDouble(), buf.readDouble());
 }
예제 #15
0
 @Override
 public double readDouble() {
   return buf.readDouble();
 }
예제 #16
0
 @Override
 public void readSpawnData(ByteBuf data) {
   setPos(data.readDouble(), data.readDouble(), data.readDouble());
 }
예제 #17
0
  @Override
  public void decodePacketdata(ByteBuf buffer) {
    super.decodePacketdata(buffer);
    this.fuelTank.setFluid(new FluidStack(GCFluids.fluidFuel, buffer.readInt()));
    this.landing = buffer.readBoolean();
    this.destinationFrequency = buffer.readInt();

    if (buffer.readBoolean()) {
      this.targetVec = new BlockPos(buffer.readInt(), buffer.readInt(), buffer.readInt());
    }

    this.motionX = buffer.readDouble() / 8000.0D;
    this.motionY = buffer.readDouble() / 8000.0D;
    this.motionZ = buffer.readDouble() / 8000.0D;
    this.lastMotionY = buffer.readDouble() / 8000.0D;
    this.lastLastMotionY = buffer.readDouble() / 8000.0D;

    if (this.cargoItems == null) {
      this.cargoItems = new ItemStack[this.getSizeInventory()];
    }

    this.setWaitForPlayer(buffer.readBoolean());

    this.statusMessage = ByteBufUtils.readUTF8String(buffer);
    this.statusMessage = this.statusMessage.equals("") ? null : this.statusMessage;
    this.statusMessageCooldown = buffer.readInt();
    this.lastStatusMessageCooldown = buffer.readInt();
    this.statusValid = buffer.readBoolean();

    // Update client with correct rider if needed
    if (this.worldObj.isRemote) {
      int shouldBeMountedId = buffer.readInt();
      if (this.riddenByEntity == null) {
        if (shouldBeMountedId > -1) {
          Entity e = FMLClientHandler.instance().getWorldClient().getEntityByID(shouldBeMountedId);
          if (e != null) {
            if (e.dimension != this.dimension) {
              if (e instanceof EntityPlayer) {
                e =
                    WorldUtil.forceRespawnClient(
                        this.dimension,
                        e.worldObj.getDifficulty().getDifficultyId(),
                        e.worldObj.getWorldInfo().getTerrainType().getWorldTypeName(),
                        ((EntityPlayerMP) e).theItemInWorldManager.getGameType().getID());
                e.mountEntity(this);
              }
            } else e.mountEntity(this);
          }
        }
      } else if (this.riddenByEntity.getEntityId() != shouldBeMountedId) {
        if (shouldBeMountedId == -1) {
          this.riddenByEntity.mountEntity(null);
        } else {
          Entity e = FMLClientHandler.instance().getWorldClient().getEntityByID(shouldBeMountedId);
          if (e != null) {
            if (e.dimension != this.dimension) {
              if (e instanceof EntityPlayer) {
                e =
                    WorldUtil.forceRespawnClient(
                        this.dimension,
                        e.worldObj.getDifficulty().getDifficultyId(),
                        e.worldObj.getWorldInfo().getTerrainType().getWorldTypeName(),
                        ((EntityPlayerMP) e).theItemInWorldManager.getGameType().getID());
                e.mountEntity(this);
              }
            } else e.mountEntity(this);
          }
        }
      }
    }
    this.statusColour = ByteBufUtils.readUTF8String(buffer);
    if (this.statusColour.equals("")) this.statusColour = null;
  }