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

The following examples show how to use codechicken.lib.packet.PacketCustom#writeByte() . 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: TileTranslocator.java    From Translocators with MIT License 6 votes vote down vote up
@Override
public Packet getDescriptionPacket()
{
    PacketCustom packet = new PacketCustom(TranslocatorSPH.channel, 1);
    packet.writeCoord(xCoord, yCoord, zCoord);
    
    int attachmask = 0;
    for(int i = 0; i < 6; i++)
        if(attachments[i] != null)
            attachmask|= 1<<i;
    
    packet.writeByte(attachmask);
    for(Attachment a : attachments)
        if(a != null)
            a.write(packet);
    
    return packet.toPacket();
}
 
Example 2
Source File: ContainerSynchronised.java    From CodeChickenCore with MIT License 6 votes vote down vote up
@Override
public final void detectAndSendChanges()
{
    super.detectAndSendChanges();
    
    for(int i = 0; i < syncVars.size(); i++)
    {
        IContainerSyncVar var = syncVars.get(i);
        if(var.changed())
        {
            PacketCustom packet = createSyncPacket();
            packet.writeByte(i);
            var.writeChange(packet);
            sendContainerPacket(packet);
            var.reset();
        }
    }
}
 
Example 3
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 4
Source File: TileItemTranslocator.java    From Translocators with MIT License 5 votes vote down vote up
private void sendTransferPacket(int i, int j, ItemStack add)
{
    PacketCustom packet = new PacketCustom(TranslocatorSPH.channel, 2);
    packet.writeCoord(xCoord, yCoord, zCoord);
    packet.writeByte(i << 4 | j);
    packet.writeItemStack(add);
    packet.sendToChunk(worldObj, xCoord>>4, zCoord>>4);
}
 
Example 5
Source File: TileLiquidTranslocator.java    From Translocators with MIT License 5 votes vote down vote up
private void sendTransferPacket(ArrayList<LiquidTransfer> transfers)
{
    PacketCustom packet = new PacketCustom(TranslocatorSPH.channel, 2);
    packet.writeCoord(xCoord, yCoord, zCoord);
    packet.writeByte(transfers.size());
    for(LiquidTransfer t : transfers)
    {
        packet.writeByte(t.key);
        packet.writeFluidStack(t.liquid);
    }
    packet.sendToChunk(worldObj, xCoord>>4, zCoord>>4);
}
 
Example 6
Source File: ContainerSynchronised.java    From CodeChickenCore with MIT License 5 votes vote down vote up
@Override
public void sendContainerAndContentsToPlayer(Container container, List<ItemStack> list, List<EntityPlayerMP> playerCrafters)
{
    super.sendContainerAndContentsToPlayer(container, list, playerCrafters);
    for(int i = 0; i < syncVars.size(); i++)
    {
        IContainerSyncVar var = syncVars.get(i);
        PacketCustom packet = createSyncPacket();
        packet.writeByte(i);
        var.writeChange(packet);
        var.reset();
        for(EntityPlayerMP player : playerCrafters)
            packet.sendToPlayer(player);
    }
}
 
Example 7
Source File: ContainerPotionCreator.java    From NotEnoughItems with MIT License 5 votes vote down vote up
public void setPotionEffect(int effectID, int duration, int amplifier) {
    PacketCustom packet = NEICPH.createContainerPacket();
    packet.writeBoolean(true);
    packet.writeByte(effectID);
    packet.writeInt(duration);
    packet.writeByte(amplifier);
    packet.sendToServer();
}
 
Example 8
Source File: WRCoreSPH.java    From WirelessRedstone with MIT License 5 votes vote down vote up
public static void sendSharedFrequencyTo(EntityPlayer player, int freq) {
    PacketCustom packet = new PacketCustom(WirelessRedstoneCore.channel, 2);
    packet.writeShort(freq);
    packet.writeByte(2);

    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: WRAddonSPH.java    From WirelessRedstone with MIT License 5 votes vote down vote up
public static void sendMapInfoTo(EntityPlayer player, int mapno, MapData mapdata) {
    PacketCustom packet = new PacketCustom(WirelessRedstoneCore.channel, 56);
    packet.writeShort((short) mapno);
    packet.writeInt(mapdata.xCenter);
    packet.writeInt(mapdata.zCenter);
    packet.writeByte(mapdata.scale);

    packet.sendToPlayer(player);
}
 
Example 11
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 12
Source File: WRCoreSPH.java    From WirelessRedstone with MIT License 5 votes vote down vote up
public static void sendPublicFrequencyTo(EntityPlayer player, int freq) {
    PacketCustom packet = new PacketCustom(WirelessRedstoneCore.channel, 2);
    packet.writeShort(freq);
    packet.writeByte(1);

    packet.sendToPlayer(player);
}
 
Example 13
Source File: ContainerItemTranslocator.java    From Translocators with MIT License 5 votes vote down vote up
@Override
public void sendLargeStack(ItemStack stack, int slot, List<EntityPlayerMP> players) {
    PacketCustom packet = new PacketCustom(TranslocatorSPH.channel, 5);
    packet.writeByte(slot);
    packet.writeItemStack(stack, true);

    for (EntityPlayerMP player : players)
        packet.sendToPlayer(player);
}
 
Example 14
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 15
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 16
Source File: NEIClientPacketHandler.java    From NotEnoughItems with MIT License 5 votes vote down vote up
/**
 * Notifies the server about an enchantment being modified inside NEI's enchantment gui.
 *
 * @param enchID The Enchantment ID.
 * @param level  The Enchantments level.
 * @param add    If the enchantment is being added or removed.
 */
public static void sendModifyEnchantment(int enchID, int level, boolean add) {
    PacketCustom packet = new PacketCustom(channel, 22);
    packet.writeByte(enchID);
    packet.writeByte(level);
    packet.writeBoolean(add);
    packet.sendToServer();
}
 
Example 17
Source File: NEICPH.java    From NotEnoughItems with MIT License 4 votes vote down vote up
public static void sendSetTime(int hour) {
    PacketCustom packet = new PacketCustom(channel, 7);
    packet.writeByte(hour);
    packet.sendToServer();
}
 
Example 18
Source File: TileEnderTank.java    From EnderStorage with MIT License 4 votes vote down vote up
@Override
public void writeToPacket(PacketCustom packet) {
    packet.writeByte(rotation);
    packet.writeFluidStack(liquid_state.s_liquid);
    packet.writeBoolean(pressure_state.a_pressure);
}
 
Example 19
Source File: ContainerPotionCreator.java    From NotEnoughItems with MIT License 4 votes vote down vote up
public void removePotionEffect(int effectID) {
    PacketCustom packet = NEICPH.createContainerPacket();
    packet.writeBoolean(false);
    packet.writeByte(effectID);
    packet.sendToServer();
}
 
Example 20
Source File: NEIClientPacketHandler.java    From NotEnoughItems with MIT License 4 votes vote down vote up
/**
 * Sent to the server to change the time.
 */
public static void sendSetTime(int hour) {
    PacketCustom packet = new PacketCustom(channel, 7);
    packet.writeByte(hour);
    packet.sendToServer();
}