Example usage for com.google.common.io ByteArrayDataInput readInt

List of usage examples for com.google.common.io ByteArrayDataInput readInt

Introduction

In this page you can find the example usage for com.google.common.io ByteArrayDataInput readInt.

Prototype

@Override
    int readInt();

Source Link

Usage

From source file:com.yogpc.qp.TileBasic.java

@Override
protected void S_recievePacket(final byte id, final byte[] data, final EntityPlayer ep) {
    final ByteArrayDataInput badi = ByteStreams.newDataInput(data);
    switch (id) {
    case PacketHandler.CtS_REMOVE_FORTUNE:
        this.fortuneList.remove(new BlockData(badi.readUTF(), badi.readInt()));
        break;//  ww  w  .  ja  v a 2s.co  m
    case PacketHandler.CtS_REMOVE_SILKTOUCH:
        this.silktouchList.remove(new BlockData(badi.readUTF(), badi.readInt()));
        break;
    case PacketHandler.CtS_TOGGLE_FORTUNE:
        this.fortuneInclude = !this.fortuneInclude;
        break;
    case PacketHandler.CtS_TOGGLE_SILKTOUCH:
        this.silktouchInclude = !this.silktouchInclude;
        break;
    }
}

From source file:micdoodle8.mods.galacticraft.core.tile.GCCoreTileEntityCoalGenerator.java

