@Override
  public void handlePacketData(ByteBuf dataStream) {
    super.handlePacketData(dataStream);

    authenticated = dataStream.readBoolean();
    locked = dataStream.readBoolean();
    password = PacketHandler.readString(dataStream);
  }
  @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);
      }
    }
  }
 @Override
 public void fromBytes(ByteBuf buf) {
   entityID = buf.readInt();
   componentID = buf.readInt();
   if (buf.readBoolean()) ident = TrackIdentifier.deserialize(buf);
   progress = buf.readFloat();
 }
 @Override
 public void readFromByteBuff(ByteBuf buf) {
   super.readFromByteBuff(buf);
   fill = buf.readBoolean();
   tank.readFromByteBuff(buf);
   inventory.readFromByteBuff(buf);
 }
 @Override
 public void readDataFromNetwork(ByteBuf in, byte id, NBTTagCompound nbt) {
   if (id == 0) nbt.setInteger("laserX", in.readInt());
   else if (id == 1) nbt.setInteger("laserZ", in.readInt());
   else if (id == 2) nbt.setBoolean("isRunning", in.readBoolean());
   else if (id == 3) nbt.setInteger("mode", in.readInt());
 }
Beispiel #6
0
  @Override
  public boolean read(ByteBuf buf, int id, EntityPlayer player, PacketType type) {
    if (worldObj.isRemote) {
      if (id == 1) {
        boolean prev = shouldRenderBlock;
        shouldRenderBlock = buf.readBoolean();
        if (buf.readBoolean()) overrideRenderBounds = new Cube(buf);

        if (prev != shouldRenderBlock) {
          worldObj.markBlockRangeForRenderUpdate(xCoord, yCoord, zCoord, xCoord, yCoord, zCoord);
        }
        return true;
      }
    }
    return false;
  }
 @Override
 public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) {
   if (protocolVersion < ProtocolConstants.MINECRAFT_SNAPSHOT) {
     items = new Item[1];
     Item item = items[0] = new Item();
     item.displayName = item.username = readString(buf);
     action = !buf.readBoolean() ? Action.REMOVE_PLAYER : Action.ADD_PLAYER;
     item.ping = buf.readShort();
   } else {
     action = Action.values()[DefinedPacket.readVarInt(buf)];
     items = new Item[DefinedPacket.readVarInt(buf)];
     for (int i = 0; i < items.length; i++) {
       Item item = items[i] = new Item();
       item.setUuid(DefinedPacket.readUUID(buf));
       switch (action) {
         case ADD_PLAYER:
           item.username = DefinedPacket.readString(buf);
           item.properties = new String[DefinedPacket.readVarInt(buf)][];
           for (int j = 0; j < item.properties.length; j++) {
             String name = DefinedPacket.readString(buf);
             String value = DefinedPacket.readString(buf);
             if (buf.readBoolean()) {
               item.properties[j] = new String[] {name, value, DefinedPacket.readString(buf)};
             } else {
               item.properties[j] = new String[] {name, value};
             }
           }
           item.gamemode = DefinedPacket.readVarInt(buf);
           item.ping = DefinedPacket.readVarInt(buf);
           if (buf.readBoolean()) {
             item.displayName = DefinedPacket.readString(buf);
           }
           break;
         case UPDATE_GAMEMODE:
           item.gamemode = DefinedPacket.readVarInt(buf);
           break;
         case UPDATE_LATENCY:
           item.ping = DefinedPacket.readVarInt(buf);
           break;
         case UPDATE_DISPLAY_NAME:
           if (buf.readBoolean()) {
             item.displayName = DefinedPacket.readString(buf);
           }
       }
     }
   }
 }
 @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 read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) {
   cursor = readString(buf);
   if (protocolVersion >= ProtocolConstants.MINECRAFT_1_8) {
     if (hasPositon = buf.readBoolean()) {
       position = buf.readLong();
     }
   }
 }
 @Override
 public void fromBytes(ByteBuf buf) {
   x = buf.readInt();
   y = buf.readInt();
   z = buf.readInt();
   _freq = buf.readInt();
   _isPublic = buf.readBoolean();
   _state = buf.readByte();
 }
  public IAEItemStack readItem(ByteBuf stream) throws IOException {
    boolean hasItem = stream.readBoolean();

    if (hasItem) {
      return AEItemStack.loadItemStackFromPacket(stream);
    }

    return null;
  }
 @Override
 public void readData(ByteBuf data) {
   super.readData(data);
   displayPower = new short[] {0, 0, 0, 0, 0, 0};
   overload = data.readBoolean();
   for (int i = 0; i < displayPower.length; i++) {
     displayPower[i] = data.readUnsignedByte();
   }
 }
  // automatic.
  public PacketPatternSlot(ByteBuf stream) throws IOException {

    this.shift = stream.readBoolean();

    this.slotItem = this.readItem(stream);

    for (int x = 0; x < 9; x++) {
      this.pattern[x] = this.readItem(stream);
    }
  }
