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)
|
public static EntityPlayer getPlayer(MessageContext context)
|
||||||
{
|
{
|
||||||
return Mekanism.proxy.getPlayer(context);
|
return Mekanism.proxy.getPlayer(context);
|
||||||
|
@ -283,11 +291,6 @@ public class PacketHandler
|
||||||
public void sendTo(IMessage message, EntityPlayerMP player)
|
public void sendTo(IMessage message, EntityPlayerMP player)
|
||||||
{
|
{
|
||||||
netHandler.sendTo(message, 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)
|
public void sendToAllAround(IMessage message, NetworkRegistry.TargetPoint point)
|
||||||
{
|
{
|
||||||
netHandler.sendToAllAround(message, 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)
|
public void sendToDimension(IMessage message, int dimensionId)
|
||||||
{
|
{
|
||||||
netHandler.sendToDimension(message, dimensionId);
|
netHandler.sendToDimension(message, dimensionId);
|
||||||
|
|
||||||
if(general.logPackets)
|
|
||||||
{
|
|
||||||
System.out.println("[Mekanism] Sending '" + message + "' packet to dimension " + dimensionId);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -59,6 +59,8 @@ public class PacketTileEntity implements IMessageHandler<TileEntityMessage, IMes
|
||||||
dataStream.writeInt(coord4D.zCoord);
|
dataStream.writeInt(coord4D.zCoord);
|
||||||
dataStream.writeInt(coord4D.dimensionId);
|
dataStream.writeInt(coord4D.dimensionId);
|
||||||
|
|
||||||
|
PacketHandler.log("Sending TileEntity packet from coordinate " + coord4D);
|
||||||
|
|
||||||
PacketHandler.encode(new Object[] {parameters}, dataStream);
|
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();
|
DynamicNetwork network = transmitter.hasTransmitterNetwork() && !message.newNetwork ? transmitter.getTransmitterNetwork() : transmitter.createEmptyNetwork();
|
||||||
network.register();
|
network.register();
|
||||||
transmitter.setTransmitterNetwork(network);
|
transmitter.setTransmitterNetwork(network);
|
||||||
|
|
||||||
for(Coord4D coord : message.transmitterCoords)
|
for(Coord4D coord : message.transmitterCoords)
|
||||||
{
|
{
|
||||||
TileEntity tile = coord.getTileEntity(player.worldObj);
|
TileEntity tile = coord.getTileEntity(player.worldObj);
|
||||||
|
@ -57,6 +58,7 @@ public class PacketTransmitterUpdate implements IMessageHandler<TransmitterUpdat
|
||||||
((ITransmitterTile)tile).getTransmitter().setTransmitterNetwork(network);
|
((ITransmitterTile)tile).getTransmitter().setTransmitterNetwork(network);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
network.updateCapacity();
|
network.updateCapacity();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -67,6 +69,7 @@ public class PacketTransmitterUpdate implements IMessageHandler<TransmitterUpdat
|
||||||
if(tileEntity instanceof ITransmitterTile)
|
if(tileEntity instanceof ITransmitterTile)
|
||||||
{
|
{
|
||||||
IGridTransmitter transmitter = ((ITransmitterTile)tileEntity).getTransmitter();
|
IGridTransmitter transmitter = ((ITransmitterTile)tileEntity).getTransmitter();
|
||||||
|
|
||||||
if(transmitter.hasTransmitterNetwork() && transmitter.getTransmissionType() == TransmissionType.ENERGY)
|
if(transmitter.hasTransmitterNetwork() && transmitter.getTransmissionType() == TransmissionType.ENERGY)
|
||||||
{
|
{
|
||||||
((IGridTransmitter<EnergyAcceptorWrapper, EnergyNetwork>)transmitter).getTransmitterNetwork().clientEnergyScale = message.power;
|
((IGridTransmitter<EnergyAcceptorWrapper, EnergyNetwork>)transmitter).getTransmitterNetwork().clientEnergyScale = message.power;
|
||||||
|
@ -80,6 +83,7 @@ public class PacketTransmitterUpdate implements IMessageHandler<TransmitterUpdat
|
||||||
if(tileEntity instanceof ITransmitterTile)
|
if(tileEntity instanceof ITransmitterTile)
|
||||||
{
|
{
|
||||||
IGridTransmitter transmitter = ((ITransmitterTile)tileEntity).getTransmitter();
|
IGridTransmitter transmitter = ((ITransmitterTile)tileEntity).getTransmitter();
|
||||||
|
|
||||||
if(transmitter.hasTransmitterNetwork() && transmitter.getTransmissionType() == TransmissionType.GAS)
|
if(transmitter.hasTransmitterNetwork() && transmitter.getTransmissionType() == TransmissionType.GAS)
|
||||||
{
|
{
|
||||||
GasNetwork net = ((IGridTransmitter<IGasHandler, GasNetwork>)transmitter).getTransmitterNetwork();
|
GasNetwork net = ((IGridTransmitter<IGasHandler, GasNetwork>)transmitter).getTransmitterNetwork();
|
||||||
|
@ -101,6 +105,7 @@ public class PacketTransmitterUpdate implements IMessageHandler<TransmitterUpdat
|
||||||
if(tileEntity instanceof ITransmitterTile)
|
if(tileEntity instanceof ITransmitterTile)
|
||||||
{
|
{
|
||||||
IGridTransmitter transmitter = ((ITransmitterTile)tileEntity).getTransmitter();
|
IGridTransmitter transmitter = ((ITransmitterTile)tileEntity).getTransmitter();
|
||||||
|
|
||||||
if(transmitter.hasTransmitterNetwork() && ((ITransmitterTile)tileEntity).getTransmitter().getTransmissionType() == TransmissionType.FLUID)
|
if(transmitter.hasTransmitterNetwork() && ((ITransmitterTile)tileEntity).getTransmitter().getTransmissionType() == TransmissionType.FLUID)
|
||||||
{
|
{
|
||||||
FluidNetwork net = ((IGridTransmitter<IFluidHandler, FluidNetwork>)transmitter).getTransmitterNetwork();
|
FluidNetwork net = ((IGridTransmitter<IFluidHandler, FluidNetwork>)transmitter).getTransmitterNetwork();
|
||||||
|
@ -180,15 +185,19 @@ public class PacketTransmitterUpdate implements IMessageHandler<TransmitterUpdat
|
||||||
dataStream.writeInt(coord4D.zCoord);
|
dataStream.writeInt(coord4D.zCoord);
|
||||||
dataStream.writeInt(coord4D.dimensionId);
|
dataStream.writeInt(coord4D.dimensionId);
|
||||||
|
|
||||||
|
PacketHandler.log("Sending '" + packetType + "' update message from coordinate " + coord4D);
|
||||||
|
|
||||||
switch(packetType)
|
switch(packetType)
|
||||||
{
|
{
|
||||||
case UPDATE:
|
case UPDATE:
|
||||||
dataStream.writeBoolean(newNetwork);
|
dataStream.writeBoolean(newNetwork);
|
||||||
dataStream.writeInt(transmittersAdded.size());
|
dataStream.writeInt(transmittersAdded.size());
|
||||||
|
|
||||||
for(IGridTransmitter transmitter : transmittersAdded)
|
for(IGridTransmitter transmitter : transmittersAdded)
|
||||||
{
|
{
|
||||||
transmitter.coord().write(dataStream);
|
transmitter.coord().write(dataStream);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case ENERGY:
|
case ENERGY:
|
||||||
dataStream.writeDouble(power);
|
dataStream.writeDouble(power);
|
||||||
|
|
Loading…
Reference in a new issue