Better packet logging, specifically for the more CPU intensive packets
This commit is contained in:
parent
838ad33756
commit
ace9dec4df
3 changed files with 19 additions and 15 deletions
|
@ -270,6 +270,14 @@ public class PacketHandler
|
|||
}
|
||||
}
|
||||
|
||||
public static void log(String log)
|
||||
{
|
||||
if(general.logPackets)
|
||||
{
|
||||
System.out.println("[Mekanism] " + log);
|
||||
}
|
||||
}
|
||||
|
||||
public static EntityPlayer getPlayer(MessageContext context)
|
||||
{
|
||||
return Mekanism.proxy.getPlayer(context);
|
||||
|
@ -283,11 +291,6 @@ public class PacketHandler
|
|||
public void sendTo(IMessage message, EntityPlayerMP player)
|
||||
{
|
||||
netHandler.sendTo(message, player);
|
||||
|
||||
if(general.logPackets)
|
||||
{
|
||||
System.out.println("[Mekanism] Sending '" + message + "' packet to " + player.getCommandSenderName());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -299,11 +302,6 @@ public class PacketHandler
|
|||
public void sendToAllAround(IMessage message, NetworkRegistry.TargetPoint point)
|
||||
{
|
||||
netHandler.sendToAllAround(message, point);
|
||||
|
||||
if(general.logPackets)
|
||||
{
|
||||
System.out.println("[Mekanism] Sending '" + message + "' packet about target point " + point.x + ", " + point.y + ", " + point.z + ", dim=" + point.dimension + ", range=" + point.range);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -314,11 +312,6 @@ public class PacketHandler
|
|||
public void sendToDimension(IMessage message, int dimensionId)
|
||||
{
|
||||
netHandler.sendToDimension(message, dimensionId);
|
||||
|
||||
if(general.logPackets)
|
||||
{
|
||||
System.out.println("[Mekanism] Sending '" + message + "' packet to dimension " + dimensionId);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -58,6 +58,8 @@ public class PacketTileEntity implements IMessageHandler<TileEntityMessage, IMes
|
|||
dataStream.writeInt(coord4D.yCoord);
|
||||
dataStream.writeInt(coord4D.zCoord);
|
||||
dataStream.writeInt(coord4D.dimensionId);
|
||||
|
||||
PacketHandler.log("Sending TileEntity packet from coordinate " + coord4D);
|
||||
|
||||
PacketHandler.encode(new Object[] {parameters}, dataStream);
|
||||
}
|
||||
|
|
|
@ -48,6 +48,7 @@ public class PacketTransmitterUpdate implements IMessageHandler<TransmitterUpdat
|
|||
DynamicNetwork network = transmitter.hasTransmitterNetwork() && !message.newNetwork ? transmitter.getTransmitterNetwork() : transmitter.createEmptyNetwork();
|
||||
network.register();
|
||||
transmitter.setTransmitterNetwork(network);
|
||||
|
||||
for(Coord4D coord : message.transmitterCoords)
|
||||
{
|
||||
TileEntity tile = coord.getTileEntity(player.worldObj);
|
||||
|
@ -57,6 +58,7 @@ public class PacketTransmitterUpdate implements IMessageHandler<TransmitterUpdat
|
|||
((ITransmitterTile)tile).getTransmitter().setTransmitterNetwork(network);
|
||||
}
|
||||
}
|
||||
|
||||
network.updateCapacity();
|
||||
}
|
||||
}
|
||||
|
@ -67,6 +69,7 @@ public class PacketTransmitterUpdate implements IMessageHandler<TransmitterUpdat
|
|||
if(tileEntity instanceof ITransmitterTile)
|
||||
{
|
||||
IGridTransmitter transmitter = ((ITransmitterTile)tileEntity).getTransmitter();
|
||||
|
||||
if(transmitter.hasTransmitterNetwork() && transmitter.getTransmissionType() == TransmissionType.ENERGY)
|
||||
{
|
||||
((IGridTransmitter<EnergyAcceptorWrapper, EnergyNetwork>)transmitter).getTransmitterNetwork().clientEnergyScale = message.power;
|
||||
|
@ -80,6 +83,7 @@ public class PacketTransmitterUpdate implements IMessageHandler<TransmitterUpdat
|
|||
if(tileEntity instanceof ITransmitterTile)
|
||||
{
|
||||
IGridTransmitter transmitter = ((ITransmitterTile)tileEntity).getTransmitter();
|
||||
|
||||
if(transmitter.hasTransmitterNetwork() && transmitter.getTransmissionType() == TransmissionType.GAS)
|
||||
{
|
||||
GasNetwork net = ((IGridTransmitter<IGasHandler, GasNetwork>)transmitter).getTransmitterNetwork();
|
||||
|
@ -101,6 +105,7 @@ public class PacketTransmitterUpdate implements IMessageHandler<TransmitterUpdat
|
|||
if(tileEntity instanceof ITransmitterTile)
|
||||
{
|
||||
IGridTransmitter transmitter = ((ITransmitterTile)tileEntity).getTransmitter();
|
||||
|
||||
if(transmitter.hasTransmitterNetwork() && ((ITransmitterTile)tileEntity).getTransmitter().getTransmissionType() == TransmissionType.FLUID)
|
||||
{
|
||||
FluidNetwork net = ((IGridTransmitter<IFluidHandler, FluidNetwork>)transmitter).getTransmitterNetwork();
|
||||
|
@ -179,16 +184,20 @@ public class PacketTransmitterUpdate implements IMessageHandler<TransmitterUpdat
|
|||
dataStream.writeInt(coord4D.yCoord);
|
||||
dataStream.writeInt(coord4D.zCoord);
|
||||
dataStream.writeInt(coord4D.dimensionId);
|
||||
|
||||
PacketHandler.log("Sending '" + packetType + "' update message from coordinate " + coord4D);
|
||||
|
||||
switch(packetType)
|
||||
{
|
||||
case UPDATE:
|
||||
dataStream.writeBoolean(newNetwork);
|
||||
dataStream.writeInt(transmittersAdded.size());
|
||||
|
||||
for(IGridTransmitter transmitter : transmittersAdded)
|
||||
{
|
||||
transmitter.coord().write(dataStream);
|
||||
}
|
||||
|
||||
break;
|
||||
case ENERGY:
|
||||
dataStream.writeDouble(power);
|
||||
|
|
Loading…
Reference in a new issue