Java Code Examples for cpw.mods.fml.common.network.PacketDispatcher#sendPacketToAllInDimension()

The following examples show how to use cpw.mods.fml.common.network.PacketDispatcher#sendPacketToAllInDimension() . 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: MoCServerPacketHandler.java    From mocreaturesdev with GNU General Public License v3.0 6 votes vote down vote up
/**
 * server sends the Appear horse command to each client
 * 
 * @param ID
 *            : Entity Horse ID
 * @param dimension
 *            : world dimension (this.worldObj.provider.dimensionId);)
 */
public static void sendAppearPacket(int ID, int dimension)
{
    ByteArrayOutputStream bytes = new ByteArrayOutputStream();
    DataOutputStream data = new DataOutputStream(bytes);
    try
    {
        data.writeInt(Integer.valueOf(3));
        data.writeInt(Integer.valueOf(ID));
    }
    catch (IOException e)
    {
        e.printStackTrace();
    }
    Packet250CustomPayload packet = new Packet250CustomPayload();
    packet.channel = "MoCreatures";
    packet.data = bytes.toByteArray();
    packet.length = packet.data.length;

    PacketDispatcher.sendPacketToAllInDimension(packet, dimension);
}
 
Example 2
Source File: MoCServerPacketHandler.java    From mocreaturesdev with GNU General Public License v3.0 6 votes vote down vote up
/**
 * server sends the Appear vanish command to each client
 * 
 * @param ID
 *            : Entity Horse ID
 * @param dimension
 *            : world dimension (this.worldObj.provider.dimensionId);)
 */
public static void sendVanishPacket(int ID, int dimension)
{
    ByteArrayOutputStream bytes = new ByteArrayOutputStream();
    DataOutputStream data = new DataOutputStream(bytes);
    try
    {
        data.writeInt(Integer.valueOf(4));
        data.writeInt(Integer.valueOf(ID));
    }
    catch (IOException e)
    {
        e.printStackTrace();
    }
    Packet250CustomPayload packet = new Packet250CustomPayload();
    packet.channel = "MoCreatures";
    packet.data = bytes.toByteArray();
    packet.length = packet.data.length;

    PacketDispatcher.sendPacketToAllInDimension(packet, dimension);

}
 
Example 3
Source File: MoCServerPacketHandler.java    From mocreaturesdev with GNU General Public License v3.0 6 votes vote down vote up
/**
 * server sends the Ogre explode command to each client
 * 
 * @param ID
 *            : Ogre entity ID
 * @param dimension
 *            : world dimension (this.worldObj.provider.dimensionId);)
 */
public static void sendExplodePacket(int ID, int dimension)
{
    ByteArrayOutputStream bytes = new ByteArrayOutputStream();
    DataOutputStream data = new DataOutputStream(bytes);
    try
    {
        data.writeInt(Integer.valueOf(5));
        data.writeInt(Integer.valueOf(ID));
    }
    catch (IOException e)
    {
        e.printStackTrace();
    }
    Packet250CustomPayload packet = new Packet250CustomPayload();
    packet.channel = "MoCreatures";
    packet.data = bytes.toByteArray();
    packet.length = packet.data.length;

    PacketDispatcher.sendPacketToAllInDimension(packet, dimension);

}
 
Example 4
Source File: MoCServerPacketHandler.java    From mocreaturesdev with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Used to synchronize Zebra shuffling counters/animations
 * 
 * @param ID
 *            : Entity Horse (Zebra) ID
 * @param dimension
 *            : world dimension (this.worldObj.provider.dimensionId);
 */
public static void sendShufflePacket(int ID, int dimension)
{
    ByteArrayOutputStream bytes = new ByteArrayOutputStream();
    DataOutputStream data = new DataOutputStream(bytes);
    try
    {
        data.writeInt(Integer.valueOf(8));
        data.writeInt(Integer.valueOf(ID));
    }
    catch (IOException e)
    {
        e.printStackTrace();
    }
    Packet250CustomPayload packet = new Packet250CustomPayload();
    packet.channel = "MoCreatures";
    packet.data = bytes.toByteArray();
    packet.length = packet.data.length;

    PacketDispatcher.sendPacketToAllInDimension(packet, dimension);

}
 
Example 5
Source File: MoCServerPacketHandler.java    From mocreaturesdev with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Stops the shuffle animation in Client Zebras
 * 
 * @param ID
 * @param dimension
 */
