List of usage examples for io.netty.buffer ByteBufInputStream readUTF
@Override public String readUTF() throws IOException
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;//from w ww .jav a 2 s .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.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 www.j a va2 s.c o 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.turretmod.client.util.ClientProxy.java
License:Creative Commons License
@Override public void processTargetListClt(ByteBufInputStream stream) throws IOException { int entityId = stream.readInt(); int listSize = stream.readInt(); Entity e = getMinecraft().theWorld.getEntityByID(entityId); if (e instanceof EntityTurretBase) { List<Class<? extends EntityLiving>> applicableTargets = new ArrayList<>(listSize); for (int i = 0; i < listSize; i++) { String clsName = stream.readUTF(); Class<? extends EntityLiving> entityCls = SAPUtils .getCasted(EntityList.stringToClassMapping.get(clsName)); applicableTargets.add(entityCls); }//w w w .j a v a2s .c om ((EntityTurretBase) e).getTargetHandler().setTargetList(applicableTargets); } }
From source file:de.sanandrew.mods.turretmod.client.util.ClientProxy.java
License:Creative Commons License
@Override public void processUpgradeListClt(ByteBufInputStream stream) throws IOException { int entityId = stream.readInt(); int listSize = stream.readInt(); Entity e = getMinecraft().theWorld.getEntityByID(entityId); if (e instanceof EntityTurretBase) { List<TurretUpgrade> currUpgList = new ArrayList<>(listSize); for (int i = 0; i < listSize; i++) { String regName = stream.readUTF(); currUpgList.add(TurretUpgradeRegistry.getUpgrade(regName)); }// ww w. j a va 2 s . c o m EntityTurretBase turret = (EntityTurretBase) e; turret.getUpgradeHandler().applyUpgradeList(turret, currUpgList); } }
From source file:de.sanandrew.mods.turretmod.network.packet.PacketEjectUpgrade.java
License:Creative Commons License
@Override public void process(ByteBufInputStream stream, ByteBuf rawData, INetHandler iNetHandler) throws IOException { if (iNetHandler instanceof NetHandlerPlayServer) { EntityPlayer player = ((NetHandlerPlayServer) iNetHandler).playerEntity; EntityTurretBase turret = (EntityTurretBase) player.worldObj.getEntityByID(stream.readInt()); String upgradeName = stream.readUTF(); TurretUpgrade upgrade = TurretUpgradeRegistry.getUpgrade(upgradeName); if (upgrade != null) { List<TurretUpgrade> ejectingUpgrades = getRcurDepUpgrades(upgrade, turret.getUpgradeHandler().getUpgradeList()); for (TurretUpgrade ejectUpg : ejectingUpgrades) { ItemStack stack = TmrItems.turretUpgrade.getStackWithUpgrade(ejectUpg, 1); turret.getUpgradeHandler().removeUpgrade(turret, ejectUpg); if ((stack = InventoryUtils.addStackToInventory(stack, player.inventory)) != null) { turret.entityDropItem(stack, 0.0F); }/*from w w w . jav a2 s. c om*/ player.inventoryContainer.detectAndSendChanges(); } } else { TurretMod.MOD_LOG.printf(Level.WARN, "Cannot eject upgrade %s! This is an invalid upgrade name!", upgradeName); } } }
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 ww. j a v a 2 s. c o m*/ 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 {/* w w w. ja v a2 s. c om*/ @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.PacketAuth.java
License:Open Source License
@Override public void read(ByteBufInputStream byteBuf) throws IOException { this.apiKey = byteBuf.readUTF(); }
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(); }
From source file:net.mcsproject.daemon.network.packets.PacketRequest.java
License:Open Source License
@Override public void read(ByteBufInputStream byteBuf) throws IOException { this.resourceType = byteBuf.readUTF(); this.resourceName = byteBuf.readUTF(); }