List of usage examples for io.netty.buffer ByteBufInputStream readInt
@Override public int readInt() throws IOException
From source file:com.kanbekotori.keycraft.network.RewriteNetwork.java
License:Open Source License
/** */ @SubscribeEvent// w ww .j av a 2 s .c om public void onServerPacket(ServerCustomPacketEvent event) { EntityPlayerMP player = ((NetHandlerPlayServer) event.handler).playerEntity; ByteBufInputStream stream = new ByteBufInputStream(event.packet.payload()); try { switch (stream.readInt()) { case LEARN_SKILL_CODE: RewriteHelper.learnSkill(player, stream.readInt()); break; case USE_SKILL_CODE: RewriteHelper.useSkill(player); break; } stream.close(); } catch (IOException e) { e.printStackTrace(); } }
From source file:com.kanbekotori.keycraft.network.RewriteNetwork.java
License:Open Source License
/** */ @SubscribeEvent//from w ww .jav a2s.c o 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.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.claysoldiers.network.packet.PacketSoldierRender.java
License:Creative Commons License
@Override public void process(ByteBufInputStream stream, ByteBuf rawData, INetHandler handler) throws IOException { ClaySoldiersMod.proxy.applySoldierRenderFlags(stream.readInt(), stream.readLong(), stream.readLong(), stream.readLong(), stream.readLong()); }
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;//from w w w . j a v a2s .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.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); }//from www. ja v a 2 s .co 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:// w ww . j av a 2 s . co m 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.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 a 2s . 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 . ja v a 2 s.c o m*/ }