Fix BufferBuilderReader endianness

- Set split ByteBuffer's order to that of the BufferBuilder's ByteBuffer
in BufferBuilderReader
- Move Fabric-only mixins from mixin.fabric to fabric.mixin and create
separate mixin config
This commit is contained in:
PepperCode1 2021-12-24 16:21:57 -08:00
parent 09f3c495e9
commit a2b6c4fd9d
12 changed files with 39 additions and 16 deletions

View file

@ -1,10 +1,16 @@
package com.jozufozu.flywheel.fabric.helper;
import com.jozufozu.flywheel.mixin.fabric.BufferBuilderAccessor;
import java.nio.ByteBuffer;
import com.jozufozu.flywheel.fabric.mixin.BufferBuilderAccessor;
import com.mojang.blaze3d.vertex.BufferBuilder;
import com.mojang.blaze3d.vertex.VertexFormat;
public final class BufferBuilderHelper {
public static void fixByteOrder(BufferBuilder self, ByteBuffer buffer) {
buffer.order(((BufferBuilderAccessor) self).getBuffer().order());
}
public static VertexFormat getVertexFormat(BufferBuilder self) {
return ((BufferBuilderAccessor) self).getFormat();
}

View file

@ -1,6 +1,6 @@
package com.jozufozu.flywheel.fabric.helper;
import com.jozufozu.flywheel.mixin.fabric.VertexFormatAccessor;
import com.jozufozu.flywheel.fabric.mixin.VertexFormatAccessor;
import com.mojang.blaze3d.vertex.VertexFormat;
public final class VertexFormatHelper {

View file

@ -1,4 +1,6 @@
package com.jozufozu.flywheel.mixin.fabric;
package com.jozufozu.flywheel.fabric.mixin;
import java.nio.ByteBuffer;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
@ -8,6 +10,9 @@ import com.mojang.blaze3d.vertex.VertexFormat;
@Mixin(BufferBuilder.class)
public interface BufferBuilderAccessor {
@Accessor("buffer")
ByteBuffer getBuffer();
@Accessor("format")
VertexFormat getFormat();
}

View file

@ -1,4 +1,4 @@
package com.jozufozu.flywheel.mixin.fabric;
package com.jozufozu.flywheel.fabric.mixin;
import java.util.List;

View file

@ -1,4 +1,4 @@
package com.jozufozu.flywheel.mixin.fabric;
package com.jozufozu.flywheel.fabric.mixin;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;

View file

@ -1,4 +1,4 @@
package com.jozufozu.flywheel.mixin.fabric;
package com.jozufozu.flywheel.fabric.mixin;
import org.objectweb.asm.Opcodes;
import org.spongepowered.asm.mixin.Mixin;

View file

@ -1,4 +1,4 @@
package com.jozufozu.flywheel.mixin.fabric;
package com.jozufozu.flywheel.fabric.mixin;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;

View file

@ -1,4 +1,4 @@
package com.jozufozu.flywheel.mixin.fabric;
package com.jozufozu.flywheel.fabric.mixin;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;

View file

@ -18,6 +18,7 @@ public class BufferBuilderReader {
VertexFormat vertexFormat = BufferBuilderHelper.getVertexFormat(builder);
Pair<BufferBuilder.DrawState, ByteBuffer> data = builder.popNextBuffer();
buffer = data.getSecond();
BufferBuilderHelper.fixByteOrder(builder, buffer);
formatSize = vertexFormat.getVertexSize();

View file

@ -25,7 +25,8 @@
]
},
"mixins": [
"flywheel.mixins.json"
"flywheel.mixins.json",
"flywheel.fabric.mixins.json"
],
"depends": {

View file

@ -0,0 +1,17 @@
{
"required": true,
"minVersion": "0.8",
"package": "com.jozufozu.flywheel.fabric.mixin",
"compatibilityLevel": "JAVA_17",
"client": [
"BufferBuilderAccessor",
"DebugScreenOverlayMixin",
"Matrix4fMixin",
"MinecraftMixin",
"TextureAtlasMixin",
"VertexFormatAccessor"
],
"injectors": {
"defaultRequire": 1
}
}

View file

@ -21,13 +21,6 @@
"matrix.Matrix3fMixin",
"matrix.Matrix4fMixin",
"matrix.PoseStackMixin"
,
"fabric.BufferBuilderAccessor",
"fabric.DebugScreenOverlayMixin",
"fabric.Matrix4fMixin",
"fabric.MinecraftMixin",
"fabric.TextureAtlasMixin",
"fabric.VertexFormatAccessor"
],
"injectors": {
"defaultRequire": 1