Fixed packet functions not static
This commit is contained in:
parent
717ef201fd
commit
5bc0b50219
1 changed files with 82 additions and 72 deletions
|
@ -5,7 +5,6 @@ package resonantinduction;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.network.INetworkManager;
|
import net.minecraft.network.INetworkManager;
|
||||||
|
@ -20,7 +19,6 @@ import com.google.common.io.ByteStreams;
|
||||||
import cpw.mods.fml.common.network.IPacketHandler;
|
import cpw.mods.fml.common.network.IPacketHandler;
|
||||||
import cpw.mods.fml.common.network.PacketDispatcher;
|
import cpw.mods.fml.common.network.PacketDispatcher;
|
||||||
import cpw.mods.fml.common.network.Player;
|
import cpw.mods.fml.common.network.Player;
|
||||||
import cpw.mods.fml.relauncher.Side;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author AidanBrady
|
* @author AidanBrady
|
||||||
|
@ -37,7 +35,8 @@ public class PacketHandler implements IPacketHandler
|
||||||
EntityPlayer entityplayer = (EntityPlayer) player;
|
EntityPlayer entityplayer = (EntityPlayer) player;
|
||||||
World world = entityplayer.worldObj;
|
World world = entityplayer.worldObj;
|
||||||
|
|
||||||
try {
|
try
|
||||||
|
{
|
||||||
int packetType = dataStream.readInt();
|
int packetType = dataStream.readInt();
|
||||||
|
|
||||||
if (packetType == PacketType.TILE.ordinal())
|
if (packetType == PacketType.TILE.ordinal())
|
||||||
|
@ -53,13 +52,17 @@ public class PacketHandler implements IPacketHandler
|
||||||
((IPacketReceiver) tileEntity).handle(dataStream);
|
((IPacketReceiver) tileEntity).handle(dataStream);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch(Exception e) {}
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void encode(Object[] dataValues, DataOutputStream output)
|
public static void encode(Object[] dataValues, DataOutputStream output)
|
||||||
{
|
{
|
||||||
try {
|
try
|
||||||
|
{
|
||||||
for (Object data : dataValues)
|
for (Object data : dataValues)
|
||||||
{
|
{
|
||||||
if (data instanceof Integer)
|
if (data instanceof Integer)
|
||||||
|
@ -87,31 +90,38 @@ public class PacketHandler implements IPacketHandler
|
||||||
output.writeByte((Byte) data);
|
output.writeByte((Byte) data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch(Exception e) {}
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendTileEntityPacketToServer(TileEntity tileEntity, Object... dataValues)
|
public static void sendTileEntityPacketToServer(TileEntity tileEntity, Object... dataValues)
|
||||||
{
|
{
|
||||||
PacketDispatcher.sendPacketToServer(getTileEntityPacket(tileEntity, dataValues));
|
PacketDispatcher.sendPacketToServer(getTileEntityPacket(tileEntity, dataValues));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendTileEntityPacketToClients(TileEntity tileEntity, Object... dataValues)
|
public static void sendTileEntityPacketToClients(TileEntity tileEntity, Object... dataValues)
|
||||||
{
|
{
|
||||||
PacketDispatcher.sendPacketToAllPlayers(getTileEntityPacket(tileEntity, dataValues));
|
PacketDispatcher.sendPacketToAllPlayers(getTileEntityPacket(tileEntity, dataValues));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Packet250CustomPayload getTileEntityPacket(TileEntity tileEntity, Object... dataValues)
|
public static Packet250CustomPayload getTileEntityPacket(TileEntity tileEntity, Object... dataValues)
|
||||||
{
|
{
|
||||||
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
|
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
|
||||||
DataOutputStream data = new DataOutputStream(bytes);
|
DataOutputStream data = new DataOutputStream(bytes);
|
||||||
|
|
||||||
try {
|
try
|
||||||
|
{
|
||||||
data.writeInt(tileEntity.xCoord);
|
data.writeInt(tileEntity.xCoord);
|
||||||
data.writeInt(tileEntity.yCoord);
|
data.writeInt(tileEntity.yCoord);
|
||||||
data.writeInt(tileEntity.zCoord);
|
data.writeInt(tileEntity.zCoord);
|
||||||
|
|
||||||
encode(dataValues, data);
|
encode(dataValues, data);
|
||||||
} catch(Exception e) {}
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
Packet250CustomPayload packet = new Packet250CustomPayload();
|
Packet250CustomPayload packet = new Packet250CustomPayload();
|
||||||
packet.channel = ResonantInduction.CHANNEL;
|
packet.channel = ResonantInduction.CHANNEL;
|
||||||
|
|
Loading…
Reference in a new issue