Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port to 1.21.1 #240

Open
wants to merge 64 commits into
base: 1.20/dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
56b0fce
Port to 1.20.4
IThundxr May 5, 2024
8c61f3f
Obfuscated Obfuscation
IThundxr May 12, 2024
cbdc318
fixme fixedme fixed...
IThundxr May 12, 2024
68d40b9
port rebase fixes
IThundxr May 13, 2024
25a5522
fix deps
IThundxr Jun 4, 2024
4190ac7
fix issues here and there
IThundxr Jun 7, 2024
52d99e3
fix param name
IThundxr Jun 7, 2024
47e80a6
optimize imports
IThundxr Jun 7, 2024
349e7b3
fix mixin
IThundxr Jun 7, 2024
045771d
fix param names
IThundxr Jun 7, 2024
a9127be
fix instance textures
IThundxr Jun 7, 2024
a9c4e5c
Merge branch 'refs/heads/1.20/dev' into feat/multi-loader-1.20.4
IThundxr Jul 3, 2024
eccbfbc
build: update dependencies
IThundxr Jul 10, 2024
d587ec0
1.21 Port I
IThundxr Jul 10, 2024
d092417
1.21 Port II
IThundxr Jul 10, 2024
e374365
1.21 Port III
IThundxr Jul 10, 2024
10d032c
1.21 Port IV
IThundxr Jul 10, 2024
dfbd451
1.21 Port V
IThundxr Jul 10, 2024
1cce5da
Mixin Fixin'
IThundxr Jul 15, 2024
eeb6e0f
style: javadoc fixes
IThundxr Jul 15, 2024
1d9f96a
string substitution fixes
IThundxr Jul 15, 2024
6533723
feat(api): Make PartialModel's use RL's instead of MRL's
IThundxr Jul 15, 2024
246939b
Merge remote-tracking branch 'refs/remotes/upstream/1.20/dev' into fe…
IThundxr Jul 19, 2024
5e64224
Merge remote-tracking branch 'refs/remotes/upstream/1.20/dev' into fe…
IThundxr Jul 28, 2024
44c2f78
merge: post merge fixes & porting
IThundxr Jul 28, 2024
b55afc9
Merge remote-tracking branch 'refs/remotes/upstream/1.20/dev' into fe…
IThundxr Jul 28, 2024
68393d1
fix(mixins): broken LevelRenderer injector
IThundxr Jul 29, 2024
475b1d8
fix view -IMS
IThundxr Aug 10, 2024
f2c0b79
uncomment the comments
IThundxr Aug 10, 2024
5313585
update neoforge & fix mixins
IThundxr Aug 11, 2024
44f045b
Fix lighting
IThundxr Aug 15, 2024
4e1a4b6
fix jittery visual animations
IThundxr Aug 17, 2024
c32fccc
Sodium 0.6
IThundxr Aug 22, 2024
6cf9f36
iris support
IThundxr Aug 23, 2024
a932d5d
Merge remote-tracking branch 'upstream/1.20/dev' into feat/multi-load…
IThundxr Aug 23, 2024
0919c0f
Merge remote-tracking branch 'upstream/1.20/dev' into feat/multi-load…
IThundxr Aug 23, 2024
3453715
forge porting
IThundxr Aug 23, 2024
42290b2
Merge remote-tracking branch 'upstream/1.20/dev' into feat/multi-load…
IThundxr Sep 14, 2024
fc61ff1
Add sodium 0.6 compat
IThundxr Sep 14, 2024
3176f1d
Fix issues
IThundxr Sep 14, 2024
9365011
fix remapping
IThundxr Sep 14, 2024
e7e3579
Merge branch '1.20/dev' into feat/multi-loader-1.21
IThundxr Sep 20, 2024
556e11a
Fix compile errors
IThundxr Sep 20, 2024
a3bb585
Merge branch '1.20/dev' into feat/multi-loader-1.21
IThundxr Sep 22, 2024
42bdd36
port changes to 1.21
IThundxr Sep 22, 2024
08866ed
Merge branch '1.20/dev' into feat/multi-loader-1.21
IThundxr Oct 2, 2024
ae4e4e7
post merge fixes
IThundxr Oct 2, 2024
05b82b5
Fix sprite UVs being messed up
IThundxr Oct 6, 2024
6cc2b74
Fix iris compat
IThundxr Oct 6, 2024
b408191
Build against 1.21.1
IThundxr Oct 10, 2024
93c1163
Last fixes
IThundxr Oct 11, 2024
178dd6c
address review
IThundxr Oct 12, 2024
6f946fc
Rename class
IThundxr Oct 12, 2024
dc3e264
post to correct bus
IThundxr Oct 12, 2024
e39554e
fix breaks formatting
IThundxr Oct 12, 2024
f6ca19c
bring back comment
IThundxr Oct 12, 2024
68e545b
forgeEventBus -> gameEventBus
IThundxr Oct 12, 2024
aeb9781
Remove unused check
IThundxr Oct 12, 2024
008b098
fix meshemitter
IThundxr Oct 14, 2024
fa57f34
formatting changes
IThundxr Oct 14, 2024
c705fdf
address requested changes
IThundxr Oct 14, 2024
68d1504
address requested changes
IThundxr Oct 14, 2024
07e66bb
Merge remote-tracking branch 'upstream/1.20/dev' into feat/multi-load…
IThundxr Oct 29, 2024
ad93839
post merge fixes
IThundxr Oct 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
strategy:
matrix:
java: [
17 # Current Java LTS & minimum supported by Minecraft
21 # Current Java LTS & minimum supported by Minecraft
]
os: [ ubuntu-latest ]
runs-on: ${{ matrix.os }}
Expand Down
4 changes: 2 additions & 2 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ plugins {
repositories {
gradlePluginPortal()
mavenCentral()
maven("https://maven.minecraftforge.net/") {
name = "MinecraftForge"
maven("https://maven.neoforged.net/releases/") {
name = "NeoForged"
}
maven("https://maven.architectury.dev/") {
name = "Architectury"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ class SubprojectPlugin: Plugin<Project> {
}
}

val processResourcesExpandFiles = listOf("pack.mcmeta", "fabric.mod.json", "META-INF/mods.toml")
val processResourcesExpandFiles = listOf("pack.mcmeta", "fabric.mod.json", "META-INF/neoforge.mods.toml")

val processResourcesExpandProperties = listOf(
"mod_id",
Expand All @@ -180,6 +180,6 @@ val processResourcesExpandProperties = listOf(
"minecraft_semver_version_range",
"minecraft_maven_version_range",
"fabric_api_version_range",
"forge_version_range",
"neoforge_version_range",
)

2 changes: 2 additions & 0 deletions common/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ jarSets {
dependencies {
modCompileOnly("net.fabricmc:fabric-loader:${property("fabric_loader_version")}")

modCompileOnly("maven.modrinth:sodium:${property("sodium_version")}-fabric")

testImplementation("org.junit.jupiter:junit-jupiter:5.8.1")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ private Flywheel() {
}

public static ResourceLocation rl(String path) {
return new ResourceLocation(ID, path);
return ResourceLocation.fromNamespaceAndPath(ID, path);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public interface RenderContext {

RenderBuffers buffers();

PoseStack stack();
Matrix4fc modelView();

Matrix4fc projection();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public static void update(RenderContext context) {
var camY = (float) (cameraPos.y - renderOrigin.getY());
var camZ = (float) (cameraPos.z - renderOrigin.getZ());

VIEW.set(context.stack().last().pose());
VIEW.set(context.modelView());
VIEW.translate(-camX, -camY, -camZ);
PROJECTION.set(context.projection());
VIEW_PROJECTION.set(context.viewProjection());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public ShaderSources(ResourceManager manager) {
}

private static ResourceLocation locationWithoutFlywheelPrefix(ResourceLocation loc) {
return new ResourceLocation(loc.getNamespace(), loc.getPath()
return ResourceLocation.fromNamespaceAndPath(loc.getNamespace(), loc.getPath()
.substring(SHADER_DIR.length()));
}

Expand Down
2 changes: 1 addition & 1 deletion common/src/backend/resources/flywheel.backend.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"required": true,
"minVersion": "0.8",
"package": "dev.engine_room.flywheel.backend.mixin",
"compatibilityLevel": "JAVA_17",
"compatibilityLevel": "JAVA_21",
"refmap": "backend-flywheel.refmap.json",
"client": [
"AbstractClientPlayerAccessor",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public interface FlwLibLink {

Map<String, ModelPart> getModelPartChildren(ModelPart part);

void compileModelPart(ModelPart part, PoseStack.Pose pose, VertexConsumer consumer, int light, int overlay, float red, float green, float blue, float alpha);
void compileModelPart(ModelPart part, PoseStack.Pose pose, VertexConsumer consumer, int light, int overlay, int color);

Deque<PoseStack.Pose> getPoseStack(PoseStack stack);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public static Material getItemMaterial(RenderType renderType) {
if (renderType == Sheets.translucentCullBlockSheet() || renderType == Sheets.translucentItemSheet()) {
return Materials.CUTOUT_BLOCK;
}
if (renderType == RenderType.glint() || renderType == RenderType.glintDirect()) {
if (renderType == RenderType.glint() || renderType == RenderType.glintTranslucent()) {
return Materials.GLINT;
}
if (renderType == RenderType.entityGlint() || renderType == RenderType.entityGlintDirect()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import org.jetbrains.annotations.Nullable;
import org.lwjgl.system.MemoryUtil;

import com.mojang.blaze3d.vertex.BufferBuilder;
import com.mojang.blaze3d.vertex.MeshData;

import dev.engine_room.flywheel.lib.memory.MemoryBlock;
import dev.engine_room.flywheel.lib.model.SimpleQuadMesh;
Expand All @@ -16,15 +16,15 @@ final class MeshHelper {
private MeshHelper() {
}

public static SimpleQuadMesh blockVerticesToMesh(BufferBuilder.RenderedBuffer buffer, @Nullable String meshDescriptor) {
BufferBuilder.DrawState drawState = buffer.drawState();
public static SimpleQuadMesh blockVerticesToMesh(MeshData data, @Nullable String meshDescriptor) {
MeshData.DrawState drawState = data.drawState();
int vertexCount = drawState.vertexCount();
long srcStride = drawState.format().getVertexSize();

VertexView vertexView = new NoOverlayVertexView();
long dstStride = vertexView.stride();

ByteBuffer src = buffer.vertexBuffer();
ByteBuffer src = data.vertexBuffer();
MemoryBlock dst = MemoryBlock.mallocTracked((long) vertexCount * dstStride);
long srcPtr = MemoryUtil.memAddress(src);
long dstPtr = dst.ptr();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,67 +26,46 @@ public void clear() {
}

@Override
public VertexConsumer vertex(double x, double y, double z) {
public VertexConsumer addVertex(float x, float y, float z) {
Matrix4f matrix = poseStack.last().pose();
float fx = (float) x;
float fy = (float) y;
float fz = (float) z;
delegate.vertex(
MatrixMath.transformPositionX(matrix, fx, fy, fz),
MatrixMath.transformPositionY(matrix, fx, fy, fz),
MatrixMath.transformPositionZ(matrix, fx, fy, fz));
delegate.addVertex(
MatrixMath.transformPositionX(matrix, x, y, z),
MatrixMath.transformPositionY(matrix, x, y, z),
MatrixMath.transformPositionZ(matrix, x, y, z));
return this;
}

@Override
public VertexConsumer color(int red, int green, int blue, int alpha) {
delegate.color(red, green, blue, alpha);
public VertexConsumer setColor(int red, int green, int blue, int alpha) {
delegate.setColor(red, green, blue, alpha);
return this;
}

@Override
public VertexConsumer uv(float u, float v) {
delegate.uv(u, v);
public VertexConsumer setUv(float u, float v) {
delegate.setUv(u, v);
return this;
}

@Override
public VertexConsumer overlayCoords(int u, int v) {
delegate.overlayCoords(u, v);
public VertexConsumer setUv1(int u, int v) {
delegate.setUv1(u, v);
return this;
}

@Override
public VertexConsumer uv2(int u, int v) {
delegate.uv2(u, v);
public VertexConsumer setUv2(int u, int v) {
delegate.setUv2(u, v);
return this;
}

@Override
public VertexConsumer normal(float x, float y, float z) {
public VertexConsumer setNormal(float x, float y, float z) {
Matrix3f matrix = poseStack.last().normal();
float fx = (float) x;
float fy = (float) y;
float fz = (float) z;
delegate.normal(
MatrixMath.transformNormalX(matrix, fx, fy, fz),
MatrixMath.transformNormalY(matrix, fx, fy, fz),
MatrixMath.transformNormalZ(matrix, fx, fy, fz));
delegate.setNormal(
MatrixMath.transformNormalX(matrix, x, y, z),
MatrixMath.transformNormalY(matrix, x, y, z),
MatrixMath.transformNormalZ(matrix, x, y, z));
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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ private static Mesh compile(ModelPart modelPart, ThreadLocalObjects objects) {
}

VertexWriter vertexWriter = objects.vertexWriter;
FlwLibLink.INSTANCE.compileModelPart(modelPart, IDENTITY_POSE, vertexWriter, LightTexture.FULL_BRIGHT, OverlayTexture.NO_OVERLAY, 1.0F, 1.0F, 1.0F, 1.0F);
FlwLibLink.INSTANCE.compileModelPart(modelPart, IDENTITY_POSE, vertexWriter, LightTexture.FULL_BRIGHT, OverlayTexture.NO_OVERLAY, 0xFFFFFFFF);
MemoryBlock data = vertexWriter.copyDataAndReset();

VertexView vertexView = new PosTexNormalVertexView();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,62 +23,62 @@ public VertexWriter() {
}

@Override
public VertexConsumer vertex(double x, double y, double z) {
public VertexConsumer addVertex(float x, float y, float z) {
if (!filledPosition) {
long ptr = vertexPtr();
MemoryUtil.memPutFloat(ptr, (float) x);
MemoryUtil.memPutFloat(ptr + 4, (float) y);
MemoryUtil.memPutFloat(ptr + 8, (float) z);
MemoryUtil.memPutFloat(ptr, x);
MemoryUtil.memPutFloat(ptr + 4, y);
MemoryUtil.memPutFloat(ptr + 8, z);
filledPosition = true;
}
return this;
return endVertexIfNeeded();
}

@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 this;
return endVertexIfNeeded();
}

@Override
public VertexConsumer uv(float u, float v) {
public VertexConsumer setUv(float u, float v) {
if (!filledTexture) {
long ptr = vertexPtr();
MemoryUtil.memPutFloat(ptr + 12, u);
MemoryUtil.memPutFloat(ptr + 16, v);
filledTexture = true;
}
return this;
return endVertexIfNeeded();
}

@Override
public VertexConsumer overlayCoords(int u, int v) {
public VertexConsumer setUv1(int u, int v) {
// ignore overlay
return this;
return endVertexIfNeeded();
}

@Override
public VertexConsumer uv2(int u, int v) {
public VertexConsumer setUv2(int u, int v) {
// ignore light
return this;
return endVertexIfNeeded();
}

@Override
public VertexConsumer normal(float x, float y, float z) {
public VertexConsumer setNormal(float x, float y, float z) {
if (!filledNormal) {
long ptr = vertexPtr();
MemoryUtil.memPutByte(ptr + 20, DataPacker.packNormI8(x));
MemoryUtil.memPutByte(ptr + 21, DataPacker.packNormI8(y));
MemoryUtil.memPutByte(ptr + 22, DataPacker.packNormI8(z));
filledNormal = true;
}
return this;
return endVertexIfNeeded();
}

@Override
public void endVertex() {
public VertexConsumer endVertexIfNeeded() {
if (!filledPosition || !filledTexture || !filledNormal) {
throw new IllegalStateException("Not filled all elements of the vertex");
// We do not throw here as that matched what vanilla does
return this;
IThundxr marked this conversation as resolved.
Show resolved Hide resolved
}

filledPosition = false;
Expand All @@ -91,14 +91,8 @@ public void endVertex() {
if (byteSize > capacity) {
data = data.realloc(capacity * 2);
}
}

@Override
public void defaultColor(int red, int green, int blue, int alpha) {
}

@Override
public void unsetDefaultColor() {
return this;
}

private long vertexPtr() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ private ResourceUtil() {
}

/**
* Same as {@link ResourceLocation#ResourceLocation(String)}, but defaults to Flywheel namespace.
* Same as {@link ResourceLocation#parse(String)}, but defaults to Flywheel namespace.
*/
public static ResourceLocation parseFlywheelDefault(String location) {
String namespace = Flywheel.ID;
Expand All @@ -30,7 +30,7 @@ public static ResourceLocation parseFlywheelDefault(String location) {
}
}

return new ResourceLocation(namespace, path);
return ResourceLocation.fromNamespaceAndPath(namespace, path);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ private VertexTransformations() {
}

public static void retexture(MutableVertexList vertexList, int index, TextureAtlasSprite sprite) {
vertexList.u(index, sprite.getU(vertexList.u(index) * 16));
vertexList.v(index, sprite.getV(vertexList.v(index) * 16));
vertexList.u(index, sprite.getU(vertexList.u(index)));
vertexList.v(index, sprite.getV(vertexList.v(index)));
}

public static void retexture(MutableVertexList vertexList, TextureAtlasSprite sprite) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
* The shadow will be cast on blocks at most {@code min(radius, 2 * strength)} blocks below the entity.</p>
*/
public final class ShadowComponent implements EntityComponent {
private static final ResourceLocation SHADOW_TEXTURE = new ResourceLocation("textures/misc/shadow.png");
private static final ResourceLocation SHADOW_TEXTURE = ResourceLocation.withDefaultNamespace("textures/misc/shadow.png");
private static final Material SHADOW_MATERIAL = SimpleMaterial.builder()
.texture(SHADOW_TEXTURE)
.mipmap(false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ public Map<String, ModelPart> getModelPartChildren(ModelPart part) {
}

@Override
public void compileModelPart(ModelPart part, PoseStack.Pose pose, VertexConsumer consumer, int light, int overlay, float red, float green, float blue, float alpha) {
((ModelPartAccessor) (Object) part).flywheel$compile(pose, consumer, light, overlay, red, green, blue, alpha);
public void compileModelPart(ModelPart part, PoseStack.Pose pose, VertexConsumer consumer, int light, int overlay, int color) {
((ModelPartAccessor) (Object) part).flywheel$compile(pose, consumer, light, overlay, color);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package dev.engine_room.flywheel.impl.compat;

import dev.engine_room.flywheel.impl.FlwImplXplat;

public enum CompatMods {
IRIS("iris"),
SODIUM("sodium");

public final boolean isLoaded;

CompatMods(String modId) {
isLoaded = FlwImplXplat.INSTANCE.isModLoaded(modId);
}
}
Loading