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

The following examples show how to use codechicken.lib.packet.PacketCustom#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: PlayerChunkViewer.java    From ChickenChunks with MIT License 6 votes vote down vote up
public TicketInfo(PacketCustom packet, WorldClient world)
{
    ID = packet.readInt();
    modId = packet.readString();
    if(packet.readBoolean())
        player = packet.readString();
    type = net.minecraftforge.common.ForgeChunkManager.Type.values()[packet.readUByte()];
    if(type == net.minecraftforge.common.ForgeChunkManager.Type.ENTITY)
        entity = world.getEntityByID(packet.readInt());
    int chunks = packet.readUShort();
    chunkSet = new HashSet<ChunkCoordIntPair>(chunks);
    for(int i = 0; i < chunks; i++)
    {
        chunkSet.add(new ChunkCoordIntPair(packet.readInt(), packet.readInt()));
    }
}
 
Example 2
Source File: TranslocatorCPH.java    From Translocators with MIT License 6 votes vote down vote up
@Override
public void handlePacket(PacketCustom packet, Minecraft mc, INetHandlerPlayClient handler) {
    switch (packet.getType()) {
        case 1:
        case 2:
        case 3:
            TileEntity tile = mc.theWorld.getTileEntity(packet.readInt(), packet.readInt(), packet.readInt());
            if (tile instanceof ICustomPacketTile)
                ((ICustomPacketTile) tile).handleDescriptionPacket(packet);
            break;
        case 4:
            int windowId = packet.readUByte();
            GuiTranslocator gui = new GuiTranslocator(new ContainerItemTranslocator(
                    new InventorySimple(9, packet.readUShort(), packet.readString()), mc.thePlayer.inventory));
            ClientUtils.openSMPGui(windowId, gui);
            break;
        case 5:
            mc.thePlayer.openContainer.putStackInSlot(packet.readUByte(), packet.readItemStack(true));
            break;
    }
}
 
Example 3
Source File: NEIClientPacketHandler.java    From NotEnoughItems with MIT License 5 votes vote down vote up
private void handleActionEnabled(PacketCustom packet) {
    String name = packet.readString();
    if (packet.readBoolean()) {
        NEIClientConfig.enabledActions.add(name);
    } else {
        NEIClientConfig.enabledActions.remove(name);
    }
}
 
Example 4
Source File: NEIClientPacketHandler.java    From NotEnoughItems with MIT License 5 votes vote down vote up
/**
 * Handles when an action is disabled.
 * For Example. Noon, Weather.
 *
 * @param packet The packet to handle.
 */
private void handleActionDisableStateChange(PacketCustom packet) {
    String name = packet.readString();
    if (packet.readBoolean()) {
        NEIClientConfig.disabledActions.add(name);
    } else {
        NEIClientConfig.disabledActions.remove(name);
    }
}
 
Example 5
Source File: TileChunkLoader.java    From ChickenChunks with MIT License 5 votes vote down vote up
public static void handleDescriptionPacket(PacketCustom packet, World world)
{
    TileEntity tile = world.getTileEntity(packet.readInt(), packet.readInt(), packet.readInt());
    if(tile instanceof TileChunkLoader)
    {        
        TileChunkLoader ctile = (TileChunkLoader)tile;         
        ctile.setShapeAndRadius(ChunkLoaderShape.values()[packet.readUByte()], packet.readUByte());
        ctile.active = packet.readBoolean();
        if(packet.readBoolean())
            ctile.owner = packet.readString();
    }
}
 
Example 6
Source File: TileSpotLoader.java    From ChickenChunks with MIT License 5 votes vote down vote up
public static void handleDescriptionPacket(PacketCustom packet, World world) {
    TileEntity tile = world.getTileEntity(packet.readInt(), packet.readInt(), packet.readInt());
    if (tile instanceof TileSpotLoader) {
        TileSpotLoader ctile = (TileSpotLoader) tile;
        ctile.active = packet.readBoolean();
        if (packet.readBoolean())
            ctile.owner = packet.readString();
    }
}
 
Example 7
Source File: NEICPH.java    From NotEnoughItems with MIT License 5 votes vote down vote up
private void handleActionEnabled(PacketCustom packet) {
    String name = packet.readString();
    if (packet.readBoolean())
        NEIClientConfig.enabledActions.add(name);
    else
        NEIClientConfig.enabledActions.remove(name);
}
 
Example 8
Source File: NEICPH.java    From NotEnoughItems with MIT License 5 votes vote down vote up
private void handleActionDisabled(PacketCustom packet) {
    String name = packet.readString();
    if (packet.readBoolean())
        NEIClientConfig.disabledActions.add(name);
    else
        NEIClientConfig.disabledActions.remove(name);
}
 
Example 9
Source File: WRCoreSPH.java    From WirelessRedstone with MIT License 5 votes vote down vote up
private void handleFreqInfo(PacketCustom packet) {
    int freq = packet.readUShort();
    String name = packet.readString();
    int colourid = packet.readUByte();

    RedstoneEther.get(false).setFreqName(freq, name);
    RedstoneEther.get(false).setFreqColour(freq, colourid);

    sendSetFreqInfoTo(null, freq, name, colourid);
}
 
Example 10
Source File: TileFrequencyOwner.java    From EnderStorage with MIT License 4 votes vote down vote up
public void handleDescriptionPacket(PacketCustom desc)
{
    freq = desc.readUShort();
    owner = desc.readString();
}
 
Example 11
Source File: NEISPH.java    From NotEnoughItems with MIT License 4 votes vote down vote up
private void handlePropertyChange(EntityPlayerMP sender, PacketCustom packet) {
    String name = packet.readString();
    if (NEIServerConfig.canPlayerPerformAction(sender.getCommandSenderName(), name))
        NEIServerConfig.disableAction(sender.dimension, name, packet.readBoolean());
}
 
Example 12
Source File: NEIServerPacketHandler.java    From NotEnoughItems with MIT License 3 votes vote down vote up
/**
 * Handles when a client disables an action.
 * For Example, Noon, Weather.
 * If the player is permitted to change the action, a packet is then relayed to all clients in the dimension.
 *
 * @param sender The player that changed the actions state.
 * @param packet The packet containing data.
 */
private void handleActionDisableStateChange(EntityPlayerMP sender, PacketCustom packet) {
    String name = packet.readString();
    if (NEIServerConfig.canPlayerPerformAction(sender.getName(), name)) {
        NEIServerConfig.setDisableActionState(sender.dimension, name, packet.readBoolean());
    }
}