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

The following examples show how to use codechicken.lib.packet.PacketCustom#writeInt() . 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: PlayerChunkViewerTracker.java    From ChickenChunks with MIT License 6 votes vote down vote up
@SuppressWarnings("unchecked")
public void loadDimension(WorldServer world)
{
    PacketCustom packet = new PacketCustom(channel, 2).compress();
    int dim = CommonUtils.getDimension(world);
    packet.writeInt(dim);
            
    List<Chunk> allchunks = world.theChunkProviderServer.loadedChunks;        
    packet.writeInt(allchunks.size());
    for(Chunk chunk : allchunks)
    {
        packet.writeInt(chunk.xPosition);
        packet.writeInt(chunk.zPosition);
    }
    
    Map<Ticket, Collection<ChunkCoordIntPair>> tickets = ForgeChunkManager.getPersistentChunksFor(world).inverse().asMap();
    packet.writeInt(tickets.size());
    for(Entry<Ticket, Collection<ChunkCoordIntPair>> entry : tickets.entrySet())
        writeTicketToPacket(packet, entry.getKey(), entry.getValue());
    
    packet.sendToPlayer(owner);
}
 
Example 3
Source File: WRAddonSPH.java    From WirelessRedstone with MIT License 6 votes vote down vote up
public static void sendTrackerUpdatePacketTo(EntityPlayerMP player, EntityWirelessTracker tracker) {
    PacketCustom packet = new PacketCustom(WirelessRedstoneCore.channel, 60);
    packet.writeInt(tracker.getEntityId());
    packet.writeShort(tracker.freq);
    packet.writeBoolean(tracker.isAttachedToEntity());
    if (tracker.isAttachedToEntity()) {
        packet.writeInt(tracker.attachedEntity.getEntityId());
        packet.writeFloat(tracker.attachedX);
        packet.writeFloat(tracker.attachedY);
        packet.writeFloat(tracker.attachedZ);
        packet.writeFloat(tracker.attachedYaw);
    } else {
        packet.writeFloat((float) tracker.posX);
        packet.writeFloat((float) tracker.posY);
        packet.writeFloat((float) tracker.posZ);
        packet.writeFloat((float) tracker.motionX);
        packet.writeFloat((float) tracker.motionY);
        packet.writeFloat((float) tracker.motionZ);
        packet.writeShort(tracker.attachmentCounter);
        packet.writeBoolean(tracker.item);
    }

    packet.sendToPlayer(player);
}
 
Example 4
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 5
Source File: WRAddonSPH.java    From WirelessRedstone with MIT License 5 votes vote down vote up
public static void sendKillREP(EntityREP entityREP) {
    PacketCustom packet = new PacketCustom(WirelessRedstoneCore.channel, 59);
    packet.writeBoolean(false);
    packet.writeInt(entityREP.getEntityId());

    packet.sendToChunk(entityREP.worldObj, (int) entityREP.posX >> 4, (int) entityREP.posZ >> 4);
}
 
Example 6
Source File: WRAddonSPH.java    From WirelessRedstone with MIT License 5 votes vote down vote up
public static void sendSpawnREP(EntityREP activeREP) {
    PacketCustom packet = new PacketCustom(WirelessRedstoneCore.channel, 59);
    packet.writeBoolean(true);
    packet.writeInt(activeREP.getEntityId());
    packet.writeInt(activeREP.shootingEntity.getEntityId());

    packet.sendToChunk(activeREP.worldObj, (int) activeREP.posX >> 4, (int) activeREP.posZ >> 4);
}
 
Example 7
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 8
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 9
Source File: WRAddonSPH.java    From WirelessRedstone with MIT License 5 votes vote down vote up
public static void sendRemoveTrackerTo(EntityPlayerMP player, EntityWirelessTracker tracker) {
    PacketCustom packet = new PacketCustom(WirelessRedstoneCore.channel, 61);
    packet.writeBoolean(false);
    packet.writeInt(tracker.getEntityId());

    packet.sendToPlayer(player);
}
 
Example 10
Source File: NEIServerPacketHandler.java    From NotEnoughItems with MIT License 5 votes vote down vote up
/**
 * Adds a tracked MagnetItem on the client.
 *
 * @param player Player to send to.
 * @param item   EntityItem to send.
 */
