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:com.builtbroken.atomic.network.packet.trigger.PacketMouse.java

@Override
public void decodeInto(ChannelHandlerContext ctx, ByteBuf buffer) {
    slot = buffer.readInt();
    forward = buffer.readBoolean();/*  www.j av a  2s  .c  o  m*/
    ctrl = buffer.readBoolean();
}

From source file:com.builtbroken.grappling.network.packets.PacketMouseClick.java

@Override
public void read(ByteBuf buffer) {
    slot = buffer.readInt();
    button = buffer.readInt();//  w  ww.j ava  2s .  c o m
    dwheel = buffer.readInt();
    state = buffer.readBoolean();
}

From source file:com.builtbroken.icbm.content.blast.entity.slime.EntitySlimeRain.java

@Override
public void readSpawnData(ByteBuf additionalData) {
    color = new Color(additionalData.readInt(), additionalData.readInt(), additionalData.readInt());
}

From source file:com.builtbroken.icbm.content.crafting.station.small.auto.TileSMAutoCraft.java

@Override
public boolean read(ByteBuf buf, int id, EntityPlayer player, PacketType type) {
    super.doUpdateGuiUsers();
    if (!super.read(buf, id, player, type)) {
        if (isServer()) {
            if (id == 1) {
                doCrafting();/*from  w  ww. j  a v a  2s. c  om*/
                return true;
            } else if (id == 2) {
                openGui(player, buf.readInt(), ICBM.INSTANCE);
                return true;
            }
            //Gui updated some settings
            else if (id == 3) {
                isAutocrafting = buf.readBoolean();
                requiresWarhead = buf.readBoolean();
                requiresGuidance = buf.readBoolean();
                requiresEngine = buf.readBoolean();
                _doUpdateGuiUsers();
                return true;
            }
        }
        return false;
    }
    return true;
}

From source file:com.builtbroken.icbm.content.crafting.station.warhead.TileWarheadStation.java

@Override
public boolean read(ByteBuf buf, int id, EntityPlayer player, PacketType type) {
    super.doUpdateGuiUsers();
    if (!super.read(buf, id, player, type)) {
        if (isServer()) {
            if (id == 1) {
                doCrafting();//w w w .ja  va  2  s.  c om
                return true;
            } else if (id == 2) {
                openGui(player, buf.readInt(), ICBM.INSTANCE);
                return true;
            }
            //Gui updated some settings
            else if (id == 3) {
                isAutocrafting = buf.readBoolean();
                explosiveStackSizeRequired = Math.min(Math.max(1, buf.readInt()), 64);
                requireExplosive = buf.readBoolean();
                requireTrigger = buf.readBoolean();
                _doUpdateGuiUsers();
                return true;
            }
        }
        return false;
    }
    return true;
}

From source file:com.builtbroken.icbm.content.crafting.station.warhead.TileWarheadStationClient.java

@Override
public boolean read(ByteBuf buf, int id, EntityPlayer player, PacketType type) {
    super.doUpdateGuiUsers();
    if (!super.read(buf, id, player, type)) {
        if (id == 5) {
            isAutocrafting = buf.readBoolean();
            explosiveStackSizeRequired = buf.readInt();
            requireExplosive = buf.readBoolean();
            requireTrigger = buf.readBoolean();
            //Reload GUI
            final GuiScreen screen = Minecraft.getMinecraft().currentScreen;
            if (screen instanceof GuiWarheadStation) {
                screen.initGui();/*from ww w .  j  a  va2 s  . com*/
            }
            return true;
        }
        return false;
    }
    return true;
}

From source file:com.builtbroken.icbm.content.fragments.EntityFragment.java

