diff --git a/build.gradle b/build.gradle index cacb235..24af098 100644 --- a/build.gradle +++ b/build.gradle @@ -30,10 +30,7 @@ subprojects { // The following line declares the mojmap mappings, you may use other mappings as well // mappings loom.officialMojangMappings() // The following line declares the yarn mappings you may select this one as well. - mappings loom.layered { - mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2" - mappings "dev.architectury:yarn-mappings-patch-neoforge:${rootProject.minecraft_version}+build.4" - } + mappings loom.officialMojangMappings() } } diff --git a/common/src/main/java/io/github/kosmx/bendylib/ModelPartAccessor.java b/common/src/main/java/io/github/kosmx/bendylib/ModelPartAccessor.java index 1b859b8..8aaff24 100644 --- a/common/src/main/java/io/github/kosmx/bendylib/ModelPartAccessor.java +++ b/common/src/main/java/io/github/kosmx/bendylib/ModelPartAccessor.java @@ -2,7 +2,7 @@ import io.github.kosmx.bendylib.impl.DummyCuboid; import io.github.kosmx.bendylib.impl.accessors.IModelPartAccessor; -import net.minecraft.client.model.ModelPart; +import net.minecraft.client.model.geom.ModelPart; import java.util.*; @@ -12,7 +12,7 @@ */ public final class ModelPartAccessor { - public static Map getChildren(ModelPart modelPart){ + public static Map getChildren(ModelPart modelPart){ return ((IModelPartAccessor)modelPart).getChildren(); } @@ -41,7 +41,7 @@ public static Optional optionalGetCuboid(ModelPart modelPart, int return Optional.of((MutableCuboid)getCuboids(modelPart).get(index)); } - public static List getCuboids(ModelPart modelPart){ + public static List getCuboids(ModelPart modelPart){ return ((IModelPartAccessor)modelPart).getCuboids(); } diff --git a/common/src/main/java/io/github/kosmx/bendylib/MutableCuboid.java b/common/src/main/java/io/github/kosmx/bendylib/MutableCuboid.java index 27f929f..5a01ced 100644 --- a/common/src/main/java/io/github/kosmx/bendylib/MutableCuboid.java +++ b/common/src/main/java/io/github/kosmx/bendylib/MutableCuboid.java @@ -1,7 +1,7 @@ package io.github.kosmx.bendylib; import io.github.kosmx.bendylib.impl.ICuboid; -import net.minecraft.util.Pair; +import net.minecraft.util.Tuple; import org.jetbrains.annotations.Nullable; public interface MutableCuboid { @@ -26,7 +26,7 @@ public interface MutableCuboid { * @return null, if no active */ @Nullable - Pair getActiveMutator(); + Tuple getActiveMutator(); /** * Check if mutator with key exists diff --git a/common/src/main/java/io/github/kosmx/bendylib/MutableModelPart.java b/common/src/main/java/io/github/kosmx/bendylib/MutableModelPart.java index 4f4b11e..572671c 100644 --- a/common/src/main/java/io/github/kosmx/bendylib/MutableModelPart.java +++ b/common/src/main/java/io/github/kosmx/bendylib/MutableModelPart.java @@ -1,11 +1,11 @@ package io.github.kosmx.bendylib; +import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.vertex.VertexConsumer; import io.github.kosmx.bendylib.impl.ICuboid; import it.unimi.dsi.fastutil.objects.ObjectArrayList; import it.unimi.dsi.fastutil.objects.ObjectList; -import net.minecraft.client.model.ModelPart; -import net.minecraft.client.render.VertexConsumer; -import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.client.model.geom.ModelPart; import org.jetbrains.annotations.Nullable; import java.util.List; @@ -26,23 +26,23 @@ public abstract class MutableModelPart extends ModelPart { protected final ObjectList iCuboids = new ObjectArrayList<>(); - public MutableModelPart(List cuboids, Map children) { + public MutableModelPart(List cuboids, Map children) { super(cuboids, children); } @Override - public void render(MatrixStack matrices, VertexConsumer vertices, int light, int overlay, int color) { + public void render(PoseStack matrices, VertexConsumer vertices, int light, int overlay, int color) { super.render(matrices, vertices, light, overlay); if(!iCuboids.isEmpty()){ - matrices.push(); - this.rotate(matrices); - this.renderICuboids(matrices.peek(), vertices, light, overlay, color); - matrices.pop(); + matrices.pushPose(); + this.translateAndRotate(matrices); + this.renderICuboids(matrices.last(), vertices, light, overlay, color); + matrices.popPose(); } } - protected void renderICuboids(MatrixStack.Entry matrices, VertexConsumer vertexConsumer, int light, int overlay, int color) { + protected void renderICuboids(PoseStack.Pose matrices, VertexConsumer vertexConsumer, int light, int overlay, int color) { this.iCuboids.forEach((cuboid)-> cuboid.render(matrices, vertexConsumer, light, overlay, color)); } diff --git a/common/src/main/java/io/github/kosmx/bendylib/compat/tr7zw/TDSkinCompat.java b/common/src/main/java/io/github/kosmx/bendylib/compat/tr7zw/TDSkinCompat.java index e71b7df..a42bd9a 100644 --- a/common/src/main/java/io/github/kosmx/bendylib/compat/tr7zw/TDSkinCompat.java +++ b/common/src/main/java/io/github/kosmx/bendylib/compat/tr7zw/TDSkinCompat.java @@ -8,8 +8,8 @@ import io.github.kosmx.bendylib.impl.IBendable; import io.github.kosmx.bendylib.impl.IPosWithOrigin; import io.github.kosmx.bendylib.impl.RememberingPos; -import net.minecraft.client.model.ModelPart; -import net.minecraft.util.math.Direction; +import net.minecraft.client.model.geom.ModelPart; +import net.minecraft.core.Direction; import org.joml.Vector3f; import org.joml.Vector4f; import org.slf4j.Logger; @@ -22,7 +22,7 @@ public static void init() throws ClassNotFoundException, NoClassDefFoundError { var sourceCuboidOptional = ModelPartAccessor.optionalGetCuboid(modelPart, 0); if (sourceCuboidOptional.isPresent() && sourceCuboidOptional.get().getActiveMutator() != null - && sourceCuboidOptional.get().getActiveMutator().getRight() instanceof BendableCuboid bendableSource) { + && sourceCuboidOptional.get().getActiveMutator().getB() instanceof BendableCuboid bendableSource) { class Bender extends BendyMeshTransformer implements MeshTransformer { @@ -51,13 +51,13 @@ public void transform(Vector3f vec3f, Vector4f[] vector4fs) { } @Override - public void transform(ModelPart.Cuboid cuboid) { + public void transform(ModelPart.Cube cuboid) { var sourceCuboid = sourceCuboidOptional.get(); var mutator = sourceCuboidOptional.get().getActiveMutator(); if (cuboid instanceof MutableCuboid mutableCuboid) { - if (!mutableCuboid.hasMutator(mutator.getLeft())) { - mutableCuboid.registerMutator(mutator.getLeft(), + if (!mutableCuboid.hasMutator(mutator.getA())) { + mutableCuboid.registerMutator(mutator.getA(), data -> new BendableCuboid.Builder().setDirection(getBendDirection()).build(data, (sides, positions, minX, minY, minZ, maxX, maxY, maxZ, fixX, fixY, fixZ, direction, basePlane, otherPlane, fullSize) -> @@ -80,7 +80,7 @@ public void transform(Vector3f vec3f, Vector4f[] vector4fs) { } @Override - public void transform(ModelPart.Cuboid cuboid) { + public void transform(ModelPart.Cube cuboid) { ((MutableCuboid) cuboid).getAndActivateMutator(null); } }; @@ -99,7 +99,7 @@ public static Vector3f calculateNormal(Vector4f[] vertices) { vecA.add(buf); vecA.cross(vecB); //Return the cross product, if it's zero then return anything non-zero to not cause crash... - return vecA.normalize().isFinite() ? vecA : Direction.NORTH.getUnitVector(); + return vecA.normalize().isFinite() ? vecA : Direction.NORTH.step(); } private static class ModifiedBendableCuboid extends BendableCuboid { diff --git a/common/src/main/java/io/github/kosmx/bendylib/impl/BendableCuboid.java b/common/src/main/java/io/github/kosmx/bendylib/impl/BendableCuboid.java index 48d8ae2..dbcd398 100644 --- a/common/src/main/java/io/github/kosmx/bendylib/impl/BendableCuboid.java +++ b/common/src/main/java/io/github/kosmx/bendylib/impl/BendableCuboid.java @@ -1,11 +1,11 @@ package io.github.kosmx.bendylib.impl; +import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.vertex.VertexConsumer; import io.github.kosmx.bendylib.ICuboidBuilder; import io.github.kosmx.bendylib.impl.accessors.DirectionMutator; -import net.minecraft.client.model.ModelPart; -import net.minecraft.client.render.VertexConsumer; -import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.util.math.*; +import net.minecraft.client.model.geom.ModelPart; +import net.minecraft.core.Direction; import org.joml.Matrix4f; import org.joml.Vector3f; import org.joml.Vector4f; @@ -181,10 +181,10 @@ public BendableCuboid build(Data data, BuildableBendable builder){ createAndAddQuads(planes, positions, new Vector3f[]{vertex6, vertex2, vertex7}, l, q, n, r, data.textureWidth, data.textureHeight, data.mirror, data); createAndAddQuads(planes, positions, new Vector3f[]{vertex5, vertex6, vertex8}, n, q, o, r, data.textureWidth, data.textureHeight, data.mirror, data); - Plane aPlane = new Plane(direction.getUnitVector(), vertex7); - Plane bPlane = new Plane(direction.getUnitVector(), vertex1); + Plane aPlane = new Plane(direction.step(), vertex7); + Plane bPlane = new Plane(direction.step(), vertex1); boolean bl = direction == Direction.UP || direction == Direction.SOUTH || direction == Direction.EAST; - float fullSize = - direction.getUnitVector().dot(vertex1) + direction.getUnitVector().dot(vertex7); + float fullSize = - direction.step().dot(vertex1) + direction.step().dot(vertex7); float bendX = ((float) data.sizeX + data.x + data.x)/2; float bendY = ((float) data.sizeY + data.y + data.y)/2; float bendZ = ((float) data.sizeZ + data.z + data.z)/2; @@ -261,7 +261,7 @@ public Matrix4f setRotationDeg(float axis, float val){ } @Override - public void render(MatrixStack.Entry matrices, VertexConsumer vertexConsumer, int light, int overlay, int color) { + public void render(PoseStack.Pose matrices, VertexConsumer vertexConsumer, int light, int overlay, int color) { for(Quad quad:sides){ quad.render(matrices, vertexConsumer, light, overlay, color); } @@ -305,16 +305,16 @@ public Quad(RememberingPos[] vertices, float u1, float v1, float u2, float v2, f } } } - public void render(MatrixStack.Entry matrices, VertexConsumer vertexConsumer, int light, int overlay, int color){ + public void render(PoseStack.Pose matrices, VertexConsumer vertexConsumer, int light, int overlay, int color){ Vector3f direction = this.getDirection(); - direction.mul(matrices.getNormalMatrix()); + direction.mul(matrices.normal()); for (int i = 0; i != 4; ++i){ IVertex vertex = this.vertices[i]; Vector3f vertexPos = vertex.getPos(); Vector4f pos = new Vector4f(vertexPos.x/16f, vertexPos.y/16f, vertexPos.z/16f, 1); - pos.mul(matrices.getPositionMatrix()); - vertexConsumer.vertex(pos.x, pos.y, pos.z, color, vertex.getU(), vertex.getV(), overlay, light, direction.x, direction.y, direction.z); + pos.mul(matrices.pose()); + vertexConsumer.addVertex(pos.x, pos.y, pos.z, color, vertex.getU(), vertex.getV(), overlay, light, direction.x, direction.y, direction.z); } } @@ -333,18 +333,18 @@ private Vector3f getDirection(){ vecA.add(buf); vecA.cross(vecB); // Return the cross product, if it's zero then return anything non-zero to not cause crash... - return vecA.normalize().isFinite() ? vecA : Direction.NORTH.getUnitVector(); + return vecA.normalize().isFinite() ? vecA : Direction.NORTH.step(); } @SuppressWarnings({"ConstantConditions"}) - private ModelPart.Quad toModelPart_Quad(){ - ModelPart.Quad quad = new ModelPart.Quad(new ModelPart.Vertex[]{ + private ModelPart.Polygon toModelPart_Quad(){ + ModelPart.Polygon quad = new ModelPart.Polygon(new ModelPart.Vertex[]{ vertices[0].toMojVertex(), vertices[1].toMojVertex(), vertices[2].toMojVertex(), vertices[3].toMojVertex() }, u1, v1, u2, v2, su, sv, false, Direction.UP); - ((DirectionMutator)quad).setDirection(this.getDirection()); + ((DirectionMutator)quad).bendy_lib$setDirection(this.getDirection()); return quad; } } @@ -355,8 +355,8 @@ public boolean disableAfterDraw() { } @Override - public List getQuads() { - List sides = new ArrayList<>(); + public List getQuads() { + List sides = new ArrayList<>(); for(Quad quad : this.sides){ sides.add(quad.toModelPart_Quad()); } diff --git a/common/src/main/java/io/github/kosmx/bendylib/impl/DummyCuboid.java b/common/src/main/java/io/github/kosmx/bendylib/impl/DummyCuboid.java index 229fdb9..f248eff 100644 --- a/common/src/main/java/io/github/kosmx/bendylib/impl/DummyCuboid.java +++ b/common/src/main/java/io/github/kosmx/bendylib/impl/DummyCuboid.java @@ -2,7 +2,7 @@ import io.github.kosmx.bendylib.ICuboidBuilder; import io.github.kosmx.bendylib.MutableCuboid; -import net.minecraft.util.Pair; +import net.minecraft.util.Tuple; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Nullable; @@ -30,7 +30,7 @@ public boolean unregisterMutator(String name) { @Nullable @Override - public Pair getActiveMutator() { + public Tuple getActiveMutator() { return null; } diff --git a/common/src/main/java/io/github/kosmx/bendylib/impl/IBendable.java b/common/src/main/java/io/github/kosmx/bendylib/impl/IBendable.java index afc9b36..1826aba 100644 --- a/common/src/main/java/io/github/kosmx/bendylib/impl/IBendable.java +++ b/common/src/main/java/io/github/kosmx/bendylib/impl/IBendable.java @@ -1,6 +1,6 @@ package io.github.kosmx.bendylib.impl; -import net.minecraft.util.math.*; +import net.minecraft.core.Direction; import org.joml.*; import java.lang.Math; @@ -20,7 +20,7 @@ public interface IBendable { */ default Matrix4f applyBend(float bendAxis, float bendValue, IterableRePos posSupplier){ Vector3f axis = new Vector3f((float) Math.cos(bendAxis), 0, (float) Math.sin(bendAxis)); - Matrix3f matrix3f = new Matrix3f().set(getBendDirection().getRotationQuaternion()); + Matrix3f matrix3f = new Matrix3f().set(getBendDirection().getRotation()); axis.mul(matrix3f); Matrix4f transformMatrix = new Matrix4f(); @@ -34,7 +34,7 @@ default Matrix4f applyBend(float bendAxis, float bendValue, IterableRePos posSup Plane basePlane = getBasePlane(); Plane otherPlane = getOtherSidePlane(); - directionUnit = this.getBendDirection().getUnitVector(); + directionUnit = this.getBendDirection().step(); directionUnit.cross(axis); //parallel to the bend's axis and to the cube's bend direction Plane bendPlane = new Plane(directionUnit, new Vector3f(this.getBendX(), this.getBendY(), this.getBendZ())); @@ -48,7 +48,7 @@ default Matrix4f applyBend(float bendAxis, float bendValue, IterableRePos posSup float distFromBase = basePlane.distanceTo(newPos); float distFromOther = otherPlane.distanceTo(newPos); double s = Math.tan(bendValue/2)*distFromBend; - Vector3f x = getBendDirection().getUnitVector(); + Vector3f x = getBendDirection().step(); if(Math.abs(distFromBase) < Math.abs(distFromOther)){ x.mul((float) (-distFromBase/halfSize*s)); newPos.add(x); diff --git a/common/src/main/java/io/github/kosmx/bendylib/impl/ICuboid.java b/common/src/main/java/io/github/kosmx/bendylib/impl/ICuboid.java index 001a3ad..bb0f1d8 100644 --- a/common/src/main/java/io/github/kosmx/bendylib/impl/ICuboid.java +++ b/common/src/main/java/io/github/kosmx/bendylib/impl/ICuboid.java @@ -1,8 +1,9 @@ package io.github.kosmx.bendylib.impl; -import net.minecraft.client.model.ModelPart; -import net.minecraft.client.render.VertexConsumer; -import net.minecraft.client.util.math.MatrixStack; + +import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.vertex.VertexConsumer; +import net.minecraft.client.model.geom.ModelPart; import java.util.List; @@ -14,15 +15,15 @@ public interface ICuboid { /** - * See {@link BendableCuboid#render(MatrixStack.Entry, VertexConsumer, float, float, float, float, int, int)} how to do it - * Or you can check the original MC code {@link net.minecraft.client.model.ModelPart#render(MatrixStack, VertexConsumer, int, int)} + * See {@link BendableCuboid#render(PoseStack.Pose, VertexConsumer, int, int, int)} how to do it + * Or you can check the original MC code {@link ModelPart#compile(PoseStack.Pose, VertexConsumer, int, int, int)} * - * @param matrices Minecraft's Matrix transformation + * @param pose Minecraft's Matrix transformation * @param vertexConsumer Minecraft Vertex consumer, add vertices to render * @param light light * @param overlay overlay */ - void render(MatrixStack.Entry matrices, VertexConsumer vertexConsumer, int light, int overlay, int color); + void render(PoseStack.Pose pose, VertexConsumer vertexConsumer, int light, int overlay, int color); /** * Copy custom state from another cuboid @@ -31,7 +32,7 @@ public interface ICuboid { void copyState(ICuboid other); /** - * Disable mutation after invoking {@link ICuboid#render(MatrixStack.Entry, VertexConsumer, float, float, float, float, int, int)} + * Disable mutation after invoking {@link ICuboid#render(PoseStack.Pose, VertexConsumer, int, int, int)} * @return true or false... */ default boolean disableAfterDraw(){ @@ -39,11 +40,11 @@ default boolean disableAfterDraw(){ } /** - * Convert custom Quads to {@link net.minecraft.client.model.ModelPart.Quad} + * Convert custom Quads to {@link net.minecraft.client.model.geom.ModelPart.Polygon} * Needed for Shader fix * @return list of converted quads */ - default List getQuads(){ + default List getQuads(){ return null; } } diff --git a/common/src/main/java/io/github/kosmx/bendylib/impl/IVertex.java b/common/src/main/java/io/github/kosmx/bendylib/impl/IVertex.java index 43fcf82..f766fd1 100644 --- a/common/src/main/java/io/github/kosmx/bendylib/impl/IVertex.java +++ b/common/src/main/java/io/github/kosmx/bendylib/impl/IVertex.java @@ -1,6 +1,6 @@ package io.github.kosmx.bendylib.impl; -import net.minecraft.client.model.ModelPart; +import net.minecraft.client.model.geom.ModelPart; import org.joml.Vector3f; /** diff --git a/common/src/main/java/io/github/kosmx/bendylib/impl/accessors/CuboidSideAccessor.java b/common/src/main/java/io/github/kosmx/bendylib/impl/accessors/CuboidSideAccessor.java index 10e6a7f..228411a 100644 --- a/common/src/main/java/io/github/kosmx/bendylib/impl/accessors/CuboidSideAccessor.java +++ b/common/src/main/java/io/github/kosmx/bendylib/impl/accessors/CuboidSideAccessor.java @@ -1,14 +1,15 @@ package io.github.kosmx.bendylib.impl.accessors; -import net.minecraft.client.model.ModelPart; + +import net.minecraft.client.model.geom.ModelPart; /** * For a shader fix. see {@link io.github.kosmx.bendylib.ModelPartAccessor.Workaround} */ public interface CuboidSideAccessor { - ModelPart.Quad[] getSides(); + ModelPart.Polygon[] getSides(); - void setSides(ModelPart.Quad[] sides); + void setSides(ModelPart.Polygon[] sides); void resetSides(); diff --git a/common/src/main/java/io/github/kosmx/bendylib/impl/accessors/DirectionMutator.java b/common/src/main/java/io/github/kosmx/bendylib/impl/accessors/DirectionMutator.java index 8f53822..20efd4e 100644 --- a/common/src/main/java/io/github/kosmx/bendylib/impl/accessors/DirectionMutator.java +++ b/common/src/main/java/io/github/kosmx/bendylib/impl/accessors/DirectionMutator.java @@ -4,5 +4,5 @@ import org.joml.Vector3f; public interface DirectionMutator { - void setDirection(Vector3f vec3f); + void bendy_lib$setDirection(Vector3f vec3f); } diff --git a/common/src/main/java/io/github/kosmx/bendylib/impl/accessors/IModelPartAccessor.java b/common/src/main/java/io/github/kosmx/bendylib/impl/accessors/IModelPartAccessor.java index d0b07c2..581df80 100644 --- a/common/src/main/java/io/github/kosmx/bendylib/impl/accessors/IModelPartAccessor.java +++ b/common/src/main/java/io/github/kosmx/bendylib/impl/accessors/IModelPartAccessor.java @@ -1,7 +1,7 @@ package io.github.kosmx.bendylib.impl.accessors; import io.github.kosmx.bendylib.ModelPartAccessor; -import net.minecraft.client.model.ModelPart; +import net.minecraft.client.model.geom.ModelPart; import java.util.List; import java.util.Map; @@ -11,7 +11,7 @@ */ public interface IModelPartAccessor { - List getCuboids(); + List getCuboids(); Map getChildren(); //easy to search in it :D diff --git a/common/src/main/java/io/github/kosmx/bendylib/mixin/CuboidMutator.java b/common/src/main/java/io/github/kosmx/bendylib/mixin/CuboidMutator.java index 574b3dd..c67defd 100644 --- a/common/src/main/java/io/github/kosmx/bendylib/mixin/CuboidMutator.java +++ b/common/src/main/java/io/github/kosmx/bendylib/mixin/CuboidMutator.java @@ -1,14 +1,14 @@ package io.github.kosmx.bendylib.mixin; +import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.vertex.VertexConsumer; import io.github.kosmx.bendylib.ICuboidBuilder; import io.github.kosmx.bendylib.MutableCuboid; import io.github.kosmx.bendylib.impl.accessors.CuboidSideAccessor; import io.github.kosmx.bendylib.impl.ICuboid; -import net.minecraft.client.model.ModelPart; -import net.minecraft.client.render.VertexConsumer; -import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.util.Pair; +import net.minecraft.client.model.geom.ModelPart; +import net.minecraft.util.Tuple; import org.jetbrains.annotations.Nullable; import org.spongepowered.asm.mixin.*; import org.spongepowered.asm.mixin.injection.At; @@ -20,16 +20,16 @@ import java.util.Set; @SuppressWarnings({"rawtypes", "unused"}) -@Mixin(ModelPart.Cuboid.class) +@Mixin(ModelPart.Cube.class) public class CuboidMutator implements MutableCuboid, CuboidSideAccessor { @Shadow @Final public float minX; @Shadow @Final public float minY; @Shadow @Final public float minZ; - @Mutable - @Shadow @Final private ModelPart.Quad[] sides; //Store the mutators and the mutator builders. + @Mutable + @Shadow @Final private ModelPart.Polygon[] polygons; @Unique private HashMap mutators = new HashMap<>(); @@ -37,7 +37,7 @@ public class CuboidMutator implements MutableCuboid, CuboidSideAccessor { private HashMap mutatorBuilders = new HashMap<>(); @Unique - private ModelPart.Quad[] originalQuads; + private ModelPart.Polygon[] originalQuads; @Unique private boolean isSidesSwapped = false; @@ -56,7 +56,7 @@ public class CuboidMutator implements MutableCuboid, CuboidSideAccessor { @Inject(method = "", at = @At(value = "RETURN")) private void constructor(int u, int v, float x, float y, float z, float sizeX, float sizeY, float sizeZ, float extraX, float extraY, float extraZ, boolean mirror, float textureWidth, float textureHeight, Set set, CallbackInfo ci){ partData = new ICuboidBuilder.Data(u, v, minX, minY, minZ, sizeX, sizeY, sizeZ, extraX, extraY, extraZ, mirror, textureWidth, textureHeight); - originalQuads = this.sides; + originalQuads = this.polygons; } @@ -84,8 +84,8 @@ public boolean unregisterMutator(String name) { @Nullable @Override - public Pair getActiveMutator() { - return activeMutator == null ? null : new Pair<>(activeMutatorID, activeMutator); + public Tuple getActiveMutator() { + return activeMutator == null ? null : new Tuple<>(activeMutatorID, activeMutator); } @Override @@ -131,17 +131,17 @@ public void copyStateFrom(MutableCuboid other) { activeMutatorID = null; } else { - if(this.getAndActivateMutator(other.getActiveMutator().getLeft()) != null){ - activeMutator.copyState(other.getActiveMutator().getRight()); + if(this.getAndActivateMutator(other.getActiveMutator().getA()) != null){ + activeMutator.copyState(other.getActiveMutator().getB()); } } } - @Inject(method = "renderCuboid", at = @At(value = "HEAD"), cancellable = true) - private void renderRedirect(MatrixStack.Entry entry, VertexConsumer vertexConsumer, int light, int overlay, int color, CallbackInfo ci){ + @Inject(method = "compile", at = @At(value = "HEAD"), cancellable = true) + private void renderRedirect(PoseStack.Pose entry, VertexConsumer vertexConsumer, int light, int overlay, int color, CallbackInfo ci){ if(getActiveMutator() != null){ - getActiveMutator().getRight().render(entry, vertexConsumer, light, overlay, color); - if(getActiveMutator().getRight().disableAfterDraw()) { + getActiveMutator().getB().render(entry, vertexConsumer, light, overlay, color); + if(getActiveMutator().getB().disableAfterDraw()) { activeMutator = null; //mutator lives only for one render cycle activeMutatorID = null; } @@ -152,28 +152,28 @@ private void renderRedirect(MatrixStack.Entry entry, VertexConsumer vertexConsum @Override public void doSideSwapping(){ if(this.getActiveMutator() != null){ - List sides = this.getActiveMutator().getRight().getQuads(); + List sides = this.getActiveMutator().getB().getQuads(); if(sides != null){ this.isSidesSwapped = true; - this.sides = sides.toArray(new ModelPart.Quad[4]); + this.polygons = sides.toArray(new ModelPart.Polygon[4]); } } } @Override - public ModelPart.Quad[] getSides() { - return this.sides; + public ModelPart.Polygon[] getSides() { + return this.polygons; } @Override - public void setSides(ModelPart.Quad[] sides) { + public void setSides(ModelPart.Polygon[] sides) { isSidesSwapped = true; - this.sides = sides; + this.polygons = sides; } @Override public void resetSides() { - this.sides = this.originalQuads; + this.polygons = this.originalQuads; isSidesSwapped = false; } } diff --git a/common/src/main/java/io/github/kosmx/bendylib/mixin/IModelPartMixin.java b/common/src/main/java/io/github/kosmx/bendylib/mixin/IModelPartMixin.java index f13db94..4f74ee7 100644 --- a/common/src/main/java/io/github/kosmx/bendylib/mixin/IModelPartMixin.java +++ b/common/src/main/java/io/github/kosmx/bendylib/mixin/IModelPartMixin.java @@ -2,13 +2,13 @@ import com.llamalad7.mixinextras.injector.wrapoperation.Operation; import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; +import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.vertex.VertexConsumer; import io.github.kosmx.bendylib.ModelPartAccessor; import io.github.kosmx.bendylib.MutableCuboid; import io.github.kosmx.bendylib.impl.accessors.CuboidSideAccessor; import io.github.kosmx.bendylib.impl.accessors.IModelPartAccessor; -import net.minecraft.client.model.ModelPart; -import net.minecraft.client.render.VertexConsumer; -import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.client.model.geom.ModelPart; import org.spongepowered.asm.mixin.*; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -23,7 +23,10 @@ public abstract class IModelPartMixin implements IModelPartAccessor { @Shadow @Final private Map children; - @Shadow @Final private List cuboids; + + @Shadow @Final private List cubes; + + @Shadow protected abstract void compile(PoseStack.Pose arg, VertexConsumer arg2, int i, int j, int k); @Unique private boolean hasMutatedCuboid = false; @@ -35,9 +38,9 @@ public abstract class IModelPartMixin implements IModelPartAccessor { private ModelPartAccessor.Workaround workaround = ModelPartAccessor.Workaround.VanillaDraw; @Override - public List getCuboids() { + public List getCuboids() { hasMutatedCuboid = true; - return cuboids; + return cubes; } @Override @@ -45,11 +48,11 @@ public Map getChildren() { return children; } - @Inject(method = "copyTransform", at = @At("RETURN")) + @Inject(method = "copyFrom", at = @At("RETURN")) private void copyTransformExtended(ModelPart part, CallbackInfo ci){ - if(((IModelPartAccessor)part).getCuboids() == null || cuboids == null) return; // Not copying state - Iterator iterator0 = ((IModelPartAccessor)part).getCuboids().iterator(); - Iterator iterator1 = cuboids.iterator(); + if(((IModelPartAccessor)part).getCuboids() == null || cubes == null) return; // Not copying state + Iterator iterator0 = ((IModelPartAccessor)part).getCuboids().iterator(); + Iterator iterator1 = cubes.iterator(); while (iterator0.hasNext() && iterator1.hasNext()){ MutableCuboid cuboid1 = (MutableCuboid) iterator1.next(); @@ -59,8 +62,8 @@ private void copyTransformExtended(ModelPart part, CallbackInfo ci){ } - @WrapOperation(method = "render(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumer;III)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/model/ModelPart;renderCuboids(Lnet/minecraft/client/util/math/MatrixStack$Entry;Lnet/minecraft/client/render/VertexConsumer;III)V"), require = 0) //It might not find anything if OF already broke the game - private void redirectRenderCuboids(ModelPart modelPart, MatrixStack.Entry entry, VertexConsumer vertexConsumer, int light, int overlay, int color, Operation original){ + @WrapOperation(method = "render(Lcom/mojang/blaze3d/vertex/PoseStack;Lcom/mojang/blaze3d/vertex/VertexConsumer;III)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/model/geom/ModelPart;compile(Lcom/mojang/blaze3d/vertex/PoseStack$Pose;Lcom/mojang/blaze3d/vertex/VertexConsumer;III)V"), require = 0) //It might not find anything if OF already broke the game + private void redirectRenderCuboids(ModelPart modelPart, PoseStack.Pose entry, VertexConsumer vertexConsumer, int light, int overlay, int color, Operation original){ redirectedFunction(modelPart, entry, vertexConsumer, light, overlay, color, original); } @@ -72,23 +75,25 @@ private void redirectOF(ModelPart modelPart, MatrixStack.Entry entry, VertexCons }*/ @Unique - private void redirectedFunction(ModelPart modelPart, MatrixStack.Entry entry, VertexConsumer vertexConsumer, int light, int overlay, int color, Operation original) { + private void redirectedFunction(ModelPart modelPart, PoseStack.Pose entry, VertexConsumer vertexConsumer, int light, int overlay, int color, Operation original) { if(workaround == ModelPartAccessor.Workaround.ExportQuads){ - for(ModelPart.Cuboid cuboid:cuboids){ + for(ModelPart.Cube cuboid:cubes){ ((CuboidSideAccessor)cuboid).doSideSwapping(); //:D } + original.call(modelPart, entry, vertexConsumer, light, overlay, color); - for(ModelPart.Cuboid cuboid:cuboids){ + + for(ModelPart.Cube cuboid:cubes){ ((CuboidSideAccessor)cuboid).resetSides(); //:D } } else if(workaround == ModelPartAccessor.Workaround.VanillaDraw){ - if(!hasMutatedCuboid || cuboids.size() == 1 && ((MutableCuboid)cuboids.get(0)).getActiveMutator() == null){ + if(!hasMutatedCuboid || cubes.size() == 1 && ((MutableCuboid)cubes.get(0)).getActiveMutator() == null){ original.call(modelPart, entry, vertexConsumer, light, overlay, color); } else { - for(ModelPart.Cuboid cuboid:cuboids){ - cuboid.renderCuboid(entry, vertexConsumer, light, overlay, color); + for(ModelPart.Cube cuboid:cubes){ + cuboid.compile(entry, vertexConsumer, light, overlay, color); } } } diff --git a/common/src/main/java/io/github/kosmx/bendylib/mixin/QuadMixin.java b/common/src/main/java/io/github/kosmx/bendylib/mixin/QuadMixin.java index fab3ed5..1002cad 100644 --- a/common/src/main/java/io/github/kosmx/bendylib/mixin/QuadMixin.java +++ b/common/src/main/java/io/github/kosmx/bendylib/mixin/QuadMixin.java @@ -1,20 +1,21 @@ package io.github.kosmx.bendylib.mixin; import io.github.kosmx.bendylib.impl.accessors.DirectionMutator; -import net.minecraft.client.model.ModelPart; +import net.minecraft.client.model.geom.ModelPart; import org.joml.Vector3f; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mutable; import org.spongepowered.asm.mixin.Shadow; -@Mixin(ModelPart.Quad.class) +@Mixin(ModelPart.Polygon.class) public class QuadMixin implements DirectionMutator { @Mutable - @Shadow @Final public Vector3f direction; + @Shadow @Final public Vector3f normal; + @Override - public void setDirection(Vector3f vec3f) { - this.direction = vec3f; + public void bendy_lib$setDirection(Vector3f vec3f) { + this.normal = vec3f; } } diff --git a/common/src/main/resources/bendylib.accesswidener b/common/src/main/resources/bendylib.accesswidener index 0aa8cf0..6f9b3c0 100644 --- a/common/src/main/resources/bendylib.accesswidener +++ b/common/src/main/resources/bendylib.accesswidener @@ -1,6 +1,6 @@ accessWidener v1 named # -extendable class net/minecraft/client/model/ModelPart -accessible class net/minecraft/client/model/ModelPart$Quad -accessible class net/minecraft/client/model/ModelPart$Vertex +extendable class net/minecraft/client/model/geom/ModelPart +accessible class net/minecraft/client/model/geom/ModelPart$Polygon +accessible class net/minecraft/client/model/geom/ModelPart$Vertex diff --git a/gradle.properties b/gradle.properties index 3c70c65..4a00a6f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,15 +1,14 @@ org.gradle.jvmargs=-Xmx4G -mod_version=5.0-rc1 +mod_version=5.0-rc2 maven_group=io.github.kosmx.bendy-lib archives_base_name=bendy-lib minecraft_version=1.21 -yarn_mappings=1.21+build.1 loader_version=0.15.11 #Fabric api -fabric_version=0.100.1+1.21 +fabric_version=0.100.3+1.21 #Forge thingy -forge_version=21.0.2-beta +forge_version=21.0.21-beta