public static void sendTrackedMagnetItem(EntityPlayerMP player, EntityItem item) {
    PacketCustom packet = new PacketCustom(channel, 13);
    packet.writeInt(item.getEntityId());

    packet.sendToPlayer(player);
}
 
Example 11
Source File: PlayerChunkViewerTracker.java    From ChickenChunks with MIT License 5 votes vote down vote up
public void addTicket(int dimension, Ticket ticket)
{
    PacketCustom packet = new PacketCustom(channel, 8);
    packet.writeInt(dimension);
    writeTicketToPacket(packet, ticket, ticket.getChunkList());
    
    packet.sendToPlayer(owner);
}
 
Example 12
Source File: PlayerChunkViewerTracker.java    From ChickenChunks with MIT License 5 votes vote down vote up
public void sendTicketChange(TicketChange change)
{
    int ticketID = manager.ticketIDs.get(change.ticket);
    if(!knownTickets.contains(ticketID))
        addTicket(change.dimension, change.ticket);
    
    PacketCustom packet = new PacketCustom(channel, 5);
    packet.writeInt(change.dimension);
    packet.writeInt(ticketID);
    packet.writeInt(change.chunk.chunkXPos);
    packet.writeInt(change.chunk.chunkZPos);
    packet.writeBoolean(change.force);
    
    packet.sendToPlayer(owner);
}
 
Example 13
Source File: PlayerChunkViewerTracker.java    From ChickenChunks with MIT License 5 votes vote down vote up
public void sendChunkChange(ChunkChange change)
{
    PacketCustom packet = new PacketCustom(channel, 4);
    packet.writeInt(change.dimension);
    packet.writeInt(change.chunk.chunkXPos);
    packet.writeInt(change.chunk.chunkZPos);
    packet.writeBoolean(change.add);

    packet.sendToPlayer(owner);
}
 
Example 14
Source File: PlayerChunkViewerTracker.java    From ChickenChunks with MIT License 5 votes vote down vote up
public void unloadDimension(int dim)
{
    PacketCustom packet = new PacketCustom(channel, 3);
    packet.writeInt(dim);
    
    packet.sendToPlayer(owner);
}
 
Example 15
Source File: ContainerPotionCreator.java    From NotEnoughItems with MIT License 5 votes vote down vote up
public void setPotionEffect(Potion potion, int duration, int amplifier) {
    PacketCustom packet = NEIClientPacketHandler.createContainerPacket();
    packet.writeBoolean(true);
    packet.writeByte(Potion.getIdFromPotion(potion));
    packet.writeInt(duration);
    packet.writeByte(amplifier);
    packet.sendToServer();
}
 
Example 16
Source File: WRAddonSPH.java    From WirelessRedstone with MIT License 5 votes vote down vote up
public static void sendThrowTracker(EntityWirelessTracker tracker, EntityPlayer thrower) {
    PacketCustom packet = new PacketCustom(WirelessRedstoneCore.channel, 61);
    packet.writeBoolean(true);
    packet.writeInt(tracker.getEntityId());
    packet.writeInt(thrower.getEntityId());
    packet.writeShort(tracker.freq);

    packet.sendToChunk(thrower.worldObj, (int) thrower.posX >> 4, (int) thrower.posZ >> 4);
}
 
Example 17
Source File: NEISPH.java    From NotEnoughItems with MIT License 4 votes vote down vote up
public static void sendAddMagneticItemTo(EntityPlayerMP player, EntityItem item) {
    PacketCustom packet = new PacketCustom(channel, 13);
    packet.writeInt(item.getEntityId());

    packet.sendToPlayer(player);
}
 
Example 18
Source File: IntegerSync.java    From CodeChickenCore with MIT License 4 votes vote down vote up
@Override
public void writeChange(PacketCustom packet)
{
    packet.writeInt(getValue());
}
 
Example 19
Source File: NEICPH.java    From NotEnoughItems with MIT License 4 votes vote down vote up
public static void sendCreativeScroll(int steps) {
    PacketCustom packet = new PacketCustom(channel, 14);
    packet.writeInt(steps);
    packet.sendToServer();
}
 
Example 20
Source File: NEIClientPacketHandler.java    From NotEnoughItems with MIT License 4 votes vote down vote up
public static void sendCreativeScroll(int steps) {
    PacketCustom packet = new PacketCustom(channel, 14);
    packet.writeInt(steps);
    packet.sendToServer();
}