mirror of
https://github.com/Jozufozu/Flywheel.git
synced 2025-01-23 03:17:53 +01:00
1.21 Port I
This commit is contained in:
parent
eccbfbc649
commit
d587ec0ec8
19 changed files with 102 additions and 164 deletions
2
.github/workflows/build.yml
vendored
2
.github/workflows/build.yml
vendored
|
@ -7,7 +7,7 @@ jobs:
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
java: [
|
java: [
|
||||||
17 # Current Java LTS & minimum supported by Minecraft
|
21 # Current Java LTS & minimum supported by Minecraft
|
||||||
]
|
]
|
||||||
os: [ ubuntu-latest ]
|
os: [ ubuntu-latest ]
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
|
|
|
@ -9,6 +9,6 @@ public final class Flywheel {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ResourceLocation rl(String path) {
|
public static ResourceLocation rl(String path) {
|
||||||
return new ResourceLocation(ID, path);
|
return ResourceLocation.fromNamespaceAndPath(ID, path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ import net.minecraft.client.renderer.Sheets;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
|
||||||
public final class Materials {
|
public final class Materials {
|
||||||
private static final ResourceLocation MINECART_LOCATION = new ResourceLocation("textures/entity/minecart.png");
|
private static final ResourceLocation MINECART_LOCATION = ResourceLocation.withDefaultNamespace("textures/entity/minecart.png");
|
||||||
|
|
||||||
public static final Material CHUNK_SOLID_SHADED = SimpleMaterial.builder()
|
public static final Material CHUNK_SOLID_SHADED = SimpleMaterial.builder()
|
||||||
.build();
|
.build();
|
||||||
|
|
|
@ -5,7 +5,7 @@ import java.nio.ByteBuffer;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.lwjgl.system.MemoryUtil;
|
import org.lwjgl.system.MemoryUtil;
|
||||||
|
|
||||||
import com.mojang.blaze3d.vertex.BufferBuilder;
|
import com.mojang.blaze3d.vertex.MeshData;
|
||||||
|
|
||||||
import dev.engine_room.flywheel.api.vertex.VertexView;
|
import dev.engine_room.flywheel.api.vertex.VertexView;
|
||||||
import dev.engine_room.flywheel.lib.memory.MemoryBlock;
|
import dev.engine_room.flywheel.lib.memory.MemoryBlock;
|
||||||
|
@ -16,15 +16,15 @@ final class MeshHelper {
|
||||||
private MeshHelper() {
|
private MeshHelper() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SimpleMesh blockVerticesToMesh(BufferBuilder.RenderedBuffer buffer, @Nullable String meshDescriptor) {
|
public static SimpleMesh blockVerticesToMesh(MeshData data, @Nullable String meshDescriptor) {
|
||||||
BufferBuilder.DrawState drawState = buffer.drawState();
|
MeshData.DrawState drawState = data.drawState();
|
||||||
int vertexCount = drawState.vertexCount();
|
int vertexCount = drawState.vertexCount();
|
||||||
long srcStride = drawState.format().getVertexSize();
|
long srcStride = drawState.format().getVertexSize();
|
||||||
|
|
||||||
VertexView vertexView = new NoOverlayVertexView();
|
VertexView vertexView = new NoOverlayVertexView();
|
||||||
long dstStride = vertexView.stride();
|
long dstStride = vertexView.stride();
|
||||||
|
|
||||||
ByteBuffer src = buffer.vertexBuffer();
|
ByteBuffer src = data.vertexBuffer();
|
||||||
MemoryBlock dst = MemoryBlock.malloc((long) vertexCount * dstStride);
|
MemoryBlock dst = MemoryBlock.malloc((long) vertexCount * dstStride);
|
||||||
long srcPtr = MemoryUtil.memAddress(src);
|
long srcPtr = MemoryUtil.memAddress(src);
|
||||||
long dstPtr = dst.ptr();
|
long dstPtr = dst.ptr();
|
||||||
|
|
|
@ -4,7 +4,7 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import net.minecraft.client.resources.model.BakedModel;
|
import net.minecraft.client.resources.model.BakedModel;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.client.resources.model.ModelResourceLocation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A helper class for loading and accessing JSON models not directly used by any blocks or items.
|
* A helper class for loading and accessing JSON models not directly used by any blocks or items.
|
||||||
|
@ -19,10 +19,10 @@ public class PartialModel {
|
||||||
static final List<PartialModel> ALL = new ArrayList<>();
|
static final List<PartialModel> ALL = new ArrayList<>();
|
||||||
static boolean tooLate = false;
|
static boolean tooLate = false;
|
||||||
|
|
||||||
protected final ResourceLocation modelLocation;
|
protected final ModelResourceLocation modelLocation;
|
||||||
protected BakedModel bakedModel;
|
protected BakedModel bakedModel;
|
||||||
|
|
||||||
public PartialModel(ResourceLocation modelLocation) {
|
public PartialModel(ModelResourceLocation modelLocation) {
|
||||||
if (tooLate) {
|
if (tooLate) {
|
||||||
throw new RuntimeException("Attempted to create PartialModel with location '" + modelLocation + "' after start of initial resource reload!");
|
throw new RuntimeException("Attempted to create PartialModel with location '" + modelLocation + "' after start of initial resource reload!");
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ public class PartialModel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ResourceLocation getLocation() {
|
public ModelResourceLocation getLocation() {
|
||||||
return modelLocation;
|
return modelLocation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,67 +26,46 @@ class TransformingVertexConsumer implements VertexConsumer {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VertexConsumer vertex(double x, double y, double z) {
|
public VertexConsumer addVertex(float x, float y, float z) {
|
||||||
Matrix4f matrix = poseStack.last().pose();
|
Matrix4f matrix = poseStack.last().pose();
|
||||||
float fx = (float) x;
|
delegate.addVertex(
|
||||||
float fy = (float) y;
|
MatrixMath.transformPositionX(matrix, x, y, z),
|
||||||
float fz = (float) z;
|
MatrixMath.transformPositionY(matrix, x, y, z),
|
||||||
delegate.vertex(
|
MatrixMath.transformPositionZ(matrix, x, y, z));
|
||||||
MatrixMath.transformPositionX(matrix, fx, fy, fz),
|
|
||||||
MatrixMath.transformPositionY(matrix, fx, fy, fz),
|
|
||||||
MatrixMath.transformPositionZ(matrix, fx, fy, fz));
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VertexConsumer color(int red, int green, int blue, int alpha) {
|
public VertexConsumer setColor(int red, int green, int blue, int alpha) {
|
||||||
delegate.color(red, green, blue, alpha);
|
delegate.setColor(red, green, blue, alpha);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VertexConsumer uv(float u, float v) {
|
public VertexConsumer setUv(float u, float v) {
|
||||||
delegate.uv(u, v);
|
delegate.setUv(u, v);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VertexConsumer overlayCoords(int u, int v) {
|
public VertexConsumer setUv1(int u, int v) {
|
||||||
delegate.overlayCoords(u, v);
|
delegate.setUv1(u, v);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VertexConsumer uv2(int u, int v) {
|
public VertexConsumer setUv2(int u, int v) {
|
||||||
delegate.uv2(u, v);
|
delegate.setUv2(u, v);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VertexConsumer normal(float x, float y, float z) {
|
public VertexConsumer setNormal(float x, float y, float z) {
|
||||||
Matrix3f matrix = poseStack.last().normal();
|
Matrix3f matrix = poseStack.last().normal();
|
||||||
float fx = (float) x;
|
delegate.setNormal(
|
||||||
float fy = (float) y;
|
MatrixMath.transformNormalX(matrix, x, y, z),
|
||||||
float fz = (float) z;
|
MatrixMath.transformNormalY(matrix, x, y, z),
|
||||||
delegate.normal(
|
MatrixMath.transformNormalZ(matrix, x, y, z));
|
||||||
MatrixMath.transformNormalX(matrix, fx, fy, fz),
|
|
||||||
MatrixMath.transformNormalY(matrix, fx, fy, fz),
|
|
||||||
MatrixMath.transformNormalZ(matrix, fx, fy, fz));
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void endVertex() {
|
|
||||||
delegate.endVertex();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void defaultColor(int red, int green, int blue, int alpha) {
|
|
||||||
delegate.defaultColor(red, green, blue, alpha);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void unsetDefaultColor() {
|
|
||||||
delegate.unsetDefaultColor();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,25 +34,24 @@ class VertexWriter implements VertexConsumer {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VertexConsumer vertex(double x, double y, double z) {
|
public VertexConsumer addVertex(float x, float y, float z) {
|
||||||
if (!filledPosition) {
|
if (!filledPosition) {
|
||||||
long ptr = vertexPtr();
|
long ptr = vertexPtr();
|
||||||
MemoryUtil.memPutFloat(ptr, (float) x);
|
MemoryUtil.memPutFloat(ptr, x);
|
||||||
MemoryUtil.memPutFloat(ptr + 4, (float) y);
|
MemoryUtil.memPutFloat(ptr + 4, y);
|
||||||
MemoryUtil.memPutFloat(ptr + 8, (float) z);
|
MemoryUtil.memPutFloat(ptr + 8, z);
|
||||||
filledPosition = true;
|
filledPosition = true;
|
||||||
}
|
}
|
||||||
return this;
|
return endVertexIfNeeded();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VertexConsumer color(int red, int green, int blue, int alpha) {
|
public VertexConsumer setColor(int red, int green, int blue, int alpha) {
|
||||||
// ignore color
|
return endVertexIfNeeded();
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VertexConsumer uv(float u, float v) {
|
public VertexConsumer setUv(float u, float v) {
|
||||||
if (!filledTexture) {
|
if (!filledTexture) {
|
||||||
if (textureMapper != null) {
|
if (textureMapper != null) {
|
||||||
uvVec.set(u, v);
|
uvVec.set(u, v);
|
||||||
|
@ -66,23 +65,23 @@ class VertexWriter implements VertexConsumer {
|
||||||
MemoryUtil.memPutFloat(ptr + 16, v);
|
MemoryUtil.memPutFloat(ptr + 16, v);
|
||||||
filledTexture = true;
|
filledTexture = true;
|
||||||
}
|
}
|
||||||
return this;
|
return endVertexIfNeeded();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VertexConsumer overlayCoords(int u, int v) {
|
public VertexConsumer setUv1(int u, int v) {
|
||||||
// ignore overlay
|
// ignore overlay
|
||||||
return this;
|
return endVertexIfNeeded();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VertexConsumer uv2(int u, int v) {
|
public VertexConsumer setUv2(int u, int v) {
|
||||||
// ignore light
|
// ignore light
|
||||||
return this;
|
return endVertexIfNeeded();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VertexConsumer normal(float x, float y, float z) {
|
public VertexConsumer setNormal(float x, float y, float z) {
|
||||||
if (!filledNormal) {
|
if (!filledNormal) {
|
||||||
long ptr = vertexPtr();
|
long ptr = vertexPtr();
|
||||||
MemoryUtil.memPutByte(ptr + 20, RenderMath.nb(x));
|
MemoryUtil.memPutByte(ptr + 20, RenderMath.nb(x));
|
||||||
|
@ -90,13 +89,12 @@ class VertexWriter implements VertexConsumer {
|
||||||
MemoryUtil.memPutByte(ptr + 22, RenderMath.nb(z));
|
MemoryUtil.memPutByte(ptr + 22, RenderMath.nb(z));
|
||||||
filledNormal = true;
|
filledNormal = true;
|
||||||
}
|
}
|
||||||
return this;
|
return endVertexIfNeeded();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public VertexConsumer endVertexIfNeeded() {
|
||||||
public void endVertex() {
|
|
||||||
if (!filledPosition || !filledTexture || !filledNormal) {
|
if (!filledPosition || !filledTexture || !filledNormal) {
|
||||||
throw new IllegalStateException("Not filled all elements of the vertex");
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
filledPosition = false;
|
filledPosition = false;
|
||||||
|
@ -109,14 +107,8 @@ class VertexWriter implements VertexConsumer {
|
||||||
if (byteSize > capacity) {
|
if (byteSize > capacity) {
|
||||||
data = data.realloc(capacity * 2);
|
data = data.realloc(capacity * 2);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
return this;
|
||||||
public void defaultColor(int red, int green, int blue, int alpha) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void unsetDefaultColor() {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private long vertexPtr() {
|
private long vertexPtr() {
|
||||||
|
|
|
@ -30,7 +30,7 @@ public final class ResourceUtil {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ResourceLocation(namespace, path);
|
return ResourceLocation.fromNamespaceAndPath(namespace, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -44,7 +44,7 @@ import net.minecraft.world.phys.shapes.VoxelShape;
|
||||||
*/
|
*/
|
||||||
public class ShadowComponent implements EntityComponent {
|
public class ShadowComponent implements EntityComponent {
|
||||||
private static final Material SHADOW_MATERIAL = SimpleMaterial.builder()
|
private static final Material SHADOW_MATERIAL = SimpleMaterial.builder()
|
||||||
.texture(new ResourceLocation("textures/misc/shadow.png"))
|
.texture(ResourceLocation.withDefaultNamespace("textures/misc/shadow.png"))
|
||||||
.mipmap(false)
|
.mipmap(false)
|
||||||
.polygonOffset(true) // vanilla shadows use "view offset" but this seems to work fine
|
.polygonOffset(true) // vanilla shadows use "view offset" but this seems to work fine
|
||||||
.transparency(Transparency.TRANSLUCENT)
|
.transparency(Transparency.TRANSLUCENT)
|
||||||
|
|
|
@ -4,7 +4,7 @@ import java.util.Iterator;
|
||||||
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import com.mojang.blaze3d.vertex.BufferBuilder.RenderedBuffer;
|
import com.mojang.blaze3d.vertex.MeshData;
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
|
|
||||||
import it.unimi.dsi.fastutil.objects.Reference2ReferenceMap;
|
import it.unimi.dsi.fastutil.objects.Reference2ReferenceMap;
|
||||||
|
@ -129,7 +129,7 @@ final class BakedModelBufferer {
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface ResultConsumer {
|
public interface ResultConsumer {
|
||||||
void accept(RenderType renderType, boolean shaded, RenderedBuffer data);
|
void accept(RenderType renderType, boolean shaded, MeshData data);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class ThreadLocalObjects {
|
private static class ThreadLocalObjects {
|
||||||
|
|
|
@ -56,69 +56,54 @@ class UniversalMeshEmitter implements VertexConsumer {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VertexConsumer vertex(double x, double y, double z) {
|
public VertexConsumer addVertex(float x, float y, float z) {
|
||||||
currentDelegate.vertex(x, y, z);
|
currentDelegate.addVertex(x, y, z);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VertexConsumer color(int red, int green, int blue, int alpha) {
|
public VertexConsumer setColor(int red, int green, int blue, int alpha) {
|
||||||
currentDelegate.color(red, green, blue, alpha);
|
currentDelegate.setColor(red, green, blue, alpha);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VertexConsumer uv(float u, float v) {
|
public VertexConsumer setUv(float u, float v) {
|
||||||
currentDelegate.uv(u, v);
|
currentDelegate.setUv(u, v);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VertexConsumer overlayCoords(int u, int v) {
|
public VertexConsumer setUv1(int u, int v) {
|
||||||
currentDelegate.overlayCoords(u, v);
|
currentDelegate.setUv1(u, v);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VertexConsumer uv2(int u, int v) {
|
public VertexConsumer setUv2(int u, int v) {
|
||||||
currentDelegate.uv2(u, v);
|
currentDelegate.setUv2(u, v);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VertexConsumer normal(float x, float y, float z) {
|
public VertexConsumer setNormal(float x, float y, float z) {
|
||||||
currentDelegate.normal(x, y, z);
|
currentDelegate.setNormal(x, y, z);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void endVertex() {
|
public void addVertex(float x, float y, float z, int color, float u, float v, int packedOverlay, int packedLight, float normalX, float normalY, float normalZ) {
|
||||||
currentDelegate.endVertex();
|
currentDelegate.addVertex(x, y, z, color, u, v, packedOverlay, packedLight, normalX, normalY, normalZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void defaultColor(int red, int green, int blue, int alpha) {
|
public void putBulkData(PoseStack.Pose pose, BakedQuad quad, float red, float green, float blue, float alpha, int packedLight, int packedOverlay) {
|
||||||
currentDelegate.defaultColor(red, green, blue, alpha);
|
currentDelegate.putBulkData(pose, quad, red, green, blue, alpha, packedLight, packedOverlay);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void unsetDefaultColor() {
|
public void putBulkData(PoseStack.Pose pose, BakedQuad quad, float[] brightness, float red, float green, float blue, float alpha, int[] lightmap, int packedOverlay, boolean readAlpha) {
|
||||||
currentDelegate.unsetDefaultColor();
|
currentDelegate.putBulkData(pose, quad, brightness, red, green, blue, alpha, lightmap, packedOverlay, readAlpha);
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void vertex(float x, float y, float z, float red, float green, float blue, float alpha, float u, float v, int overlay, int light, float normalX, float normalY, float normalZ) {
|
|
||||||
currentDelegate.vertex(x, y, z, red, green, blue, alpha, u, v, overlay, light, normalX, normalY, normalZ);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void putBulkData(PoseStack.Pose pose, BakedQuad quad, float red, float green, float blue, int light, int overlay) {
|
|
||||||
currentDelegate.putBulkData(pose, quad, red, green, blue, light, overlay);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void putBulkData(PoseStack.Pose pose, BakedQuad quad, float[] brightnesses, float red, float green, float blue, int[] lights, int overlay, boolean readExistingColor) {
|
|
||||||
currentDelegate.putBulkData(pose, quad, brightnesses, red, green, blue, lights, overlay, readExistingColor);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private class WrapperModel extends ForwardingBakedModel {
|
private class WrapperModel extends ForwardingBakedModel {
|
||||||
|
|
|
@ -99,7 +99,7 @@ public class FabricFlwConfig implements FlwConfig {
|
||||||
if (backendJson instanceof JsonPrimitive primitive && primitive.isString()) {
|
if (backendJson instanceof JsonPrimitive primitive && primitive.isString()) {
|
||||||
var value = primitive.getAsString();
|
var value = primitive.getAsString();
|
||||||
try {
|
try {
|
||||||
this.backend = Backend.REGISTRY.getOrThrow(new ResourceLocation(value));
|
this.backend = Backend.REGISTRY.getOrThrow(ResourceLocation.parse(value));
|
||||||
return;
|
return;
|
||||||
} catch (ResourceLocationException e) {
|
} catch (ResourceLocationException e) {
|
||||||
msg = "'backend' value '" + value + "' is not a valid resource location";
|
msg = "'backend' value '" + value + "' is not a valid resource location";
|
||||||
|
|
|
@ -5,7 +5,7 @@ import java.util.function.Function;
|
||||||
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import com.mojang.blaze3d.vertex.BufferBuilder.RenderedBuffer;
|
import com.mojang.blaze3d.vertex.MeshData;
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
|
|
||||||
import net.minecraft.client.renderer.ItemBlockRenderTypes;
|
import net.minecraft.client.renderer.ItemBlockRenderTypes;
|
||||||
|
@ -130,7 +130,7 @@ final class BakedModelBufferer {
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface ResultConsumer {
|
public interface ResultConsumer {
|
||||||
void accept(RenderType renderType, boolean shaded, RenderedBuffer data);
|
void accept(RenderType renderType, boolean shaded, MeshData data);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class ThreadLocalObjects {
|
private static class ThreadLocalObjects {
|
||||||
|
|
|
@ -63,12 +63,6 @@ class MeshEmitter implements VertexConsumer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void putBulkData(PoseStack.Pose pose, BakedQuad quad, float red, float green, float blue, int light, int overlay) {
|
|
||||||
prepareForGeometry(quad);
|
|
||||||
bufferBuilder.putBulkData(pose, quad, red, green, blue, light, overlay);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void putBulkData(PoseStack.Pose pose, BakedQuad quad, float red, float green, float blue, float alpha, int light, int overlay, boolean readExistingColor) {
|
public void putBulkData(PoseStack.Pose pose, BakedQuad quad, float red, float green, float blue, float alpha, int light, int overlay, boolean readExistingColor) {
|
||||||
prepareForGeometry(quad);
|
prepareForGeometry(quad);
|
||||||
|
@ -76,9 +70,9 @@ class MeshEmitter implements VertexConsumer {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void putBulkData(PoseStack.Pose pose, BakedQuad quad, float[] brightnesses, float red, float green, float blue, int[] lights, int overlay, boolean readExistingColor) {
|
public void putBulkData(PoseStack.Pose pose, BakedQuad quad, float red, float green, float blue, float alpha, int packedLight, int packedOverlay) {
|
||||||
prepareForGeometry(quad);
|
prepareForGeometry(quad);
|
||||||
bufferBuilder.putBulkData(pose, quad, brightnesses, red, green, blue, lights, overlay, readExistingColor);
|
bufferBuilder.putBulkData(pose, quad, red, green, blue, alpha, packedLight, packedOverlay);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -88,47 +82,32 @@ class MeshEmitter implements VertexConsumer {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VertexConsumer vertex(double x, double y, double z) {
|
public VertexConsumer addVertex(float x, float y, float z) {
|
||||||
throw new UnsupportedOperationException("MeshEmitter only supports putBulkData!");
|
throw new UnsupportedOperationException("MeshEmitter only supports putBulkData!");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VertexConsumer color(int red, int green, int blue, int alpha) {
|
public VertexConsumer setColor(int red, int green, int blue, int alpha) {
|
||||||
throw new UnsupportedOperationException("MeshEmitter only supports putBulkData!");
|
throw new UnsupportedOperationException("MeshEmitter only supports putBulkData!");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VertexConsumer uv(float u, float v) {
|
public VertexConsumer setUv(float u, float v) {
|
||||||
throw new UnsupportedOperationException("MeshEmitter only supports putBulkData!");
|
throw new UnsupportedOperationException("MeshEmitter only supports putBulkData!");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VertexConsumer overlayCoords(int u, int v) {
|
public VertexConsumer setUv1(int u, int v) {
|
||||||
throw new UnsupportedOperationException("MeshEmitter only supports putBulkData!");
|
throw new UnsupportedOperationException("MeshEmitter only supports putBulkData!");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VertexConsumer uv2(int u, int v) {
|
public VertexConsumer setUv2(int u, int v) {
|
||||||
throw new UnsupportedOperationException("MeshEmitter only supports putBulkData!");
|
throw new UnsupportedOperationException("MeshEmitter only supports putBulkData!");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VertexConsumer normal(float x, float y, float z) {
|
public VertexConsumer setNormal(float normalX, float normalY, float normalZ) {
|
||||||
throw new UnsupportedOperationException("MeshEmitter only supports putBulkData!");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void endVertex() {
|
|
||||||
throw new UnsupportedOperationException("MeshEmitter only supports putBulkData!");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void defaultColor(int red, int green, int blue, int alpha) {
|
|
||||||
throw new UnsupportedOperationException("MeshEmitter only supports putBulkData!");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void unsetDefaultColor() {
|
|
||||||
throw new UnsupportedOperationException("MeshEmitter only supports putBulkData!");
|
throw new UnsupportedOperationException("MeshEmitter only supports putBulkData!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ import java.util.Map;
|
||||||
import org.jetbrains.annotations.ApiStatus;
|
import org.jetbrains.annotations.ApiStatus;
|
||||||
|
|
||||||
import net.minecraft.client.resources.model.BakedModel;
|
import net.minecraft.client.resources.model.BakedModel;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.client.resources.model.ModelResourceLocation;
|
||||||
import net.neoforged.neoforge.client.event.ModelEvent;
|
import net.neoforged.neoforge.client.event.ModelEvent;
|
||||||
|
|
||||||
@ApiStatus.Internal
|
@ApiStatus.Internal
|
||||||
|
@ -22,7 +22,7 @@ public final class PartialModelEventHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void onBakingCompleted(ModelEvent.BakingCompleted event) {
|
public static void onBakingCompleted(ModelEvent.BakingCompleted event) {
|
||||||
Map<ResourceLocation, BakedModel> models = event.getModels();
|
Map<ModelResourceLocation, BakedModel> models = event.getModels();
|
||||||
|
|
||||||
for (PartialModel partial : PartialModel.ALL) {
|
for (PartialModel partial : PartialModel.ALL) {
|
||||||
partial.set(models.get(partial.getLocation()));
|
partial.set(models.get(partial.getLocation()));
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package dev.engine_room.flywheel.impl;
|
package dev.engine_room.flywheel.impl;
|
||||||
|
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
import org.apache.maven.artifact.versioning.ArtifactVersion;
|
import org.apache.maven.artifact.versioning.ArtifactVersion;
|
||||||
import org.jetbrains.annotations.UnknownNullability;
|
import org.jetbrains.annotations.UnknownNullability;
|
||||||
|
|
||||||
|
@ -18,22 +20,20 @@ import dev.engine_room.flywheel.lib.util.LevelAttached;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.commands.synchronization.ArgumentTypeInfos;
|
import net.minecraft.commands.synchronization.ArgumentTypeInfos;
|
||||||
import net.minecraft.core.registries.Registries;
|
import net.minecraft.core.registries.Registries;
|
||||||
import net.neoforged.api.distmarker.Dist;
|
|
||||||
import net.neoforged.bus.api.IEventBus;
|
import net.neoforged.bus.api.IEventBus;
|
||||||
import net.neoforged.fml.CrashReportCallables;
|
import net.neoforged.fml.CrashReportCallables;
|
||||||
import net.neoforged.fml.DistExecutor;
|
|
||||||
import net.neoforged.fml.LogicalSide;
|
|
||||||
import net.neoforged.fml.ModContainer;
|
import net.neoforged.fml.ModContainer;
|
||||||
import net.neoforged.fml.ModLoadingContext;
|
import net.neoforged.fml.ModLoadingContext;
|
||||||
import net.neoforged.fml.common.Mod;
|
import net.neoforged.fml.common.Mod;
|
||||||
import net.neoforged.fml.event.lifecycle.FMLCommonSetupEvent;
|
import net.neoforged.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||||
|
import net.neoforged.fml.loading.FMLLoader;
|
||||||
import net.neoforged.neoforge.client.event.CustomizeGuiOverlayEvent;
|
import net.neoforged.neoforge.client.event.CustomizeGuiOverlayEvent;
|
||||||
import net.neoforged.neoforge.client.event.RegisterClientReloadListenersEvent;
|
import net.neoforged.neoforge.client.event.RegisterClientReloadListenersEvent;
|
||||||
import net.neoforged.neoforge.common.NeoForge;
|
import net.neoforged.neoforge.common.NeoForge;
|
||||||
import net.neoforged.neoforge.event.TickEvent;
|
|
||||||
import net.neoforged.neoforge.event.entity.EntityJoinLevelEvent;
|
import net.neoforged.neoforge.event.entity.EntityJoinLevelEvent;
|
||||||
import net.neoforged.neoforge.event.entity.EntityLeaveLevelEvent;
|
import net.neoforged.neoforge.event.entity.EntityLeaveLevelEvent;
|
||||||
import net.neoforged.neoforge.event.level.LevelEvent;
|
import net.neoforged.neoforge.event.level.LevelEvent;
|
||||||
|
import net.neoforged.neoforge.event.tick.LevelTickEvent;
|
||||||
import net.neoforged.neoforge.registries.RegisterEvent;
|
import net.neoforged.neoforge.registries.RegisterEvent;
|
||||||
|
|
||||||
@Mod(Flywheel.ID)
|
@Mod(Flywheel.ID)
|
||||||
|
@ -50,9 +50,12 @@ public final class FlywheelForge {
|
||||||
|
|
||||||
IEventBus forgeEventBus = NeoForge.EVENT_BUS;
|
IEventBus forgeEventBus = NeoForge.EVENT_BUS;
|
||||||
|
|
||||||
ForgeFlwConfig.INSTANCE.registerSpecs(modLoadingContext);
|
ForgeFlwConfig.INSTANCE.registerSpecs(modContainer);
|
||||||
|
|
||||||
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> FlywheelForge.clientInit(forgeEventBus, modEventBus));
|
if (FMLLoader.getDist().isClient()) {
|
||||||
|
Supplier<Runnable> toRun = () -> () -> FlywheelForge.clientInit(forgeEventBus, modEventBus);
|
||||||
|
toRun.get().run();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void clientInit(IEventBus forgeEventBus, IEventBus modEventBus) {
|
private static void clientInit(IEventBus forgeEventBus, IEventBus modEventBus) {
|
||||||
|
@ -67,10 +70,10 @@ public final class FlywheelForge {
|
||||||
private static void registerImplEventListeners(IEventBus forgeEventBus, IEventBus modEventBus) {
|
private static void registerImplEventListeners(IEventBus forgeEventBus, IEventBus modEventBus) {
|
||||||
forgeEventBus.addListener((ReloadLevelRendererEvent e) -> BackendManagerImpl.onReloadLevelRenderer(e.level()));
|
forgeEventBus.addListener((ReloadLevelRendererEvent e) -> BackendManagerImpl.onReloadLevelRenderer(e.level()));
|
||||||
|
|
||||||
forgeEventBus.addListener((TickEvent.LevelTickEvent e) -> {
|
forgeEventBus.addListener((LevelTickEvent.Post e) -> {
|
||||||
// Make sure we don't tick on the server somehow.
|
// Make sure we don't tick on the server somehow.
|
||||||
if (e.phase == TickEvent.Phase.END && e.side == LogicalSide.CLIENT) {
|
if (FMLLoader.getDist().isClient()) {
|
||||||
VisualizationEventHandler.onClientTick(Minecraft.getInstance(), e.level);
|
VisualizationEventHandler.onClientTick(Minecraft.getInstance(), e.getLevel());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
forgeEventBus.addListener((BeginFrameEvent e) -> VisualizationEventHandler.onBeginFrame(e.context()));
|
forgeEventBus.addListener((BeginFrameEvent e) -> VisualizationEventHandler.onBeginFrame(e.context()));
|
||||||
|
|
|
@ -7,7 +7,7 @@ import dev.engine_room.flywheel.api.backend.Backend;
|
||||||
import dev.engine_room.flywheel.api.backend.BackendManager;
|
import dev.engine_room.flywheel.api.backend.BackendManager;
|
||||||
import net.minecraft.ResourceLocationException;
|
import net.minecraft.ResourceLocationException;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.neoforged.fml.ModLoadingContext;
|
import net.neoforged.fml.ModContainer;
|
||||||
import net.neoforged.fml.config.ModConfig;
|
import net.neoforged.fml.config.ModConfig;
|
||||||
import net.neoforged.neoforge.common.ModConfigSpec;
|
import net.neoforged.neoforge.common.ModConfigSpec;
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ public class ForgeFlwConfig implements FlwConfig {
|
||||||
private static Backend parseBackend(String idStr) {
|
private static Backend parseBackend(String idStr) {
|
||||||
ResourceLocation backendId;
|
ResourceLocation backendId;
|
||||||
try {
|
try {
|
||||||
backendId = new ResourceLocation(idStr);
|
backendId = ResourceLocation.parse(idStr);
|
||||||
} catch (ResourceLocationException e) {
|
} catch (ResourceLocationException e) {
|
||||||
FlwImpl.CONFIG_LOGGER.warn("'backend' value '{}' is not a valid resource location", idStr);
|
FlwImpl.CONFIG_LOGGER.warn("'backend' value '{}' is not a valid resource location", idStr);
|
||||||
return null;
|
return null;
|
||||||
|
@ -63,7 +63,7 @@ public class ForgeFlwConfig implements FlwConfig {
|
||||||
return client.workerThreads.get();
|
return client.workerThreads.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void registerSpecs(ModLoadingContext context) {
|
public void registerSpecs(ModContainer context) {
|
||||||
context.registerConfig(ModConfig.Type.CLIENT, clientSpec);
|
context.registerConfig(ModConfig.Type.CLIENT, clientSpec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ import dev.engine_room.flywheel.api.event.EndClientResourceReloadEvent;
|
||||||
import dev.engine_room.flywheel.impl.FlwImpl;
|
import dev.engine_room.flywheel.impl.FlwImpl;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.server.packs.resources.ReloadableResourceManager;
|
import net.minecraft.server.packs.resources.ReloadableResourceManager;
|
||||||
import net.neoforged.fml.ModLoader;
|
import net.neoforged.neoforge.common.NeoForge;
|
||||||
|
|
||||||
@Mixin(Minecraft.class)
|
@Mixin(Minecraft.class)
|
||||||
abstract class MinecraftMixin {
|
abstract class MinecraftMixin {
|
||||||
|
@ -34,11 +34,11 @@ abstract class MinecraftMixin {
|
||||||
|
|
||||||
@Inject(method = "lambda$new$7", at = @At("HEAD"))
|
@Inject(method = "lambda$new$7", at = @At("HEAD"))
|
||||||
private void flywheel$onEndInitialResourceReload(@Coerce Object gameLoadCookie, Optional<Throwable> error, CallbackInfo ci) {
|
private void flywheel$onEndInitialResourceReload(@Coerce Object gameLoadCookie, Optional<Throwable> error, CallbackInfo ci) {
|
||||||
ModLoader.get().postEvent(new EndClientResourceReloadEvent((Minecraft) (Object) this, resourceManager, true, error));
|
NeoForge.EVENT_BUS.post(new EndClientResourceReloadEvent((Minecraft) (Object) this, resourceManager, true, error));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "lambda$reloadResourcePacks$39", at = @At("HEAD"))
|
@Inject(method = "lambda$reloadResourcePacks$39", at = @At("HEAD"))
|
||||||
private void flywheel$onEndManualResourceReload(boolean recovery, @Coerce Object gameLoadCookie, CompletableFuture<Void> completablefuture, Optional<Throwable> error, CallbackInfo ci) {
|
private void flywheel$onEndManualResourceReload(boolean recovery, @Coerce Object gameLoadCookie, CompletableFuture<Void> completablefuture, Optional<Throwable> error, CallbackInfo ci) {
|
||||||
ModLoader.get().postEvent(new EndClientResourceReloadEvent((Minecraft) (Object) this, resourceManager, false, error));
|
NeoForge.EVENT_BUS.post(new EndClientResourceReloadEvent((Minecraft) (Object) this, resourceManager, false, error));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
package dev.engine_room.flywheel.impl.mixin.sodium;
|
package dev.engine_room.flywheel.impl.mixin.sodium;
|
||||||
|
|
||||||
|
import org.embeddedt.embeddium.impl.render.chunk.compile.tasks.ChunkBuilderMeshingTask;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||||
|
|
||||||
import dev.engine_room.flywheel.lib.visual.VisualizationHelper;
|
import dev.engine_room.flywheel.lib.visual.VisualizationHelper;
|
||||||
import me.jellysquid.mods.sodium.client.render.chunk.compile.tasks.ChunkBuilderMeshingTask;
|
|
||||||
import net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher;
|
import net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher;
|
||||||
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer;
|
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
|
|
||||||
@Mixin(value = ChunkBuilderMeshingTask.class, remap = false)
|
@Mixin(value = ChunkBuilderMeshingTask.class, remap = false)
|
||||||
abstract class ChunkBuilderMeshingTaskMixin {
|
abstract class ChunkBuilderMeshingTaskMixin {
|
||||||
@Redirect(method = "execute", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/blockentity/BlockEntityRenderDispatcher;getRenderer(Lnet/minecraft/world/level/block/entity/BlockEntity;)Lnet/minecraft/client/renderer/blockentity/BlockEntityRenderer;", remap = true))
|
@Redirect(method = "execute(Lorg/embeddedt/embeddium/impl/render/chunk/compile/ChunkBuildContext;Lorg/embeddedt/embeddium/impl/util/task/CancellationToken;)Lorg/embeddedt/embeddium/impl/render/chunk/compile/ChunkBuildOutput;", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/blockentity/BlockEntityRenderDispatcher;getRenderer(Lnet/minecraft/world/level/block/entity/BlockEntity;)Lnet/minecraft/client/renderer/blockentity/BlockEntityRenderer;", remap = true))
|
||||||
private BlockEntityRenderer<?> flywheel$redirectGetRenderer(BlockEntityRenderDispatcher dispatcher, BlockEntity blockEntity) {
|
private BlockEntityRenderer<?> flywheel$redirectGetRenderer(BlockEntityRenderDispatcher dispatcher, BlockEntity blockEntity) {
|
||||||
if (VisualizationHelper.tryAddBlockEntity(blockEntity)) {
|
if (VisualizationHelper.tryAddBlockEntity(blockEntity)) {
|
||||||
return null;
|
return null;
|
||||||
|
|
Loading…
Reference in a new issue