Support closed flag on BufferBuilders

Thanks to Moulberry for noting this vanilla change
This commit is contained in:
embeddedt 2023-11-02 13:35:25 -04:00
parent 915de8187e
commit 86c6e90436

View File

@ -14,6 +14,7 @@ import java.nio.ByteBuffer;
@Mixin(BufferBuilder.class)
public class BufferBuilderMixin {
@Shadow private ByteBuffer buffer;
@Shadow private boolean closed;
private static boolean leakReported = false;
@ -30,7 +31,7 @@ public class BufferBuilderMixin {
try {
ByteBuffer buf = buffer;
// can be null if a mod already tried to free the buffer
if(buf != null) {
if(!this.closed && buf != null) {
if(!leakReported) {
leakReported = true;
ModernFix.LOGGER.warn("One or more BufferBuilders have been leaked, ModernFix will attempt to correct this.");