Java Code Examples for codechicken.lib.packet.PacketCustom#writeString()

The following examples show how to use codechicken.lib.packet.PacketCustom#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: PlayerChunkViewerTracker.java    From ChickenChunks with MIT License 6 votes vote down vote up
public void writeTicketToPacket(PacketCustom packet, Ticket ticket, Collection<ChunkCoordIntPair> chunkSet)
{
    packet.writeInt(manager.ticketIDs.get(ticket));
    packet.writeString(ticket.getModId());
    String player = ticket.getPlayerName();
    packet.writeBoolean(player != null);
    if(player != null)
        packet.writeString(player);
    packet.writeByte(ticket.getType().ordinal());
    Entity entity = ticket.getEntity();
    if(entity != null)
        packet.writeInt(entity.getEntityId());
    packet.writeShort(chunkSet.size());
    for(ChunkCoordIntPair chunk : chunkSet)
    {
        packet.writeInt(chunk.chunkXPos);
        packet.writeInt(chunk.chunkZPos);
    }
    
    knownTickets.add(manager.ticketIDs.get(ticket));
}
 
Example 2
Source File: TileSpotLoader.java    From ChickenChunks with MIT License 5 votes vote down vote up
public Packet getDescriptionPacket() {
    PacketCustom packet = new PacketCustom(ChunkLoaderSPH.channel, 11);
    packet.writeCoord(xCoord, yCoord, zCoord);
    packet.writeBoolean(active);
    packet.writeBoolean(owner != null);
    if (owner != null)
        packet.writeString(owner);
    return packet.toPacket();
}
 
Example 3
Source File: WRCoreSPH.java    From WirelessRedstone with MIT License 5 votes vote down vote up
public static void sendSetFreqOwner(int freq, String username) {
    PacketCustom packet = new PacketCustom(WirelessRedstoneCore.channel, 9);
    packet.writeShort(freq);
    packet.writeString(username);

    packet.sendToClients();
}
 
Example 4
Source File: WRCoreSPH.java    From WirelessRedstone with MIT License 5 votes vote down vote up
public static void sendFreqOwnerTo(EntityPlayer player, ArrayList<Integer> freqsWithOwners) {
    if (freqsWithOwners.size() == 0)
        return;

    PacketCustom packet = new PacketCustom(WirelessRedstoneCore.channel, 10);
    packet.writeShort(freqsWithOwners.size());
    for (int freq : freqsWithOwners) {
        packet.writeShort(freq);
        packet.writeString(RedstoneEther.get(false).getFreqOwner(freq));
    }
    packet.sendToPlayer(player);
}
 
Example 5
Source File: WRCoreSPH.java    From WirelessRedstone with MIT License 5 votes vote down vote up
public static void sendFreqInfoTo(EntityPlayer player, ArrayList<Integer> freqsWithInfo) {
    if (freqsWithInfo.size() == 0)
        return;

    PacketCustom packet = new PacketCustom(WirelessRedstoneCore.channel, 1);
    packet.writeShort(freqsWithInfo.size());
    for (int freq : freqsWithInfo) {
        packet.writeShort(freq);
        packet.writeByte(RedstoneEther.get(false).getFreqColourId(freq));
        packet.writeString(RedstoneEther.get(false).getFreqName(freq));
    }
    packet.sendToPlayer(player);
}
 
Example 6
Source File: WRCoreSPH.java    From WirelessRedstone with MIT License 5 votes vote down vote up
public static void sendSetFreqInfoTo(EntityPlayer player, int freq, String name, int colourid) {
    PacketCustom packet = new PacketCustom(WirelessRedstoneCore.channel, 4);
    packet.writeShort(freq);
    packet.writeByte(colourid);
    packet.writeString(name);

    packet.sendToPlayer(player);
}
 
Example 7
Source File: WRCoreCPH.java    From WirelessRedstone with MIT License 5 votes vote down vote up
public static void sendSetFreqInfo(int freq, String name, int colourid) {
    PacketCustom packet = new PacketCustom(WirelessRedstoneCore.channel, 4);
    packet.writeShort((short) freq);
    packet.writeString(name);
    packet.writeByte((byte) colourid);
    packet.sendToServer();
}
 
Example 8
Source File: NEISPH.java    From NotEnoughItems with MIT License 5 votes vote down vote up
public static void sendHasServerSideTo(EntityPlayerMP player) {
    NEIServerConfig.logger.debug("Sending serverside check to: " + player.getCommandSenderName());
    PacketCustom packet = new PacketCustom(channel, 1);
    packet.writeByte(NEIActions.protocol);
    packet.writeString(player.worldObj.getWorldInfo().getWorldName());

    packet.sendToPlayer(player);
}
 
Example 9
Source File: NEIServerPacketHandler.java    From NotEnoughItems with MIT License 5 votes vote down vote up
/**
 * Sends the current protocol version and world to the client.
 * Called every time the player changes dimensions.
 * If successful on the client, it will request a LoginState.
 *
 * @param player The player to send the ServerSide check to.
 */
