net.minecraft.network.packet.Packet250CustomPayload Java Examples

The following examples show how to use net.minecraft.network.packet.Packet250CustomPayload. 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 transform horse command to each client
 * 
 * @param ID
 * @param tType
 *            : transformation type
 */
public static void sendTransformPacket(int ID, int tType)
{
    ByteArrayOutputStream bytes = new ByteArrayOutputStream();
    DataOutputStream data = new DataOutputStream(bytes);
    try
    {
        data.writeInt(Integer.valueOf(2));
        data.writeInt(Integer.valueOf(ID));
        data.writeInt(Integer.valueOf(tType));
    }
    catch (IOException e)
    {
        e.printStackTrace();
    }

    Packet250CustomPayload packet = new Packet250CustomPayload();
    packet.channel = "MoCreatures";
    packet.data = bytes.toByteArray();
    packet.length = packet.data.length;

    //TODO 4FIX

}
 
Example #2
Source File: MoCClientPacketHandler.java    From mocreaturesdev with GNU General Public License v3.0 6 votes vote down vote up
public static void sendEntityDismountPacket() 
{
	ByteArrayOutputStream bytes = new ByteArrayOutputStream();
       DataOutputStream data = new DataOutputStream(bytes);
       try
       {
           data.writeInt(Integer.valueOf(25));
       }
       catch (IOException e)
       {
           e.printStackTrace();
       }

       Packet250CustomPayload packet = new Packet250CustomPayload();
       packet.channel = "MoCreatures";
       packet.data = bytes.toByteArray();
       packet.length = packet.data.length;

       EntityClientPlayerMP player = MoCClientProxy.mc.thePlayer;
       player.sendQueue.addToSendQueue(packet);
	
}
 
Example #3
Source File: MoCClientPacketHandler.java    From mocreaturesdev with GNU General Public License v3.0 6 votes vote down vote up
public static void sendEntityDivePacket()
{
    // client sending entity dive command. 

    ByteArrayOutputStream bytes = new ByteArrayOutputStream();
    DataOutputStream data = new DataOutputStream(bytes);
    try
    {
        data.writeInt(Integer.valueOf(24));
    }
    catch (IOException e)
    {
        e.printStackTrace();
    }

    Packet250CustomPayload packet = new Packet250CustomPayload();
    packet.channel = "MoCreatures";
    packet.data = bytes.toByteArray();
    packet.length = packet.data.length;

    EntityClientPlayerMP player = MoCClientProxy.mc.thePlayer;
    player.sendQueue.addToSendQueue(packet);
}
 
Example #4
Source File: MoCClientPacketHandler.java    From mocreaturesdev with GNU General Public License v3.0 6 votes vote down vote up
public static void sendInstaSpawnPacket(int ID, int number)
{
    // client sending insta spawn command. int ID, int number

    ByteArrayOutputStream bytes = new ByteArrayOutputStream();
    DataOutputStream data = new DataOutputStream(bytes);
    try
    {
        data.writeInt(Integer.valueOf(22));
        data.writeInt(Integer.valueOf(ID));
        data.writeInt(Integer.valueOf(number));
    }
    catch (IOException e)
    {
        e.printStackTrace();
    }

    Packet250CustomPayload packet = new Packet250CustomPayload();
    packet.channel = "MoCreatures";
    packet.data = bytes.toByteArray();
    packet.length = packet.data.length;

    EntityClientPlayerMP player = MoCClientProxy.mc.thePlayer;
    player.sendQueue.addToSendQueue(packet);
}
 
Example #5
Source File: MoCClientPacketHandler.java    From mocreaturesdev with GNU General Public License v3.0 6 votes vote down vote up
public static void sendEntityJumpPacket()
{
    // client sending horse jump command. 

    ByteArrayOutputStream bytes = new ByteArrayOutputStream();
    DataOutputStream data = new DataOutputStream(bytes);
    try
    {
        data.writeInt(Integer.valueOf(21));
    }
    catch (IOException e)
    {
        e.printStackTrace();
    }

    Packet250CustomPayload packet = new Packet250CustomPayload();
    packet.channel = "MoCreatures";
    packet.data = bytes.toByteArray();
    packet.length = packet.data.length;

    EntityClientPlayerMP player = MoCClientProxy.mc.thePlayer;
    //System.out.println("MoCClientPacketHandler sending packet 21 to player " + player.toString());
    player.sendQueue.addToSendQueue(packet);
}
 
Example #6
Source File: MoCServerPacketHandler.java    From mocreaturesdev with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Sends message to player
 * 
 * @param player
 * @param message
 */
public static void sendMsgToPlayer(EntityPlayerMP player, String message)
{
    ByteArrayOutputStream bytes = new ByteArrayOutputStream();
    DataOutputStream data = new DataOutputStream(bytes);
    try
    {
        data.writeInt(Integer.valueOf(15));
        data.writeUTF(message);
    }
    catch (IOException e)
    {
        e.printStackTrace();
    }
    Packet250CustomPayload packet = new Packet250CustomPayload();
    packet.channel = "MoCreatures";
    packet.data = bytes.toByteArray();
    packet.length = packet.data.length;

    PacketDispatcher.sendPacketToPlayer(packet, (Player) player);
}
 
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 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 #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 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 #10
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 #11
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 #12
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 #13
Source File: MoCServerPacketHandler.java    From mocreaturesdev with GNU General Public License v3.0 6 votes vote down vote up
/**
 * 
 * @param player
 * @param entityId
 */
