Example usage for io.netty.buffer ByteBuf readInt

List of usage examples for io.netty.buffer ByteBuf readInt

Introduction

In this page you can find the example usage for io.netty.buffer ByteBuf readInt.

Prototype

public abstract int readInt();

Source Link

Document

Gets a 32-bit integer at the current readerIndex and increases the readerIndex by 4 in this buffer.

Usage

From source file:de.sanandrew.mods.turretmod.network.PacketSyncPlayerList.java

License:Creative Commons License

@Override
public void fromBytes(ByteBuf buf) {
    int size = buf.readInt();
    this.players = new HashMap<>(size);

    for (int i = 0; i < size; i++) {
        this.players.put(UUID.fromString(ByteBufUtils.readUTF8String(buf)), ByteBufUtils.readUTF8String(buf));
    }/*from  w w  w. ja  va 2s.  com*/
}

From source file:de.sanandrew.mods.turretmod.network.PacketSyncTcuGuis.java

License:Creative Commons License

@Override
public void fromBytes(ByteBuf buf) {
    int size = buf.readInt();
    this.guis = new HashMap<>(size);

    for (int i = 0; i < size; i++) {
        this.guis.put(i, new ResourceLocation(ByteBufUtils.readUTF8String(buf)));
    }//w  w w  .j a  v a 2  s. co m
}

From source file:de.sanandrew.mods.turretmod.network.PacketSyncTileEntity.java

License:Creative Commons License

@Override
public void fromBytes(ByteBuf buf) {
    this.pos = new BlockPos(buf.readInt(), buf.readInt(), buf.readInt());
    int arrSz = buf.readInt();
    this.tileBytes = new byte[arrSz];
    buf.readBytes(this.tileBytes, 0, arrSz);
}

From source file:de.sanandrew.mods.turretmod.network.PacketSyncUpgradeInst.java

License:Creative Commons License

@Override
public void fromBytes(ByteBuf buf) {
    this.turretId = buf.readInt();
    this.upgradeId = new UUID(buf.readLong(), buf.readLong());
    int lng = buf.readInt();
    this.instData = new byte[lng];
    if (lng > 0) {
        buf.readBytes(this.instData);
    }/*ww  w.  j a  v a  2 s.co  m*/
}

From source file:de.sanandrew.mods.turretmod.network.PacketTurretNaming.java

License:Creative Commons License

@Override
public void fromBytes(ByteBuf buf) {
    this.turretId = buf.readInt();
    this.name = ByteBufUtils.readUTF8String(buf);
}

From source file:de.sanandrew.mods.turretmod.network.PacketUpdateTargets.java

License:Creative Commons License

@Override
@SuppressWarnings("unchecked")
public void fromBytes(ByteBuf buf) {
    this.turretID = buf.readInt();
    this.entityTargets = new ArrayList<>();
    for (int i = 0, max = buf.readInt(); i < max; i++) {
        try {/*from w w w  .j av  a2  s  .  co m*/
            this.entityTargets.add((Class<? extends Entity>) Class.forName(ByteBufUtils.readUTF8String(buf)));
        } catch (ClassNotFoundException ignored) {
        }
    }
    this.playerTargets = new UUID[buf.readInt()];
    for (int i = 0; i < this.playerTargets.length; i++) {
        try {
            this.playerTargets[i] = UUID.fromString(ByteBufUtils.readUTF8String(buf));
        } catch (IllegalArgumentException ex) {
            this.playerTargets[i] = null;
        }
    }
    this.isBlacklistEntity = buf.readBoolean();
    this.isBlacklistPlayer = buf.readBoolean();
}

From source file:de.sanandrew.mods.turretmod.network.PacketUpdateTurretState.java

License:Creative Commons License

@Override
public void fromBytes(ByteBuf buf) {
    this.turretId = buf.readInt();
    this.entityToAttackId = buf.readInt();
    this.currAmmoCap = buf.readInt();
    this.isShooting = buf.readBoolean();
    this.ammoStack = ByteBufUtils.readItemStack(buf);
    int lng = buf.readInt();
    this.delegateData = new byte[lng];
    if (lng > 0) {
        buf.readBytes(this.delegateData);
    }//from   w  ww .j  ava 2 s  . co  m
}

From source file:de.sanandrew.mods.turretmod.network.PacketUpdateUgradeSlot.java

License:Creative Commons License

@Override
public void fromBytes(ByteBuf buf) {
    this.turretID = buf.readInt();
    this.slot = buf.readByte();
    this.stack = ByteBufUtils.readItemStack(buf);
}

From source file:de.sanandrew.mods.turretmod.tileentity.assembly.TileEntityTurretAssembly.java

License:Creative Commons License

@Override
public void fromBytes(ByteBuf buf) {
    this.energyStorage.fluxAmount = buf.readInt();
    this.fluxConsumption = buf.readInt();
    this.isActive = buf.readBoolean();
    this.ticksCrafted = buf.readInt();
    this.maxTicksCrafted = buf.readInt();
    this.automate = buf.readBoolean();
    this.isActiveClient = buf.readBoolean();
    ItemStack crfStack = ByteBufUtils.readItemStack(buf);
    if (ItemStackUtils.isValid(crfStack)) {
        this.currCrafting = new Tuple(UUID.fromString(ByteBufUtils.readUTF8String(buf)), crfStack);
    } else {/*from   w w  w  .j av  a 2 s  . com*/
        this.currCrafting = null;
    }
}