Java Code Examples for net.minecraft.network.PacketBuffer#writeString()
The following examples show how to use
net.minecraft.network.PacketBuffer#writeString() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SyncMapServer.java From OpenModsLib with MIT License | 6 votes |
private void writeSyncObjectInitialization(PacketBuffer dos) throws IOException { if (!firstRemoteObjectInitialized) { firstRemoteObjectInitialized = true; bitmapLength = (objects.size() + 7) / 8; } dos.writeVarInt(objects.size()); for (Entry e : orderedEntries) { dos.writeString(e.name); final int typeId = SyncableObjectTypeRegistry.getTypeId(e.type); dos.writeVarInt(typeId); e.obj.writeToStream(dos); } }
Example 2
Source File: PacketAsteroidInfo.java From AdvancedRocketry with MIT License | 6 votes |
@Override public void write(ByteBuf out) { PacketBuffer packetBuffer = new PacketBuffer(out); NBTTagCompound nbt = new NBTTagCompound(); packetBuffer.writeString(asteroid.ID); packetBuffer.writeInt(asteroid.distance); packetBuffer.writeInt(asteroid.mass); packetBuffer.writeInt(asteroid.minLevel); packetBuffer.writeFloat(asteroid.massVariability); packetBuffer.writeFloat(asteroid.richness); //factor of the ratio of ore to stone packetBuffer.writeFloat(asteroid.richnessVariability); //variability of richness packetBuffer.writeFloat(asteroid.probability); //probability of the asteroid spawning packetBuffer.writeFloat(asteroid.timeMultiplier); packetBuffer.writeInt(asteroid.stackProbabilites.size()); for(int i = 0; i < asteroid.stackProbabilites.size(); i++) { packetBuffer.writeItemStack(asteroid.itemStacks.get(i)); packetBuffer.writeFloat(asteroid.stackProbabilites.get(i)); } }
Example 3
Source File: DryingRecipe.java From Survivalist with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void write(PacketBuffer buffer, DryingRecipe recipe) { buffer.writeString(recipe.group); recipe.input.write(buffer); buffer.writeItemStack(recipe.output); buffer.writeVarInt(recipe.time); }
Example 4
Source File: SyncableTank.java From OpenModsLib with MIT License | 5 votes |
@Override public void writeToStream(PacketBuffer stream) { if (fluid != null) { stream.writeBoolean(true); final String id = FluidRegistry.getFluidName(fluid.getFluid()); stream.writeString(id); stream.writeInt(fluid.amount); stream.writeCompoundTag(fluid.tag); } else { stream.writeBoolean(false); } }
Example 5
Source File: PacketSpaceStationInfo.java From AdvancedRocketry with MIT License | 5 votes |
@Override public void write(ByteBuf out) { NBTTagCompound nbt = new NBTTagCompound(); out.writeInt(stationNumber); boolean flag = false; //TODO //dimProperties == null; if(!flag) { //Try to send the nbt data of the dimension to the client, if it fails(probably due to non existent Biome ids) then remove the dimension try { spaceObject.writeToNbt(nbt); //spaceObject.getProperties().writeToNBT(nbt); PacketBuffer packetBuffer = new PacketBuffer(out); out.writeBoolean(false); packetBuffer.writeString(SpaceObjectManager.getSpaceManager().getItentifierFromClass(spaceObject.getClass())); packetBuffer.writeCompoundTag(nbt); packetBuffer.writeInt(spaceObject.getFuelAmount()); packetBuffer.writeBoolean(spaceObject.hasWarpCores); out.writeInt(spaceObject.getForwardDirection().ordinal()); } catch(NullPointerException e) { out.writeBoolean(true); Logger.getLogger("advancedRocketry").warning("Dimension " + stationNumber + " has thrown an exception trying to write NBT, deleting!"); DimensionManager.getInstance().deleteDimension(stationNumber); } } else out.writeBoolean(flag); }
Example 6
Source File: TileAtmosphereDetector.java From AdvancedRocketry with MIT License | 5 votes |
@Override public void writeDataToNetwork(ByteBuf out, byte id) { //Send the unlocalized name over the net to reduce chances of foulup due to client/server inconsistencies if(id == 0) { PacketBuffer buf = new PacketBuffer(out); buf.writeShort(atmosphereToDetect.getUnlocalizedName().length()); buf.writeString(atmosphereToDetect.getUnlocalizedName()); } }
Example 7
Source File: TileLandingPad.java From AdvancedRocketry with MIT License | 5 votes |
@Override public void writeDataToNetwork(ByteBuf out, byte id) { if(id == 0) { PacketBuffer buff = new PacketBuffer(out); buff.writeInt(name.length()); buff.writeString(name); } }
Example 8
Source File: MixinC00Handshake.java From LiquidBounce with GNU General Public License v3.0 | 5 votes |
/** * @author CCBlueX */ @Overwrite public void writePacketData(PacketBuffer buf) { buf.writeVarIntToBuffer(this.protocolVersion); buf.writeString(this.ip + (AntiForge.enabled && AntiForge.blockFML && !Minecraft.getMinecraft().isIntegratedServerRunning() ? "" : "\0FML\0")); buf.writeShort(this.port); buf.writeVarIntToBuffer(this.requestedState.getId()); }
Example 9
Source File: ChoppingRecipe.java From Survivalist with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void write(PacketBuffer buffer, ChoppingRecipe recipe) { buffer.writeString(recipe.group); recipe.input.write(buffer); buffer.writeItemStack(recipe.output); buffer.writeDouble(recipe.outputMultiplier); buffer.writeDouble(recipe.hitCountMultiplier); buffer.writeVarInt(recipe.maxOutput); buffer.writeVarInt(recipe.sawingTime); }
Example 10
Source File: CreateRecipe.java From EnderStorage with MIT License | 5 votes |
@Override public void write(PacketBuffer buffer, CreateRecipe recipe) { buffer.writeString(recipe.group); for (Ingredient ingredient : recipe.input) { ingredient.write(buffer); } buffer.writeItemStack(recipe.output); }
Example 11
Source File: CraftPlayer.java From Kettle with GNU General Public License v3.0 | 5 votes |
@Override public void stopSound(String sound, SoundCategory category) { if (getHandle().connection == null) return; PacketBuffer packetdataserializer = new PacketBuffer(Unpooled.buffer()); packetdataserializer.writeString(category == null ? "" : net.minecraft.util.SoundCategory.valueOf(category.name()).getName()); packetdataserializer.writeString(sound); getHandle().connection.sendPacket(new SPacketCustomPayload("MC|StopSound", packetdataserializer)); }
Example 12
Source File: PlayerParticleData.java From MiningGadgets with MIT License | 5 votes |
@Override public void write(PacketBuffer buf) { buf.writeString(partType); buf.writeDouble(targetX); buf.writeDouble(targetY); buf.writeDouble(targetZ); buf.writeFloat(size); buf.writeFloat(r); buf.writeFloat(g); buf.writeFloat(b); buf.writeFloat(maxAgeMul); buf.writeBoolean(depthTest); }
Example 13
Source File: MixinC00Handshake.java From LiquidBounce with GNU General Public License v3.0 | 5 votes |
/** * @author CCBlueX */ @Overwrite public void writePacketData(PacketBuffer buf) { buf.writeVarIntToBuffer(this.protocolVersion); buf.writeString(this.ip + (AntiForge.enabled && AntiForge.blockFML && !Minecraft.getMinecraft().isIntegratedServerRunning() ? "" : "\0FML\0")); buf.writeShort(this.port); buf.writeVarIntToBuffer(this.requestedState.getId()); }
Example 14
Source File: ReColourRecipe.java From EnderStorage with MIT License | 4 votes |
@Override public void write(PacketBuffer buffer, ReColourRecipe recipe) { buffer.writeString(recipe.group); recipe.ingredient.write(buffer); buffer.writeItemStack(recipe.output); }
Example 15
Source File: MixinNetHandlerPlayClient.java From Hyperium with GNU Lesser General Public License v3.0 | 4 votes |
@Inject(method = "handleCustomPayload", at = @At("RETURN")) private void handleCustomPayload(S3FPacketCustomPayload packetIn, CallbackInfo ci) { PacketBuffer packetBuffer = packetIn.getBufferData(); try { int readableBytes = packetBuffer.readableBytes(); if (readableBytes > 0) { byte[] payload = new byte[readableBytes - 1]; packetBuffer.readBytes(payload); String message = new String(payload, Charsets.UTF_8); if (LoginReplyHandler.SHOW_MESSAGES) { GeneralChatHandler.instance().sendMessage("Packet message on channel " + packetIn.getChannelName() + " -> " + message); } if ("REGISTER".equalsIgnoreCase(packetIn.getChannelName())) { if (message.contains("Hyperium")) { PacketBuffer buffer = new PacketBuffer(Unpooled.buffer()); buffer.writeString("Hyperium;" + Metadata.getVersion() + ";" + Metadata.getVersionID()); addToSendQueue(new C17PacketCustomPayload("REGISTER", buffer)); PacketBuffer addonbuffer = new PacketBuffer(Unpooled.buffer()); List<AddonManifest> addons = AddonBootstrap.INSTANCE.getAddonManifests(); addonbuffer.writeInt(addons.size()); for (AddonManifest addonmanifest : addons) { String addonName = addonmanifest.getName(); String version = addonmanifest.getVersion(); if (addonName == null) addonName = addonmanifest.getMainClass(); if (version == null) version = "unknown"; addonbuffer.writeString(addonName); addonbuffer.writeString(version); } addToSendQueue(new C17PacketCustomPayload("hyperium|Addons", addonbuffer)); } } } } catch (Exception ex) { ex.printStackTrace(); } }
Example 16
Source File: PacketDimInfo.java From AdvancedRocketry with MIT License | 4 votes |
@Override public void write(ByteBuf out) { NBTTagCompound nbt = new NBTTagCompound(); out.writeInt(dimNumber); boolean flag = dimProperties == null; if(!flag) { //Try to send the nbt data of the dimension to the client, if it fails(probably due to non existent Biome ids) then remove the dimension PacketBuffer packetBuffer = new PacketBuffer(out); try { dimProperties.writeToNBT(nbt); out.writeBoolean(false); packetBuffer.writeCompoundTag(nbt); out.writeShort(dimProperties.getRequiredArtifacts().size()); for(ItemStack i : dimProperties.getRequiredArtifacts()) { NBTTagCompound nbt2 = new NBTTagCompound(); i.writeToNBT(nbt2); packetBuffer.writeCompoundTag(nbt2); } } catch(NullPointerException e) { out.writeBoolean(true); e.printStackTrace(); Logger.getLogger("advancedRocketry").warning("Dimension " + dimNumber + " has thrown an exception trying to write NBT, deleting!"); DimensionManager.getInstance().deleteDimension(dimNumber); } if(!dimProperties.customIcon.isEmpty()) { packetBuffer.writeShort(dimProperties.customIcon.length()); packetBuffer.writeString(dimProperties.customIcon); } else packetBuffer.writeShort(0); } else out.writeBoolean(flag); }
Example 17
Source File: PacketUpdateUpgrade.java From MiningGadgets with MIT License | 4 votes |
public static void encode(PacketUpdateUpgrade msg, PacketBuffer buffer) { buffer.writeString(msg.upgrade); }
Example 18
Source File: PacketExtractUpgrade.java From MiningGadgets with MIT License | 4 votes |
public static void encode(PacketExtractUpgrade msg, PacketBuffer buffer) { buffer.writeInt(msg.nameLength); buffer.writeBlockPos(msg.pos); buffer.writeString(msg.upgrade); }
Example 19
Source File: TypeRW.java From OpenModsLib with MIT License | 4 votes |
@Override public void writeToStream(String o, PacketBuffer output) { output.writeString(Strings.nullToEmpty(o)); }
Example 20
Source File: SyncableString.java From OpenModsLib with MIT License | 4 votes |
@Override public void writeToStream(PacketBuffer stream) { stream.writeString(value); }