public static void sendNameGUI(EntityPlayerMP player, int entityId)
{
    ByteArrayOutputStream bytes = new ByteArrayOutputStream();
    DataOutputStream data = new DataOutputStream(bytes);
    try
    {
        data.writeInt(Integer.valueOf(7));
        data.writeInt(Integer.valueOf(entityId));
    }
    catch (IOException e)
    {
        e.printStackTrace();
    }
    Packet250CustomPayload packet = new Packet250CustomPayload();
    packet.channel = "MoCreatures";
    packet.data = bytes.toByteArray();
    packet.length = packet.data.length;

    PacketDispatcher.sendPacketToPlayer(packet, (Player) player);
}
 
Example #14
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 #15
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 #16
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 #17
Source File: MoCServerPacketHandler.java    From mocreaturesdev with GNU General Public License v3.0 6 votes vote down vote up
public static void sendStateInfo(EntityPlayer player, int state)
{
    // server sending state info. first packet int: 1 then int state

    ByteArrayOutputStream bytes = new ByteArrayOutputStream();
    DataOutputStream data = new DataOutputStream(bytes);
    try
    {
        data.writeInt(Integer.valueOf(1));
        data.writeInt(Integer.valueOf(state));
    }
    catch (IOException e)
    {
        e.printStackTrace();
    }

    Packet250CustomPayload packet = new Packet250CustomPayload();
    packet.channel = "MoCreatures";
    packet.data = bytes.toByteArray();
    packet.length = packet.data.length;
    PacketDispatcher.sendPacketToPlayer(packet, (Player) player);

}
 
Example #18
Source File: MoCClientPacketHandler.java    From mocreaturesdev with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Packets generated client side
 * 
 */

//-----------client side
public static void sendNameInfo(int entityId, String nameToSet)
{
    // client sending name info. int entityID and string name

    ByteArrayOutputStream bytes = new ByteArrayOutputStream();
    DataOutputStream data = new DataOutputStream(bytes);
    try
    {
        data.writeInt(Integer.valueOf(20));
        data.writeInt(entityId);
        data.writeUTF(nameToSet);
    }
    catch (IOException e)
    {
        e.printStackTrace();
    }

    Packet250CustomPayload packet = new Packet250CustomPayload();
    packet.channel = "MoCreatures";
    packet.data = bytes.toByteArray();
    packet.length = packet.data.length;
    EntityClientPlayerMP player = MoCClientProxy.mc.thePlayer;
    player.sendQueue.addToSendQueue(packet);

    //EntityClientPlayerMP thePlayerMP = (EntityClientPlayerMP)player;
    //thePlayerMP.sendQueue.addToSendQueue(packet);

}
 
Example #19
Source File: MoCClientPacketHandler.java    From mocreaturesdev with GNU General Public License v3.0 5 votes vote down vote up
/**
 * New instaSpawn method with (key) name of entity and number to spawn
 * @param name
 * @param number
 */
public static void sendInstaSpawnPacket(String name, int number)
   {
       // client sending insta spawn command. int ID, int number

	if (name.isEmpty() || number < 1)
	{
		return;
	}
	
       ByteArrayOutputStream bytes = new ByteArrayOutputStream();
       DataOutputStream data = new DataOutputStream(bytes);
       try
       {
           data.writeInt(Integer.valueOf(26));
           data.writeUTF(name);
           data.writeInt(Integer.valueOf(number));
       }
       catch (IOException e)
       {
           e.printStackTrace();
       }

       Packet250CustomPayload packet = new Packet250CustomPayload();
       packet.channel = "MoCreatures";
       packet.data = bytes.toByteArray();
       packet.length = packet.data.length;

       EntityClientPlayerMP player = MoCClientProxy.mc.thePlayer;
       player.sendQueue.addToSendQueue(packet);
   }
 
Example #20
Source File: PacketWrapper.java    From HexxitGear with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Create a new Packet250CustomPayload and encode the Objects you provide in it
 *
 * @param channel String name of the packet channel to use
 * @param packetID Integer value to be prefixed to the data array so you can distinguish packets
 * @param input Object Array to be encoded to the packet byte array.
 */
public static Packet250CustomPayload createPacket(String channel, int packetID, Object[] input)
{
    ByteArrayOutputStream bytes = new ByteArrayOutputStream();
    DataOutputStream data = new DataOutputStream(bytes);
    try
    {
        data.write(packetID);

        if (input != null)
        {
            for (Object obj : input)
            {
                writeObjectToStream(obj, data);
            }
        }

    }
    catch (IOException e)
    {
        e.printStackTrace();
    }

    Packet250CustomPayload packet = new Packet250CustomPayload();
    packet.channel = channel;
    packet.data = bytes.toByteArray();
    packet.length = packet.data.length;

    return packet;
}