@Override
public void readSpawnData(ByteBuf additionalData) {
    try {//from w  ww  . j  a  va 2 s  .c o  m
        byte i = additionalData.readByte();
        if (i >= 0 && i < FragmentType.values().length) {
            fragmentType = FragmentType.values()[i];
        }
        int blockID = additionalData.readInt();
        if (i > -1) {
            fragmentMaterial = Block.getBlockById(blockID);
        }
        if (additionalData.readBoolean()) {
            renderShape = new Cube(additionalData);
        }
    } catch (Exception e) {
        ICBM.INSTANCE.logger().error("Failed to read spawn data for " + this);
    }
}

From source file:com.builtbroken.icbm.content.items.ItemLaserDetonator.java

@Override
public void read(ByteBuf buf, EntityPlayer player, PacketType packet) {
    ItemStack stack = player.inventory.getCurrentItem();
    if (stack != null && stack.getItem() == this) {
        if (!player.worldObj.isRemote) {
            Pos pos = new Pos(buf.readInt(), buf.readInt(), buf.readInt());
            int mode = getMode(stack);
            if (mode > 0) {
                float hz = getBroadCastHz(stack);
                if (mode == 1) {
                    RadioRegistry.popMessage(player.worldObj, new FakeRadioSender(player, stack, 2000), hz,
                            "fireMissileAtTarget", getPassKey(stack), getGroupID(stack), getSiloName(stack),
                            pos);/*from ww  w .  ja  va 2  s  . c  om*/
                } else if (mode == 2) {
                    RadioRegistry.popMessage(player.worldObj, new FakeRadioSender(player, stack, 2000), hz,
                            "fireMissileGroupAtTarget", getPassKey(stack), getGroupID(stack), pos);
                    //TODO add selective first missile firing
                }
                //TODO add mode for chain firing
                //TODO add mode for group firing
            } else {
                player.addChatComponentMessage(new ChatComponentText(
                        "Not encoded for launch data! Use Command Silo Interface to encode with launch data..."));
            }
        }
    }
}

From source file:com.builtbroken.icbm.content.items.ItemRadarGun.java

@Override
public void read(ByteBuf buf, EntityPlayer player, PacketType packet) {
    ItemStack stack = player.inventory.getCurrentItem();
    if (stack != null && stack.getItem() == this) {
        setLocation(stack, new Location(player.worldObj, buf.readInt(), buf.readInt(), buf.readInt()));
        player.addChatComponentMessage(new ChatComponentText("GPS data set"));
    }/*from w  ww .  ja v a 2  s.c o m*/
}

From source file:com.builtbroken.icbm.content.launcher.controller.remote.display.TileSiloInterfaceClient.java

protected void readCommandSiloConnector(int controllerIndexValue, ByteBuf buf) {
    int locationSize = buf.readInt();
    Pos[] posData = new Pos[locationSize];
    for (int i = 0; i < locationSize; i++) {
        Pos pos = new Pos(buf.readInt(), buf.readInt(), buf.readInt());
        int dataSize = buf.readInt();
        List<ISiloConnectionData> list = new ArrayList();
        if (dataSize > 0) {
            NBTTagCompound save = ByteBufUtils.readTag(buf);
            if (save != null) {
                NBTTagList tagList = save.getTagList("data", 10);
                for (int s = 0; s < tagList.tagCount(); s++) {
                    //TODO fix loading to use interfaces, as this will not always be a silo connection data object
                    //TODO add sanity checks to either now show or block bad data in GUI
                    SiloConnectionData data = new SiloConnectionData(tagList.getCompoundTagAt(s));

                    //TODO find a way around this so cross world support is possible
                    if (data.dim == Minecraft.getMinecraft().theWorld.provider.dimensionId) {
                        data.world = Minecraft.getMinecraft().theWorld;
                        list.add(data);/*w  ww.ja  v a  2s  .co  m*/
                    }
                }
            }
        } else if (dataSize == 0) {
            //TODO show no connections
        } else if (dataSize == -1) {
            //TODO show in GUI connection was lost
        }
        posData[i] = pos;
        clientSiloDataCache.put(pos, list);
    }
    this.controllerData[controllerIndexValue] = posData;
}