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

The following examples show how to use codechicken.lib.packet.PacketCustom#writeCoord() . 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: BlockChunkLoader.java    From ChickenChunks with MIT License 6 votes vote down vote up
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9) {
    int meta = world.getBlockMetadata(x, y, z);
    if (meta != 0 || player.isSneaking())
        return false;

    if (!world.isRemote) {
        TileChunkLoader tile = (TileChunkLoader) world.getTileEntity(x, y, z);
        if (tile.owner == null || tile.owner.equals(player.getCommandSenderName()) ||
                ChunkLoaderManager.opInteract() && ServerUtils.isPlayerOP(player.getCommandSenderName())) {
            PacketCustom packet = new PacketCustom(ChunkLoaderSPH.channel, 12);
            packet.writeCoord(x, y, z);
            packet.sendToPlayer(player);
        } else
            player.addChatMessage(new ChatComponentTranslation("chickenchunks.accessdenied"));
    }
    return true;
}
 
Example 2
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 3
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 4
Source File: TileEnderTank.java    From EnderStorage with MIT License 5 votes vote down vote up
@Override
public void sendSyncPacket() {
    PacketCustom packet = new PacketCustom(EnderStorageSPH.channel, 5);
    packet.writeCoord(xCoord, yCoord, zCoord);
    packet.writeFluidStack(s_liquid);
    packet.sendToChunk(worldObj, xCoord >> 4, zCoord >> 4);
}
 
Example 5
Source File: ChunkLoaderCPH.java    From ChickenChunks with MIT License 5 votes vote down vote up
public static void sendShapeChange(TileChunkLoader tile, ChunkLoaderShape shape, int radius) {
    PacketCustom packet = new PacketCustom(channel, 2);
    packet.writeCoord(tile.xCoord, tile.yCoord, tile.zCoord);
    packet.writeByte(shape.ordinal());
    packet.writeByte(radius);
    packet.sendToServer();
}
 
Example 6
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 7
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 8
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 9
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 10
Source File: TileCraftingGrid.java    From Translocators with MIT License 5 votes vote down vote up
@Override
public Packet getDescriptionPacket() {
    PacketCustom packet = new PacketCustom(TranslocatorSPH.channel, 3);
    packet.writeCoord(xCoord, yCoord, zCoord);
    packet.writeByte(rotation);
    for (ItemStack item : items)
        packet.writeItemStack(item);

    return packet.toPacket();
}
 
Example 11
Source File: TileEnderTank.java    From EnderStorage with MIT License 4 votes vote down vote up
private void sendSyncPacket() {
    PacketCustom packet = new PacketCustom(EnderStorageSPH.channel, 6);
    packet.writeCoord(xCoord, yCoord, zCoord);
    packet.writeBoolean(a_pressure);
    packet.sendToChunk(worldObj, xCoord >> 4, zCoord >> 4);
}
 
Example 12
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 13
Source File: WRCoreCPH.java    From WirelessRedstone with MIT License 4 votes vote down vote up
public static void sendSetTileFreq(int x, int y, int z, int freq) {
    PacketCustom packet = new PacketCustom(WirelessRedstoneCore.channel, 1);
    packet.writeCoord(x, y, z);
    packet.writeShort(freq);
    packet.sendToServer();
}