Example usage for io.netty.buffer ByteBufInputStream readByte

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

Introduction

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

Prototype

@Override
    public byte readByte() throws IOException 

Source Link

Usage

From source file:de.sanandrew.mods.claysoldiers.network.packet.PacketParticleFX.java

License:Creative Commons License

@Override
public void process(ByteBufInputStream stream, ByteBuf rawData, INetHandler handler) throws IOException {
    EnumParticleFx fxType = EnumParticleFx.VALUES[stream.readByte()];
    switch (fxType) {
    case FX_DIGGING: // FALL_THROUGH
    case FX_BREAK: // FALL_THROUGH
    case FX_SOLDIER_DEATH:
        ClaySoldiersMod.proxy.spawnParticles(fxType, Quartet.with(stream.readDouble(),
                stream.readDouble() + 0.5D, stream.readDouble(), stream.readUTF()));
        break;/* www  .  j av a 2s.co  m*/
    case FX_CRIT:
        ClaySoldiersMod.proxy.spawnParticles(fxType,
                Triplet.with(stream.readDouble(), stream.readDouble() + 0.1D, stream.readDouble()));
        break;
    case FX_HORSE_DEATH: // FALL_THROUGH
    case FX_BUNNY_DEATH: // FALL_THROUGH
    case FX_TURTLE_DEATH:
        ClaySoldiersMod.proxy.spawnParticles(fxType, Quartet.with(stream.readDouble(),
                stream.readDouble() + 0.5D, stream.readDouble(), stream.readByte()));
        break;
    case FX_SPELL:
        ClaySoldiersMod.proxy.spawnParticles(fxType,
                Sextet.with(stream.readDouble(), stream.readDouble() + 0.5D, stream.readDouble(),
                        stream.readDouble(), stream.readDouble(), stream.readDouble()));
        break;
    case FX_SHOCKWAVE: // FALL_THROUGH
    case FX_MAGMAFUSE:
        ClaySoldiersMod.proxy.spawnParticles(fxType,
                Triplet.with(stream.readDouble(), stream.readDouble(), stream.readDouble()));
        break;
    }
}

From source file:de.sanandrew.mods.claysoldiers.network.packet.PacketSendEffectNBT.java

License:Creative Commons License

@Override
public void process(ByteBufInputStream stream, ByteBuf rawData, INetHandler handler) throws IOException {
    ClaySoldiersMod.proxy.applyEffectNbt(stream.readInt(), stream.readByte(), ByteBufUtils.readTag(rawData));
}

From source file:de.sanandrew.mods.claysoldiers.network.packet.PacketSendUpgradeNBT.java

License:Creative Commons License

@Override
public void process(ByteBufInputStream stream, ByteBuf rawData, INetHandler handler) throws IOException {
    ClaySoldiersMod.proxy.applyUpgradeNbt(stream.readInt(), stream.readByte(), ByteBufUtils.readTag(rawData));
}

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  w  w.  j a v a2  s  . c  om
    }

    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.enderstuffp.network.packet.PacketBiomeChangerModify.java

License:Creative Commons License

@Override
public void process(ByteBufInputStream stream, ByteBuf rawData, INetHandler handler) throws IOException {
    World world = EnderStuffPlus.proxy.getWorld(handler);
    if (world.isRemote) {
        int x = stream.readInt();
        int z = stream.readInt();
        int y = world.getTopSolidOrLiquidBlock(x, z);
        byte biomeId = stream.readByte();
        Chunk chunk = world.getChunkFromBlockCoords(x, z);
        byte[] biomeArray = chunk.getBiomeArray();

        biomeArray[(z & 0xF) << 4 | (x & 0xF)] = biomeId;
        chunk.setBiomeArray(biomeArray);

        EnderStuffPlus.proxy.handleParticle(EnumParticleFx.FX_BIOME_DATA, x + 0.5F, y, z + 0.5D,
                Unit.with((short) biomeId));
        world.markBlockForUpdate(x, y - 1, z);
    }// ww  w  .  j  ava 2 s  . c o m
}

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

License:Creative Commons License

@Override
public void process(ByteBufInputStream stream, ByteBuf rawData, INetHandler handler) throws IOException {
    if (handler instanceof NetHandlerPlayServer) {
        EntityPlayerMP playerMP = ((NetHandlerPlayServer) handler).playerEntity;
        int entityId = stream.readInt();
        IEnderPet pet = (IEnderPet) playerMP.worldObj.getEntityByID(entityId);

        switch (stream.readByte()) {
        case 0://from w ww  . ja va  2  s.com
            if (pet.canMount()) {
                playerMP.mountEntity(pet.getEntity());
            }
            break;
        case 1:
            pet.setSitting(!pet.isSitting());
            break;
        case 2:
            pet.setFollowing(!pet.isFollowing());
            break;
        case 3: {
            if (playerMP.inventory.hasItem(Items.egg) || playerMP.capabilities.isCreativeMode) {
                ItemStack stack = new ItemStack(EspItems.enderPetEgg, 1);
                NBTTagCompound nbt = new NBTTagCompound();
                pet.writePetToNBT(nbt);
                stack.setTagCompound(nbt);
                if (playerMP.inventory.addItemStackToInventory(stack)) {
                    playerMP.inventory.consumeInventoryItem(Items.egg);
                    playerMP.inventoryContainer.detectAndSendChanges();
                    pet.getEntity().setDead();
                } else {
                    //TODO: use translation string
                    playerMP.addChatMessage(
                            new ChatComponentText("You don't have enough inventory space to do this!"));
                }
            } else {
                //TODO: use translation string
                playerMP.addChatMessage(new ChatComponentText("You don't have the required egg!"));
            }
        }
            break;
        case 4:
            pet.setName(stream.readUTF());
            break;
        }
    }
}

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

License:Creative Commons License

@Override
public void process(ByteBufInputStream stream, ByteBuf rawData, INetHandler handler) throws IOException {
    EnderStuffPlus.proxy.handleParticle(EnumParticleFx.VALUES[stream.readByte()], stream.readDouble(),
            stream.readDouble(), stream.readDouble(), Tuple.readFromByteBufStream(stream));
}

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

License:Creative Commons License

@Override
public void process(ByteBufInputStream stream, ByteBuf rawData, INetHandler handler) throws IOException {
    EnderStuffPlus.proxy.openGui(null, EnumGui.VALUES[stream.readByte()], stream.readInt(), stream.readInt(),
            stream.readInt());/* w w w . j  av  a2 s. c o m*/
}

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

License:Creative Commons License

@Override
public void process(ByteBufInputStream stream, ByteBuf rawData, INetHandler handler) throws IOException {
    if (handler instanceof NetHandlerPlayServer) {
        EntityPlayerMP playerMP = ((NetHandlerPlayServer) handler).playerEntity;
        TileEntityWeatherAltar altar = (TileEntityWeatherAltar) playerMP.worldObj
                .getTileEntity(stream.readInt(), stream.readInt(), stream.readInt());
        altar.setWeather(stream.readByte(), stream.readInt());
    }/*from   w ww. j  av a2 s . co  m*/
}

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());/*w  ww.  j a va2s.  c  o m*/
}