public static void sendStopShuffle(int ID, int dimension)
{
    ByteArrayOutputStream bytes = new ByteArrayOutputStream();
    DataOutputStream data = new DataOutputStream(bytes);
    try
    {
        data.writeInt(Integer.valueOf(9));
        data.writeInt(Integer.valueOf(ID));
    }
    catch (IOException e)
    {
        e.printStackTrace();
    }
    Packet250CustomPayload packet = new Packet250CustomPayload();
    packet.channel = "MoCreatures";
    packet.data = bytes.toByteArray();
    packet.length = packet.data.length;

    PacketDispatcher.sendPacketToAllInDimension(packet, dimension);

}
 
Example 6
Source File: MoCServerPacketHandler.java    From mocreaturesdev with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Used for heart breeding animation
 * 
 * @param ID
 * @param dimension
 */
public static void sendHeartPacket(int ID, int dimension)
{
    ByteArrayOutputStream bytes = new ByteArrayOutputStream();
    DataOutputStream data = new DataOutputStream(bytes);
    try
    {
        data.writeInt(Integer.valueOf(10));
        data.writeInt(Integer.valueOf(ID));
    }
    catch (IOException e)
    {
        e.printStackTrace();
    }
    Packet250CustomPayload packet = new Packet250CustomPayload();
    packet.channel = "MoCreatures";
    packet.data = bytes.toByteArray();
    packet.length = packet.data.length;

    PacketDispatcher.sendPacketToAllInDimension(packet, dimension);
}
 
Example 7
Source File: MoCServerPacketHandler.java    From mocreaturesdev with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Used to synchronize the attack animation
 * 
 * @param ID
 * @param dimension
 */
public static void sendAnimationPacket(int ID, int dimension, int animationType)
{
    ByteArrayOutputStream bytes = new ByteArrayOutputStream();
    DataOutputStream data = new DataOutputStream(bytes);
    try
    {
        data.writeInt(Integer.valueOf(11));
        data.writeInt(Integer.valueOf(ID));
        data.writeInt(Integer.valueOf(animationType));
    }
    catch (IOException e)
    {
        e.printStackTrace();
    }
    Packet250CustomPayload packet = new Packet250CustomPayload();
    packet.channel = "MoCreatures";
    packet.data = bytes.toByteArray();
    packet.length = packet.data.length;

    PacketDispatcher.sendPacketToAllInDimension(packet, dimension);
}
 
Example 8
Source File: MoCServerPacketHandler.java    From mocreaturesdev with GNU General Public License v3.0 6 votes vote down vote up
public static void sendAttachedEntity(Entity source, Entity target, int dimension)
{
    ByteArrayOutputStream bytes = new ByteArrayOutputStream();
    DataOutputStream data = new DataOutputStream(bytes);
    try
    {
        data.writeInt(Integer.valueOf(13));
        data.writeInt(Integer.valueOf(source.entityId));
        data.writeInt(Integer.valueOf(target.entityId));
    }
    catch (IOException e)
    {
        e.printStackTrace();
    }
    Packet250CustomPayload packet = new Packet250CustomPayload();
    packet.channel = "MoCreatures";
    packet.data = bytes.toByteArray();
    packet.length = packet.data.length;
    //System.out.println("MOCServerHandler sending packet with sourceId " + source.entityId + ", entityId " + target.entityId);
    PacketDispatcher.sendPacketToAllInDimension(packet, dimension);
}
 
Example 9
Source File: MoCServerPacketHandler.java    From mocreaturesdev with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Used to synchronize the two bytes between server and client Used for the
 * MoCEntityG
 * 
 * @param ID
 *            = entity ID
 * @param dimension
 *            = worldDimension
 * @param slot
 *            = which slot in the array
 * @param value
 *            = the value to pass
 */
public static void sendTwoBytes(int ID, int dimension, byte slot, byte value)
{
    ByteArrayOutputStream bytes = new ByteArrayOutputStream();
    DataOutputStream data = new DataOutputStream(bytes);
    try
    {
        data.writeInt(Integer.valueOf(14));
        data.writeInt(Integer.valueOf(ID));
        data.writeByte(Byte.valueOf(slot));
        data.writeByte(Byte.valueOf(value));
    }
    catch (IOException e)
    {
        e.printStackTrace();
    }
    Packet250CustomPayload packet = new Packet250CustomPayload();
    packet.channel = "MoCreatures";
    packet.data = bytes.toByteArray();
    packet.length = packet.data.length;

    PacketDispatcher.sendPacketToAllInDimension(packet, dimension);
}
 
Example 10
Source File: MoCServerPacketHandler.java    From mocreaturesdev with GNU General Public License v3.0 4 votes vote down vote up
public static void sendNamedEntitySpawn(Entity source, int dimension)
{
    PacketDispatcher.sendPacketToAllInDimension(new Packet20NamedEntitySpawn((EntityPlayer) source), dimension);
}