public static void sendServerSideCheck(EntityPlayerMP player) {
    LogHelper.debug("Sending ServerSide check to: " + player.getName());
    PacketCustom packet = new PacketCustom(channel, 1);
    packet.writeByte(NEIActions.protocol);
    packet.writeString(player.world.getWorldInfo().getWorldName());

    packet.sendToPlayer(player);
}
 
Example 10
Source File: PlayerChunkViewerTracker.java    From ChickenChunks with MIT License 5 votes vote down vote up
public void removePlayer(String username)
{
    PacketCustom packet = new PacketCustom(channel, 7);
    packet.writeString(username);
    
    packet.sendToPlayer(owner);
}
 
Example 11
Source File: PlayerChunkViewerTracker.java    From ChickenChunks with MIT License 5 votes vote down vote up
public void updatePlayer(EntityPlayer player)
{
    PacketCustom packet = new PacketCustom(channel, 6);
    packet.writeString(player.getCommandSenderName());
    packet.writeInt(player.dimension);
    Vector3 pos = Vector3.fromEntity(player);
    packet.writeFloat((float) pos.x);
    packet.writeFloat((float) pos.y);
    packet.writeFloat((float) pos.z);
    
    packet.sendToPlayer(owner);
}
 
Example 12
Source File: TileChunkLoader.java    From ChickenChunks with MIT License 5 votes vote down vote up
public Packet getDescriptionPacket()
{
    PacketCustom packet = new PacketCustom(ChunkLoaderSPH.channel, 10);
    packet.writeCoord(xCoord, yCoord, zCoord);
    packet.writeByte(shape.ordinal());
    packet.writeByte(radius);
    packet.writeBoolean(active);
    packet.writeBoolean(owner != null);
    if(owner != null)
        packet.writeString(owner);
    return packet.toPacket();
}
 
Example 13
Source File: TankSynchroniser.java    From EnderStorage with MIT License 5 votes vote down vote up
@Override
public void sendSyncPacket()
{
    if(!tracking)
        return;
    
    PacketCustom packet = new PacketCustom(EnderStorageSPH.channel, 4);
    packet.writeShort(storage.freq);
    packet.writeString(storage.owner);
    packet.writeFluidStack(s_liquid);
    packet.sendToPlayer(player);
}
 
Example 14
Source File: TileFrequencyOwner.java    From EnderStorage with MIT License 5 votes vote down vote up
@Override
public final Packet getDescriptionPacket()
{
    PacketCustom packet = new PacketCustom(EnderStorageSPH.channel, 1);
    packet.writeCoord(xCoord, yCoord, zCoord);
    packet.writeShort(freq);
    packet.writeString(owner);
    writeToPacket(packet);
    return packet.toPacket();
}
 
Example 15
Source File: EnderStorageSPH.java    From EnderStorage with MIT License 5 votes vote down vote up
public static void sendOpenUpdateTo(EntityPlayer player, String owner, int freq, boolean open) {
    PacketCustom packet = new PacketCustom(channel, 3);
    packet.writeString(owner);
    packet.writeShort(freq);
    packet.writeBoolean(open);

    packet.sendToPlayer(player);
}
 
Example 16
Source File: NEICPH.java    From NotEnoughItems with MIT License 4 votes vote down vote up
public static void sendSetPropertyDisabled(String name, boolean enable) {
    PacketCustom packet = new PacketCustom(channel, 12);
    packet.writeString(name);
    packet.writeBoolean(enable);
    packet.sendToServer();
}
 
Example 17
Source File: NEICPH.java    From NotEnoughItems with MIT License 4 votes vote down vote up
public static void sendMobSpawnerID(int x, int y, int z, String mobtype) {
    PacketCustom packet = new PacketCustom(channel, 15);
    packet.writeCoord(x, y, z);
    packet.writeString(mobtype);
    packet.sendToServer();
}
 
Example 18
Source File: WRCoreCPH.java    From WirelessRedstone with MIT License 4 votes vote down vote up
public static void sendSetFreqOwner(int freq, String username) {
    PacketCustom packet = new PacketCustom(WirelessRedstoneCore.channel, 9);
    packet.writeShort(freq);
    packet.writeString(username);
    packet.sendToServer();
}
 
Example 19
Source File: NEIClientPacketHandler.java    From NotEnoughItems with MIT License 4 votes vote down vote up
public static void sendMobSpawnerID(int x, int y, int z, String mobtype) {
    PacketCustom packet = new PacketCustom(channel, 15);
    packet.writePos(new BlockPos(x, y, z));
    packet.writeString(mobtype);
    packet.sendToServer();
}
 
Example 20
Source File: NEIClientPacketHandler.java    From NotEnoughItems with MIT License 3 votes vote down vote up
/**
 * Sent to the server when a user disables a specific action.
 * For example Noon, Weather.
 * Is handled on the server then relayed to all clients in the dimension.
 *
 * @param name   The identifier for the action.
 * @param enable The actions new state.
 */
public static void sendActionDisableStateChange(String name, boolean enable) {
    PacketCustom packet = new PacketCustom(channel, 12);
    packet.writeString(name);
    packet.writeBoolean(enable);
    packet.sendToServer();
}