Example usage for io.netty.buffer ByteBufInputStream readBoolean

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

Introduction

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

Prototype

@Override
    public boolean readBoolean() throws IOException 

Source Link

Usage

From source file:com.kanbekotori.keycraft.network.RewriteNetwork.java

License:Open Source License

/**  */
@SubscribeEvent/*  w w  w .java 2  s.  co m*/
public void onClientPacket(ClientCustomPacketEvent event) {
    EntityPlayer player = MainHelper.getPlayerCl();

    ByteBufInputStream stream = new ByteBufInputStream(event.packet.payload());
    try {
        switch (stream.readInt()) {
        case SYNC_AURORA_POINT_CODE:
            RewriteHelper.setAuroraPoint(player, stream.readInt());
            break;

        case SYNC_SKILL_CODE:
            for (int i = 0; i < RewriteHelper.SKILLS.length; i++) {
                RewriteHelper.learnSkill(player, RewriteHelper.SKILLS[i].id, stream.readBoolean());
            }
            break;
        }

        stream.close();
    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:de.sanandrew.mods.enderstuffp.network.packet.PacketBiomeChangerActions.java

License:Creative Commons License

@Override
public void process(ByteBufInputStream stream, ByteBuf rawData, INetHandler handler) throws IOException {
    EnumAction action = EnumAction.VALUES[stream.readByte()];
    World world = EnderStuffPlus.proxy.getWorld(handler);
    TileEntityBiomeChanger biomeChanger = (TileEntityBiomeChanger) world.getTileEntity(stream.readInt(),
            stream.readInt(), stream.readInt());

    if (biomeChanger == null) {
        return;/*  w ww.  j  a  v  a  2  s  . c o m*/
    }

    switch (action) {
    case ACTIVATE:
        biomeChanger.activate();
        break;
    case DEACTIVATE:
        biomeChanger.deactivate();
        break;
    case CHANGE_BIOME:
        biomeChanger.setCurrRange(stream.readByte());
        biomeChanger.changeBiome();
        biomeChanger.setCurrRange(biomeChanger.getCurrRange() + 1);
        break;
    case REPLACE_BLOCKS:
        biomeChanger.replaceBlocks(stream.readBoolean());
        break;
    case CHNG_MAX_RANGE:
        biomeChanger.setMaxRange(stream.readShort());
        break;
    case CHNG_PERIM_FORM:
        biomeChanger.perimForm = EnumPerimForm.VALUES[stream.readByte()];
        break;
    }
}

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. ja v a  2  s .com
            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 {// ww  w . j a  va 2 s .  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: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();
}