diff --git a/src/main/java/com/jozufozu/flywheel/extension/BufferBuilderExtension.java b/src/main/java/com/jozufozu/flywheel/extension/BufferBuilderExtension.java deleted file mode 100644 index b5a750a87..000000000 --- a/src/main/java/com/jozufozu/flywheel/extension/BufferBuilderExtension.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.jozufozu.flywheel.extension; - -import java.nio.ByteBuffer; - -import com.mojang.blaze3d.vertex.BufferBuilder; -import com.mojang.blaze3d.vertex.VertexFormat; - -/** - * Duck interface used on {@link BufferBuilder} to provide lower level access to the backing memory. - * - * @see com.jozufozu.flywheel.mixin.BufferBuilderMixin - */ -public interface BufferBuilderExtension { - - /** - * Frees the internal ByteBuffer, if it exists. - */ - void flywheel$freeBuffer(); - - /** - * Prepares the BufferBuilder for drawing the contents of the given buffer. - * @param buffer The buffer to draw. - * @param format The format of the buffer. - * @param vertexCount The number of vertices in the buffer. - */ - void flywheel$injectForRender(ByteBuffer buffer, VertexFormat format, int vertexCount); -} diff --git a/src/main/java/com/jozufozu/flywheel/mixin/BufferBuilderMixin.java b/src/main/java/com/jozufozu/flywheel/mixin/BufferBuilderMixin.java deleted file mode 100644 index 973d9f4dd..000000000 --- a/src/main/java/com/jozufozu/flywheel/mixin/BufferBuilderMixin.java +++ /dev/null @@ -1,66 +0,0 @@ -package com.jozufozu.flywheel.mixin; - -import java.nio.ByteBuffer; - -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.lwjgl.system.MemoryUtil; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; - -import com.jozufozu.flywheel.extension.BufferBuilderExtension; -import com.mojang.blaze3d.vertex.BufferBuilder; -import com.mojang.blaze3d.vertex.VertexFormat; -import com.mojang.blaze3d.vertex.VertexFormatElement; - -@Mixin(BufferBuilder.class) -abstract class BufferBuilderMixin implements BufferBuilderExtension { - @Shadow - private ByteBuffer buffer; - - @Shadow - private int vertices; - - @Shadow - @Nullable - private VertexFormatElement currentElement; - - @Shadow - private int elementIndex; - - @Shadow - private VertexFormat format; - - @Shadow - private VertexFormat.Mode mode; - - @Shadow - private boolean building; - - @Shadow - private int nextElementByte; - - @Override - public void flywheel$freeBuffer() { - if (buffer != null) { - // The buffer is created using MemoryTracker, which uses a non-default allocator. - // The same allocator must be used here to free the buffer. - MemoryUtil.getAllocator(false).free(MemoryUtil.memAddress0(buffer)); - buffer = null; - } - } - - @Override - public void flywheel$injectForRender(@NotNull ByteBuffer buffer, @NotNull VertexFormat format, int vertexCount) { - building = true; - mode = VertexFormat.Mode.QUADS; - - this.buffer = buffer; - this.format = format; - vertices = vertexCount; - - currentElement = format.getElements().get(0); - elementIndex = 0; - nextElementByte = vertexCount * format.getVertexSize(); - } -} diff --git a/src/main/resources/flywheel.mixins.json b/src/main/resources/flywheel.mixins.json index 396e1b26f..5809e2940 100644 --- a/src/main/resources/flywheel.mixins.json +++ b/src/main/resources/flywheel.mixins.json @@ -6,7 +6,6 @@ "refmap": "flywheel.refmap.json", "client": [ "BlockEntityTypeMixin", - "BufferBuilderMixin", "ClientLevelMixin", "EntityTypeMixin", "FogUpdateMixin",