Example usage for io.netty.buffer ByteBufInputStream readInt

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

Introduction

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

Prototype

@Override
    public int readInt() throws IOException 

Source Link

Usage

From source file:de.sanandrew.mods.turretmod.network.packet.PacketEjectUpgrade.java

License:Creative Commons License

@Override
public void process(ByteBufInputStream stream, ByteBuf rawData, INetHandler iNetHandler) throws IOException {
    if (iNetHandler instanceof NetHandlerPlayServer) {
        EntityPlayer player = ((NetHandlerPlayServer) iNetHandler).playerEntity;
        EntityTurretBase turret = (EntityTurretBase) player.worldObj.getEntityByID(stream.readInt());
        String upgradeName = stream.readUTF();
        TurretUpgrade upgrade = TurretUpgradeRegistry.getUpgrade(upgradeName);
        if (upgrade != null) {
            List<TurretUpgrade> ejectingUpgrades = getRcurDepUpgrades(upgrade,
                    turret.getUpgradeHandler().getUpgradeList());
            for (TurretUpgrade ejectUpg : ejectingUpgrades) {
                ItemStack stack = TmrItems.turretUpgrade.getStackWithUpgrade(ejectUpg, 1);
                turret.getUpgradeHandler().removeUpgrade(turret, ejectUpg);
                if ((stack = InventoryUtils.addStackToInventory(stack, player.inventory)) != null) {
                    turret.entityDropItem(stack, 0.0F);
                }/*from   www.j av a  2 s.  c  o  m*/
                player.inventoryContainer.detectAndSendChanges();
            }
        } else {
            TurretMod.MOD_LOG.printf(Level.WARN, "Cannot eject upgrade %s! This is an invalid upgrade name!",
                    upgradeName);
        }
    }
}

From source file:de.sanandrew.mods.turretmod.network.packet.PacketRemoteOpenGui.java

License:Creative Commons License

@Override
public void process(ByteBufInputStream stream, ByteBuf rawData, INetHandler handler) throws IOException {
    TurretMod.proxy.openGui(null, EnumGui.VALUES[stream.readByte()], stream.readInt(), stream.readInt(),
            stream.readInt());/*  ww w  .j  a  v  a  2 s. c  om*/
}

From source file:de.sanandrew.mods.turretmod.network.packet.PacketSendMultiTargetFlag.java

License:Creative Commons License

@Override
public void process(ByteBufInputStream stream, ByteBuf rawData, INetHandler iNetHandler) throws IOException {
    if (iNetHandler instanceof NetHandlerPlayServer) {
        EntityTurretBase turret = (EntityTurretBase) ((NetHandlerPlayServer) iNetHandler).playerEntity.worldObj
                .getEntityByID(stream.readInt());
        try {/*from w w  w .  j a  v  a  2  s .  co  m*/
            for (int i = 0, count = stream.readInt(); i < count; i++) {
                @SuppressWarnings("unchecked")
                Class<? extends EntityLiving> entityCls = (Class<? extends EntityLiving>) EntityList.stringToClassMapping
                        .get(stream.readUTF());
                turret.getTargetHandler().toggleTarget(entityCls, stream.readBoolean());
            }
        } catch (ClassCastException ex) {
            TurretMod.MOD_LOG.log(Level.WARN, "Cannot apply multi-target list! An entry is invalid!");
            throw new IOException(ex);
        }
    }
}

From source file:de.sanandrew.mods.turretmod.network.packet.PacketSendTargetFlag.java

License:Creative Commons License

@Override
public void process(ByteBufInputStream stream, ByteBuf rawData, INetHandler iNetHandler) throws IOException {
    if (iNetHandler instanceof NetHandlerPlayServer) {
        EntityTurretBase turret = (EntityTurretBase) ((NetHandlerPlayServer) iNetHandler).playerEntity.worldObj
                .getEntityByID(stream.readInt());
        String entityName = stream.readUTF();
        try {//from  w  ww . j  ava2s.  c  o  m
            @SuppressWarnings("unchecked")
            Class<? extends EntityLiving> entityCls = (Class<? extends EntityLiving>) EntityList.stringToClassMapping
                    .get(entityName);
            turret.getTargetHandler().toggleTarget(entityCls, stream.readBoolean());
        } catch (ClassCastException ex) {
            TurretMod.MOD_LOG.printf(Level.WARN, "Cannot apply target %s! This is an invalid entity name!",
                    entityName);
            throw new IOException(ex);
        }
    }
}

From source file:de.sanandrew.mods.turretmod.network.packet.PacketTargetListRequest.java

License:Creative Commons License

@Override
public void process(ByteBufInputStream inStream, ByteBuf rawData, INetHandler iNetHandler) throws IOException {
    if (iNetHandler instanceof NetHandlerPlayServer) {
        int entityId = inStream.readInt();
        Entity e = ((NetHandlerPlayServer) iNetHandler).playerEntity.worldObj.getEntityByID(entityId);
        if (e instanceof EntityTurretBase) {
            PacketTargetList.sendPacket((EntityTurretBase) e);
        }//from w ww . ja va  2 s  .  co m
    }
}

From source file:de.sanandrew.mods.turretmod.network.packet.PacketUpgradeListRequest.java

License:Creative Commons License

@Override
public void process(ByteBufInputStream inStream, ByteBuf rawData, INetHandler iNetHandler) throws IOException {
    if (iNetHandler instanceof NetHandlerPlayServer) {
        int entityId = inStream.readInt();
        Entity e = ((NetHandlerPlayServer) iNetHandler).playerEntity.worldObj.getEntityByID(entityId);
        if (e instanceof EntityTurretBase) {
            PacketUpgradeList.sendPacket((EntityTurretBase) e);
        }/* w  w w . ja v  a  2 s  .co  m*/
    }
}

From source file:net.mcsproject.daemon.network.packets.PacketAuthResponse.java

License:Open Source License

@Override
public void read(ByteBufInputStream byteBuf) throws IOException {
    this.ok = byteBuf.readBoolean();
    this.minPort = byteBuf.readInt();
    this.maxPort = byteBuf.readInt();

    this.resources = byteBuf.readUTF();
}

From source file:net.mcsproject.daemon.network.packets.PacketServerStarted.java

License:Open Source License

@Override
public void read(ByteBufInputStream byteBuf) throws IOException {
    this.serverType = byteBuf.readUTF();
    this.port = byteBuf.readInt();
}

From source file:net.mcsproject.daemon.network.packets.PacketServerStatus.java

License:Open Source License

@Override
public void read(ByteBufInputStream byteBuf) throws IOException {
    this.cpuUsage = byteBuf.readInt();
    this.ramUsage = byteBuf.readInt();
    this.ramMax = byteBuf.readInt();
}