Beispiel #14
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);
  }
  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 readSpawnData(ByteBuf buffer) {
   boolean ex_exists = buffer.readBoolean();
   if (ex_exists) {
     ex = ExplosiveRegistry.get(ByteBufUtils.readUTF8String(buffer));
     ex_data = ByteBufUtils.readTag(buffer);
   } else {
     ex = null;
     ex_data = null;
   }
 }
Beispiel #17
0
  public void readFromStream(ByteBuf stream) {
    initialized = stream.readBoolean();

    xMin = stream.readInt();
    yMin = stream.readInt();
    zMin = stream.readInt();

    xMax = stream.readInt();
    yMax = stream.readInt();
    zMax = stream.readInt();
  }
  /**
   * Called client side when a sync packet has been received.
   *
   * @throws IOException
   */
  @SideOnly(Side.CLIENT)
  @Override
  public boolean readFromStream(final ByteBuf stream) throws IOException {
    // Call super
    super.readFromStream(stream);

    // Read the activity state
    this.isEmitting = stream.readBoolean();

    return true;
  }
  @Override
  public void handlePacketData(ByteBuf dataStream) {
    super.handlePacketData(dataStream);

    clientActive = dataStream.readBoolean();
    controlType = RedstoneControl.values()[dataStream.readInt()];

    if (updateDelay == 0 && clientActive != isActive) {
      updateDelay = general.UPDATE_DELAY;
      isActive = clientActive;
      MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord);
    }
  }
