11package gregtech .api .metatileentity .interfaces ;
22
3+ import gregtech .api .capability .GregtechDataCodes ;
4+ import gregtech .api .metatileentity .MetaTileEntity ;
5+ import gregtech .api .util .GTLog ;
6+
37import net .minecraft .network .PacketBuffer ;
8+ import net .minecraft .tileentity .TileEntity ;
49
10+ import io .netty .buffer .ByteBuf ;
511import org .jetbrains .annotations .NotNull ;
612
713import java .util .function .Consumer ;
@@ -25,7 +31,7 @@ public interface ISyncedTileEntity {
2531 * <p>
2632 * This method is called <strong>Server-Side</strong>.
2733 * <p>
28- * Equivalent to {@link net.minecraft.tileentity. TileEntity#getUpdateTag}.
34+ * Equivalent to {@link TileEntity#getUpdateTag}.
2935 *
3036 * @param buf the buffer to write data to
3137 */
@@ -43,7 +49,7 @@ public interface ISyncedTileEntity {
4349 * <p>
4450 * This method is called <strong>Client-Side</strong>.
4551 * <p>
46- * Equivalent to {@link net.minecraft.tileentity. TileEntity#handleUpdateTag}.
52+ * Equivalent to {@link TileEntity#handleUpdateTag}.
4753 *
4854 * @param buf the buffer to read data from
4955 */
@@ -62,11 +68,11 @@ public interface ISyncedTileEntity {
6268 * <p>
6369 * This method is called <strong>Server-Side</strong>.
6470 * <p>
65- * Equivalent to {@link net.minecraft.tileentity. TileEntity#getUpdatePacket}
71+ * Equivalent to {@link TileEntity#getUpdatePacket}
6672 *
6773 * @param discriminator the discriminator determining the packet sent.
6874 * @param dataWriter a consumer which writes packet data to a buffer.
69- * @see gregtech.api.capability. GregtechDataCodes
75+ * @see GregtechDataCodes
7076 */
7177 void writeCustomData (int discriminator , @ NotNull Consumer <@ NotNull PacketBuffer > dataWriter );
7278
@@ -82,10 +88,10 @@ public interface ISyncedTileEntity {
8288 * <p>
8389 * This method is called <strong>Server-Side</strong>.
8490 * <p>
85- * Equivalent to {@link net.minecraft.tileentity. TileEntity#getUpdatePacket}
91+ * Equivalent to {@link TileEntity#getUpdatePacket}
8692 *
8793 * @param discriminator the discriminator determining the packet sent.
88- * @see gregtech.api.capability. GregtechDataCodes
94+ * @see GregtechDataCodes
8995 */
9096 default void writeCustomData (int discriminator ) {
9197 writeCustomData (discriminator , NO_OP );
@@ -103,11 +109,24 @@ default void writeCustomData(int discriminator) {
103109 * <p>
104110 * This method is called <strong>Client-Side</strong>.
105111 * <p>
106- * Equivalent to {@link net.minecraft.tileentity. TileEntity#onDataPacket}
112+ * Equivalent to {@link TileEntity#onDataPacket}
107113 *
108114 * @param discriminator the discriminator determining the packet sent.
109115 * @param buf the buffer containing the packet data.
110- * @see gregtech.api.capability. GregtechDataCodes
116+ * @see GregtechDataCodes
111117 */
112118 void receiveCustomData (int discriminator , @ NotNull PacketBuffer buf );
119+
120+ static void handleUnreadPacket (int discriminator , @ NotNull ByteBuf buf , ISyncedTileEntity syncedTile ) {
121+ String className = null ;
122+ if (syncedTile instanceof IGregTechTileEntity gtte ) {
123+ MetaTileEntity mte = gtte .getMetaTileEntity ();
124+ if (mte != null ) className = mte .getClass ().getSimpleName ();
125+ } else {
126+ className = syncedTile .getClass ().getSimpleName ();
127+ }
128+ GTLog .logger .error (
129+ "Class {} failed to finish reading receiveCustomData with discriminator {} and {} bytes remaining" ,
130+ className , GregtechDataCodes .getNameFor (discriminator ), buf .readableBytes ());
131+ }
113132}
0 commit comments