Skip to content

Commit

Permalink
Improve packet warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
ALongStringOfNumbers committed Nov 10, 2023
1 parent 08c7f57 commit 3a47cda
Showing 1 changed file with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import gregtech.api.block.BlockStateTileEntity;
import gregtech.api.metatileentity.interfaces.ISyncedTileEntity;
import gregtech.api.metatileentity.interfaces.IGregTechTileEntity;
import gregtech.api.network.PacketDataList;
import gregtech.api.util.GTLog;
import io.netty.buffer.ByteBuf;
Expand Down Expand Up @@ -72,8 +73,16 @@ public final void onDataPacket(@NotNull NetworkManager net, @NotNull SPacketUpda
ByteBuf backedBuffer = Unpooled.copiedBuffer(entryTag.getByteArray(discriminatorKey));
receiveCustomData(Integer.parseInt(discriminatorKey), new PacketBuffer(backedBuffer));
if (backedBuffer.readableBytes() != 0) {
String className = null;
if (this instanceof IGregTechTileEntity gtte) {
MetaTileEntity mte = gtte.getMetaTileEntity();
if (mte != null) className = mte.getClass().getName();
}
if (className == null) {
className = this.getClass().getName();
}
GTLog.logger.error("Class {} failed to finish reading receiveCustomData with discriminator {} and {} bytes remaining",
getClass().getName(), discriminatorKey, backedBuffer.readableBytes());
className, discriminatorKey, backedBuffer.readableBytes());
}
}
}
Expand All @@ -96,8 +105,17 @@ public final void handleUpdateTag(@NotNull NBTTagCompound tag) {
ByteBuf backedBuffer = Unpooled.copiedBuffer(updateData);
receiveInitialSyncData(new PacketBuffer(backedBuffer));
if (backedBuffer.readableBytes() != 0) {
String className = null;
if (this instanceof IGregTechTileEntity gtte) {
MetaTileEntity mte = gtte.getMetaTileEntity();
if (mte != null) className = mte.getClass().getName();
}
if (className == null) {
className = this.getClass().getName();
}

GTLog.logger.error("Class {} failed to finish reading initialSyncData with {} bytes remaining",
getClass().getName(), backedBuffer.readableBytes());
className, backedBuffer.readableBytes());
}
}
}

0 comments on commit 3a47cda

Please sign in to comment.