Beispiel #20
0
  @Override
  public void fromBytes(ByteBuf buffer) {
    this.x = buffer.readInt();
    this.y = buffer.readInt();
    this.z = buffer.readInt();

    this.closedSides = new boolean[6];
    for (int i = 0; i < 6; ++i) this.closedSides[i] = buffer.readBoolean();

    this.lasers = new ArrayList<LaserInGame>();
    int count = buffer.readInt();
    for (int i = 0; i < count; ++i) this.lasers.add(new LaserInGame().readFromPacket(buffer));
  }
  @Override
  public void handlePacketData(ByteBuf dataStream) {
    super.handlePacketData(dataStream);

    finishedCalc = dataStream.readBoolean();

    if (dataStream.readInt() == 1) {
      fluidTank.setFluid(new FluidStack(dataStream.readInt(), dataStream.readInt()));
    } else {
      fluidTank.setFluid(null);
    }

    MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord);
  }
  @Override
  public void handlePacketData(ByteBuf dataStream) {
    super.handlePacketData(dataStream);

    isActive = dataStream.readBoolean();
    controlType = RedstoneControl.values()[dataStream.readInt()];
    operatingTicks = dataStream.readInt();

    if (dataStream.readBoolean()) {
      injectTank.setGas(
          new GasStack(GasRegistry.getGas(dataStream.readInt()), dataStream.readInt()));
    } else {
      injectTank.setGas(null);
    }

    if (dataStream.readBoolean()) {
      outputTank.setGas(
          new GasStack(GasRegistry.getGas(dataStream.readInt()), dataStream.readInt()));
    } else {
      outputTank.setGas(null);
    }

    MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord);
  }
  @Override
  public void handlePacketData(ByteBuf dataStream) {
    facing = dataStream.readInt();
    redstone = dataStream.readBoolean();

    if (clientFacing != facing) {
      MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord);
      worldObj.notifyBlocksOfNeighborChange(
          xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord));
      clientFacing = facing;
    }

    for (ITileComponent component : components) {
      component.read(dataStream);
    }
  }
  @Override
  public Object read(ByteBuf data, Object o, SerializationContext context)
      throws IllegalArgumentException, IllegalAccessException, InstantiationException,
          ClassNotFoundException {
    if (!data.readBoolean()) {
      return null;
    } else {
      int size = data.readShort();

      HashMap<Object, Object> map = new HashMap<Object, Object>();

      for (int i = 0; i < size; ++i) {
        Object key = anonymousSerializer.read(data, null, context);
        Object value = anonymousSerializer.read(data, null, context);

        map.put(key, value);
      }

      return map;
    }
  }
  @Override
  public Object read(ByteBuf data, Object o, SerializationContext context)
      throws IllegalArgumentException, IllegalAccessException, InstantiationException,
          ClassNotFoundException {

    if (!data.readBoolean()) {
      return null;
    } else {
      int size = data.readShort();

      LinkedList list = new LinkedList();

      for (int i = 0; i < size; ++i) {
        Object val = anonymousSerializer.read(data, null, context);

        list.add(val);
      }

      return list;
    }
  }
 @Override
 public void fromBytes(ByteBuf buf) {
   this.x = buf.readInt();
   this.y = buf.readInt();
   this.z = buf.readInt();
   this.coinSum = buf.readInt();
   this.itemPrice = buf.readInt();
   this.customName = ByteBufUtils.readUTF8String(buf);
   this.playerName = ByteBufUtils.readUTF8String(buf);
   this.buyButtonActive = buf.readBoolean();
   this.sellButtonActive = buf.readBoolean();
   this.autoModeButtonActive = buf.readBoolean();
   this.coinButtonActive = buf.readBoolean();
   this.isSStackButtonActive = buf.readBoolean();
   this.isLStackButtonActive = buf.readBoolean();
   this.isSBagButtonActive = buf.readBoolean();
   this.isLBagButtonActive = buf.readBoolean();
   this.inUse = buf.readBoolean();
 }
    @Override
    public void fromBytes(ByteBuf buffer) {
      packetType = PortableTeleporterPacketType.values()[buffer.readInt()];

      if (packetType == PortableTeleporterPacketType.DATA_REQUEST) {
        if (buffer.readBoolean()) {
          frequency =
              new Frequency(PacketHandler.readString(buffer), null).setPublic(buffer.readBoolean());
        }
      } else if (packetType == PortableTeleporterPacketType.DATA_RESPONSE) {
        if (buffer.readBoolean()) {
          frequency =
              new Frequency(PacketHandler.readString(buffer), null).setPublic(buffer.readBoolean());
        }

        status = buffer.readByte();

        int amount = buffer.readInt();

        for (int i = 0; i < amount; i++) {
          publicCache.add(new Frequency(buffer));
        }

        amount = buffer.readInt();

        for (int i = 0; i < amount; i++) {
          privateCache.add(new Frequency(buffer));
        }
      } else if (packetType == PortableTeleporterPacketType.SET_FREQ) {
        frequency =
            new Frequency(PacketHandler.readString(buffer), null).setPublic(buffer.readBoolean());
      } else if (packetType == PortableTeleporterPacketType.DEL_FREQ) {
        frequency =
            new Frequency(PacketHandler.readString(buffer), null).setPublic(buffer.readBoolean());
      } else if (packetType == PortableTeleporterPacketType.TELEPORT) {
        frequency =
            new Frequency(PacketHandler.readString(buffer), null).setPublic(buffer.readBoolean());
      }
    }
  @Override
  public void handlePacketData(ByteBuf dataStream) {
    super.handlePacketData(dataStream);

    if (FMLCommonHandler.instance().getEffectiveSide().isClient()) {
      FluidTankTier prevTier = tier;

      tier = FluidTankTier.values()[dataStream.readInt()];
      fluidTank.setCapacity(tier.storage);

      clientActive = dataStream.readBoolean();
      valve = dataStream.readInt();
      editMode = ContainerEditMode.values()[dataStream.readInt()];

      if (valve > 0) {
        valveFluid = FluidRegistry.getFluid(PacketHandler.readString(dataStream));
      } else {
        valveFluid = null;
      }

      if (dataStream.readInt() == 1) {
        fluidTank.setFluid(
            new FluidStack(
                FluidRegistry.getFluid(PacketHandler.readString(dataStream)),
                dataStream.readInt()));
      } else {
        fluidTank.setFluid(null);
      }

      if (prevTier != tier || (updateDelay == 0 && clientActive != isActive)) {
        updateDelay = general.UPDATE_DELAY;
        isActive = clientActive;
        MekanismUtils.updateBlock(worldObj, getPos());
      }
    }
  }
 @Override
 protected void readData(final ByteBuf stream) {
   this.saveState = Packet_C_KnowledgeInscriber.SAVE_STATES[stream.readInt()];
   this.justSaved = stream.readBoolean();
 }
 @TileEvent(TileEventType.NETWORK_READ)
 public boolean readFromStream_TileMolecularAssembler(final ByteBuf data) {
   final boolean oldPower = this.isPowered;
   this.isPowered = data.readBoolean();
   return this.isPowered != oldPower;
 }