@Override
public void handlePacketData(INetworkManager network, int type, Packet250CustomPayload packet,
        EntityPlayer player, ByteArrayDataInput dataStream) {
    try {//from  ww  w  . j ava  2s  .c  om
        if (this.worldObj.isRemote) {
            this.generateWatts = dataStream.readFloat();
            this.itemCookTime = dataStream.readInt();
            this.setEnergyStored(dataStream.readFloat());
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:micdoodle8.mods.galacticraft.core.network.GCCorePacketManager.java

@Override
public void onPacketData(INetworkManager network, Packet250CustomPayload packet, Player player) {
    if (packet == null) {
        FMLLog.severe("Packet received as null!");
        return;//from w w  w  .j a  va2  s.c om
    }

    if (packet.data == null) {
        FMLLog.severe("Packet data received as null! ID " + packet.getPacketId());
        return;
    }

    try {
        final ByteArrayDataInput data = ByteStreams.newDataInput(packet.data);

        final int packetTypeID = data.readInt();

        if (packetTypeID == GCCorePacketType.ENTITY.ordinal()) {
            final double id = data.readInt();

            final World world = ((EntityPlayer) player).worldObj;

            if (world != null) {
                for (final Object o : world.loadedEntityList) {
                    if (o instanceof Entity) {
                        final Entity e = (Entity) o;

                        if (id == e.entityId && e instanceof IPacketReceiver) {
                            ((IPacketReceiver) e).handlePacketData(network, packetTypeID, packet,
                                    (EntityPlayer) player, data);
                        }
                    }
                }
            }
        } else if (packetTypeID == GCCorePacketType.TILEENTITY.ordinal()) {
            final int x = data.readInt();
            final int y = data.readInt();
            final int z = data.readInt();

            final World world = ((EntityPlayer) player).worldObj;

            if (world != null) {
                final TileEntity tileEntity = world.getBlockTileEntity(x, y, z);

                if (tileEntity != null) {
                    if (tileEntity instanceof IPacketReceiver) {
                        ((IPacketReceiver) tileEntity).handlePacketData(network, packetTypeID, packet,
                                (EntityPlayer) player, data);
                    }
                }
            }
        }
    } catch (final Exception e) {
        e.printStackTrace();
    }
}

From source file:shadowmage.ancient_warfare.common.gates.EntityGate.java

@Override
public void readSpawnData(ByteArrayDataInput data) {
    this.pos1 = new BlockPosition(data.readInt(), data.readInt(), data.readInt());
    this.pos2 = new BlockPosition(data.readInt(), data.readInt(), data.readInt());
    this.gateType = Gate.getGateByID(data.readInt());
    this.teamNum = data.readInt();
    this.edgePosition = data.readFloat();
    this.edgeMax = data.readFloat();
    this.gateStatus = data.readByte();
    this.gateOrientation = data.readByte();
    this.health = data.readInt();
}

From source file:org.yogpstop.qp.TileMiningCore.java

@Override
public void C_recievePacket(byte pattern, ByteArrayDataInput data, EntityPlayer ep) {
    switch (pattern) {
    case StC_OPENGUI_FORTUNE:
        this.fortuneInclude = data.readBoolean();
        this.fortuneList.clear();
        int fsize = data.readInt();
        for (int i = 0; i < fsize; i++) {
            this.fortuneList.add(data.readLong());
        }//w w w  .j  a v a  2 s.  co  m
        ep.openGui(QuarryPlus.instance, QuarryPlus.guiIdFList, this.worldObj, this.xCoord, this.yCoord,
                this.zCoord);
        break;
    case StC_OPENGUI_SILKTOUCH:
        this.silktouchInclude = data.readBoolean();
        this.silktouchList.clear();
        int ssize = data.readInt();
        for (int i = 0; i < ssize; i++) {
            this.silktouchList.add(data.readLong());
        }
        ep.openGui(QuarryPlus.instance, QuarryPlus.guiIdSList, this.worldObj, this.xCoord, this.yCoord,
                this.zCoord);
        break;
    }
}

From source file:com.yogpc.qp.tile.TileBasic.java

@Override
public void S_recievePacket(final byte id, final byte[] data, final EntityPlayer ep) {
    final ByteArrayDataInput badi = ByteStreams.newDataInput(data);
    switch (id) {
    case PacketHandler.CtS_REMOVE_FORTUNE:
        this.fortuneList.remove(new BlockData(badi.readUTF(), badi.readInt()));
        break;/*from w ww . j a v  a2 s  .c om*/
    case PacketHandler.CtS_REMOVE_SILKTOUCH:
        this.silktouchList.remove(new BlockData(badi.readUTF(), badi.readInt()));
        break;
    case PacketHandler.CtS_TOGGLE_FORTUNE:
        this.fortuneInclude = !this.fortuneInclude;
        break;
    case PacketHandler.CtS_TOGGLE_SILKTOUCH:
        this.silktouchInclude = !this.silktouchInclude;
        break;
    }
}

From source file:micdoodle8.mods.galacticraft.core.tile.GCCoreTileEntityFuelLoader.java

@Override
public void readPacket(ByteArrayDataInput data) {
    if (this.worldObj.isRemote) {
        this.setEnergyStored(data.readFloat());
        this.fuelTank.setFluid(new FluidStack(GalacticraftCore.fluidFuel, data.readInt()));
        this.disabled = data.readBoolean();
        this.disableCooldown = data.readInt();
    }//from ww  w . j  a v a 2 s .co m
}

From source file:micdoodle8.mods.galacticraft.core.tile.GCCoreTileEntityCargoUnloader.java

@Override
public void readPacket(ByteArrayDataInput data) {
    if (this.worldObj.isRemote) {
        this.setEnergyStored(data.readFloat());
        this.disabled = data.readBoolean();
        this.disableCooldown = data.readInt();
        this.targetEmpty = data.readBoolean();
        this.noTarget = data.readBoolean();
        this.targetNoInventory = data.readBoolean();
    }// w  w  w  .  j  ava 2s .  c o  m
}

From source file:micdoodle8.mods.galacticraft.core.tile.GCCoreTileEntityCargoLoader.java

@Override
public void readPacket(ByteArrayDataInput data) {
    if (this.worldObj.isRemote) {
        this.setEnergyStored(data.readFloat());
        this.disabled = data.readBoolean();
        this.disableCooldown = data.readInt();
        this.targetFull = data.readBoolean();
        this.outOfItems = data.readBoolean();
        this.noTarget = data.readBoolean();
        this.targetNoInventory = data.readBoolean();
    }//from  w w  w  .  j  ava2 s .c  o  m
}

From source file:shadowmage.ancient_warfare.common.vehicles.missiles.MissileBase.java

@Override
public void readSpawnData(ByteArrayDataInput data) {
    this.missileType = data.readInt();
    this.ammoType = AmmoRegistry.instance().getAmmoEntry(missileType);
    if (this.ammoType == null) {
        this.ammoType = Ammo.ammoArrow;
    }//from ww  w  .j a  v  a  2s  .com
    this.prevRotationYaw = this.rotationYaw = data.readFloat();
    this.prevRotationPitch = this.rotationPitch = data.readFloat();
    this.inGround = data.readBoolean();
    this.blockX = data.readInt();
    this.blockY = data.readInt();
    this.blockZ = data.readInt();
    this.blockID = data.readInt();
    this.blockMeta = data.readInt();
    this.rocketBurnTime = data.readInt();
    boolean hasLauncher = data.readBoolean();
    if (hasLauncher) {
        Entity launcher = worldObj.getEntityByID(data.readInt());
    }
}