Java Code Examples for net.minecraft.util.PacketByteBuf#readString()

The following examples show how to use net.minecraft.util.PacketByteBuf#readString() . 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: ClientNetworkHandler.java    From fabric-carpet with MIT License 6 votes vote down vote up
private static void onHi(PacketByteBuf data)
{
    synchronized (CarpetClient.sync)
    {
        CarpetClient.setCarpet();
        CarpetClient.serverCarpetVersion = data.readString(64);
        if (CarpetSettings.carpetVersion.equals(CarpetClient.serverCarpetVersion))
        {
            CarpetSettings.LOG.info("Joined carpet server with matching carpet version");
        }
        else
        {
            CarpetSettings.LOG.warn("Joined carpet server with another carpet version: "+CarpetClient.serverCarpetVersion);
        }
        if (CarpetClient.getPlayer() != null)
            respondHello();

    }
}
 
Example 2
Source File: AddonS2CPacket.java    From Sandbox with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void read(PacketByteBuf var1) {
    count = var1.readInt();
    prefix = var1.readString(Short.MAX_VALUE);
    if (count > 0) {
        addons = new ArrayList<>();
    } else {
        addons = Collections.emptyList();
    }
    for (int i = 0; i < count; i++) {
        String suffix = var1.readString(Short.MAX_VALUE);
        String hash = var1.readString(Short.MAX_VALUE);
        addons.add(new Pair<>(suffix, hash));
    }
}
 
Example 3
Source File: VelocityUtil.java    From Sandbox with GNU Lesser General Public License v3.0 5 votes vote down vote up
private static void readProperties(final PacketByteBuf buf, final GameProfile profile) {
    if (buf.readableBytes() < 4)
        return;
    final int properties = buf.readInt();
    for (int i1 = 0; i1 < properties; i1++) {
        final String name = buf.readString(32767);
        final String value = buf.readString(32767);
        final String signature = buf.readBoolean() ? buf.readString(32767) : null;
        profile.getProperties().put(name, new Property(name, value, signature));
    }
}
 
Example 4
Source File: ServerNetworkHandler.java    From fabric-carpet with MIT License 5 votes vote down vote up
public static void onHello(ServerPlayerEntity playerEntity, PacketByteBuf packetData)
{

    validCarpetPlayers.add(playerEntity);
    String clientVersion = packetData.readString(64);
    remoteCarpetPlayers.put(playerEntity, clientVersion);
    if (clientVersion.equals(CarpetSettings.carpetVersion))
        CarpetSettings.LOG.info("Player "+playerEntity.getName().getString()+" joined with a matching carpet client");
    else
        CarpetSettings.LOG.warn("Player "+playerEntity.getName().getString()+" joined with another carpet version: "+clientVersion);
    DataBuilder data = DataBuilder.create().withTickRate();
    CarpetServer.settingsManager.getRules().forEach(data::withRule);
    playerEntity.networkHandler.sendPacket(new CustomPayloadS2CPacket(CarpetClient.CARPET_CHANNEL, data.build() ));
}
 
Example 5
Source File: VelocityUtil.java    From Sandbox with GNU Lesser General Public License v3.0 4 votes vote down vote up
public static GameProfile createProfile(final PacketByteBuf buf) {
    final GameProfile profile = new GameProfile(buf.readUuid(), buf.readString(16));
    readProperties(buf, profile);
    return profile;
}