Skip to content

Commit

Permalink
Update to 1.21.2/3
Browse files Browse the repository at this point in the history
  • Loading branch information
Sollace committed Oct 23, 2024
1 parent 4dc152f commit c88266d
Show file tree
Hide file tree
Showing 27 changed files with 358 additions and 175 deletions.
13 changes: 8 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
buildscript {
dependencies {
classpath 'com.github.dexman545:Outlet:1.3.10'
classpath 'com.github.dexman545:Outlet:1.6.1'
}
}
plugins {
id 'fabric-loom' version '1.6-SNAPSHOT'
id 'fabric-loom' version '1.7-SNAPSHOT'
id 'maven-publish'
id 'com.modrinth.minotaur' version '2.+'
id 'org.ajoberstar.reckon' version '0.13.0'
id 'org.ajoberstar.reckon' version '0.13.1'
}
apply plugin: 'dex.plugins.outlet'
apply plugin: 'io.github.dexman545.outlet'

java {
toolchain {
Expand Down Expand Up @@ -70,7 +70,10 @@ processResources {
expand "version": project.version.toString(),
"minecraftVersion": project.minecraft_version_range,
"loaderVersion": ">=${project.loader_version}",
"fabricVersion": ">=${project.fabric_version}"
"fabricVersion": ">=${project.fabric_version}",
// Workaround for groovy jank
"class_618": '$class_618',
"class_593": '$class_593'
}

from 'LICENSE'
Expand Down
12 changes: 6 additions & 6 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ org.gradle.daemon=false

# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=1.21-pre2
yarn_mappings=1.21-pre2+build.2
loader_version=0.15.11
fabric_version=0.99.4+1.21
minecraft_version=1.21.3
yarn_mappings=1.21.3+build.2
loader_version=0.16.7
fabric_version=0.106.1+1.21.3

# Mod Properties
group=com.minelittlepony
Expand All @@ -15,9 +15,9 @@ org.gradle.daemon=false
description=Json-based entity models. Mson.

# Publishing
minecraft_version_range=>=1.21-pre2
minecraft_version_range=>=1.21.2
modrinth_loader_type=fabric
modrinth_project_id=POWgsZW2

# Dependencies
modmenu_version=11.0.0-beta.1
modmenu_version=12.0.0-beta.1
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public interface EntityRendererRegistry {
/**
* Adds a custom entity renderer.
*/
<T extends Entity, R extends EntityRenderer<?>> void registerEntityRenderer(EntityType<T> type, Function<EntityRendererFactory.Context, R> constructor);
<T extends Entity, R extends EntityRenderer<?, ?>> void registerEntityRenderer(EntityType<T> type, Function<EntityRendererFactory.Context, R> constructor);

/**
* Adds a custom block entity renderer.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ public VanillaModelSerializer() {
public void exportAll(Path root) {
((ModelList)MinecraftClient.getInstance().getEntityModelLoader()).getModelParts().forEach((id, model) -> {
try {
Path path = root.resolve(id.getId().getNamespace()).resolve(id.getId().getPath() + ".json");
Path path = root.resolve(id.id().getNamespace()).resolve(id.id().getPath() + ".json");
writeToFile(path, model);

if (modelLoader != null) {
((MsonModelFormat)MsonModelFormat.INSTANCE).loadModel(id.getId(), path, modelLoader).ifPresent(content -> {
((MsonModelFormat)MsonModelFormat.INSTANCE).loadModel(id.id(), path, modelLoader).ifPresent(content -> {
BBModelFormat.INSTANCE.createSerializer().ifPresent(serializer -> {
try (serializer) {
serializer.writeToFile(
root.resolve(id.getId().getNamespace()).resolve(id.getId().getPath() + ".bbmodel").normalize(),
root.resolve(id.id().getNamespace()).resolve(id.id().getPath() + ".bbmodel").normalize(),
content
);
} catch (Exception ex) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,11 @@ public BoxBuilder mirror(Axis axis, Optional<Boolean> mirror) {
}

public Vert vert(float x, float y, float z, int u, int v) {
return (Vert)new ModelPart.Vertex(x, y, z, u, v);
return (Vert)(Object)new ModelPart.Vertex(x, y, z, u, v);
}

public Vert vert(int[] parameters, float[][] positionMatrix) {
return (Vert)new ModelPart.Vertex(
return (Vert)(Object)new ModelPart.Vertex(
positionMatrix[parameters[0]][0], positionMatrix[parameters[1]][1], positionMatrix[parameters[2]][2],
parameters[3], parameters[4]
);
Expand Down Expand Up @@ -142,7 +142,7 @@ public void quad(float u, float v, float w, float h, Direction direction, boolea
ModelPart.Vertex[] verts = new ModelPart.Vertex[vertices.length];
System.arraycopy(vertices, 0, verts, 0, vertices.length);

Rect rect = (Rect)new ModelPart.Quad(
Rect rect = (Rect)(Object)new ModelPart.Quad(
remap ? verts : defaultVertices,
u, v,
u + w, v + h,
Expand Down
14 changes: 11 additions & 3 deletions src/main/java/com/minelittlepony/mson/api/model/Vert.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
package com.minelittlepony.mson.api.model;

import net.minecraft.client.model.ModelPart;

import org.joml.Quaternionf;
import org.joml.Vector3f;

public interface Vert {
Vector3f getPos();
default Vector3f getPos() {
return ((ModelPart.Vertex)this).pos();
}

float getU();
default float getU() {
return ((ModelPart.Vertex)this).u();
}

float getV();
default float getV() {
return ((ModelPart.Vertex)this).v();
}

default Vert rotate(float x, float y, float z) {
return rotate(new Quaternionf().rotateXYZ(x, y, z));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,13 @@
import com.minelittlepony.mson.util.PartUtil;

public class MsonPlayer<T extends LivingEntity>
extends PlayerEntityModel<T>
extends PlayerEntityModel
implements MsonModel {

protected ModelPart cape;
protected ModelPart deadmsEars;

private boolean empty;

public MsonPlayer(ModelPart tree) {
super(tree, false);
cape = tree.getChild("cloak");
deadmsEars = tree.getChild("ear");
empty = tree.traverse().noneMatch(p -> !p.isEmpty());
}

Expand Down
4 changes: 3 additions & 1 deletion src/main/java/com/minelittlepony/mson/impl/LoadWorker.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.minelittlepony.mson.impl;

import net.minecraft.util.profiler.Profiler;
import net.minecraft.util.profiler.Profilers;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executor;
Expand All @@ -11,9 +12,10 @@ public interface LoadWorker<T> {

CompletableFuture<T> load(Supplier<T> loadFunc, String loadMessage);

public static <T> LoadWorker<T> async(Executor executor, Profiler profiler) {
public static <T> LoadWorker<T> async(Executor executor) {
return (loadFunc, loadMessage) -> {
return CompletableFuture.supplyAsync(() -> {
Profiler profiler = Profilers.get();
profiler.startTick();
profiler.push(loadMessage);
try {
Expand Down
18 changes: 6 additions & 12 deletions src/main/java/com/minelittlepony/mson/impl/MsonImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import net.minecraft.client.render.entity.model.EntityModelLayer;
import net.minecraft.resource.ResourceManager;
import net.minecraft.util.Identifier;
import net.minecraft.util.profiler.Profiler;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
Expand Down Expand Up @@ -75,7 +74,7 @@ public void registerVanillaModels(Map<EntityModelLayer, TexturedModelData> model
synchronized (vanillaModels) {
vanillaModels.clear();
modelParts.forEach((layer, vanilla) -> {
Identifier id = Identifier.of(layer.getId().getNamespace(), String.format("mson/%s", layer.getId().getPath()));
Identifier id = layer.id().withPath(p -> String.format("mson/%s", p));
((MsonImpl.KeyHolder)vanilla).setKey(registeredModels.computeIfAbsent(id, VanillaKey::new));
vanillaModels.add(id);
});
Expand All @@ -86,27 +85,22 @@ public void registerVanillaModels(Map<EntityModelLayer, TexturedModelData> model
}
}

private CompletableFuture<Void> requireVanillaModels(Synchronizer sync, ResourceManager sender,
Profiler prepareProfiler, Profiler applyProfiler,
Executor prepareExecutor, Executor applyExecutor) {
private CompletableFuture<Void> requireVanillaModels(ResourceManager sender, Executor prepareExecutor) {
boolean hasVanillaModels;
synchronized (vanillaModels) {
hasVanillaModels = !vanillaModels.isEmpty();
}
if (!hasVanillaModels) {
return MinecraftClient.getInstance().getEntityModelLoader()
.reload(sync, sender, prepareProfiler, applyProfiler, prepareExecutor, applyExecutor);
return CompletableFuture.runAsync(() -> MinecraftClient.getInstance().getEntityModelLoader().reload(sender), prepareExecutor);
}
return CompletableFuture.completedFuture(null);
}

@Override
public CompletableFuture<Void> reload(Synchronizer sync, ResourceManager sender,
Profiler prepareProfiler, Profiler applyProfiler,
Executor prepareExecutor, Executor applyExecutor) {
ModelFoundry loadingFoundry = new ModelFoundry(this).setWorker(LoadWorker.async(prepareExecutor, prepareProfiler));
public CompletableFuture<Void> reload(Synchronizer sync, ResourceManager sender, Executor prepareExecutor, Executor applyExecutor) {
ModelFoundry loadingFoundry = new ModelFoundry(this).setWorker(LoadWorker.async(prepareExecutor));

return requireVanillaModels(sync, sender, prepareProfiler, applyProfiler, prepareExecutor, applyExecutor)
return requireVanillaModels(sender, prepareExecutor)
.thenComposeAsync(v -> loadingFoundry.load(), prepareExecutor)
.thenCompose(sync::whenPrepared)
.thenRunAsync(() -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public final class PendingEntityRendererRegistry implements EntityRendererRegist
});
public final PendingRegistrations<
EntityType<?>,
Function<EntityRendererFactory.Context, ? extends EntityRenderer<?>>
Function<EntityRendererFactory.Context, ? extends EntityRenderer<?, ?>>
> entity = new PendingRegistrations<>(MsonImpl.id("renderers/entity"), EntityRendererRegistry::registerEntityRenderer);
public final PendingRegistrations<
BlockEntityType<?>,
Expand All @@ -45,7 +45,7 @@ public <T extends PlayerEntityRenderer> void registerPlayerRenderer(Identifier s
}

@Override
public <T extends Entity, R extends EntityRenderer<?>> void registerEntityRenderer(EntityType<T> type, Function<EntityRendererFactory.Context, R> constructor) {
public <T extends Entity, R extends EntityRenderer<?, ?>> void registerEntityRenderer(EntityType<T> type, Function<EntityRendererFactory.Context, R> constructor) {
entity.register(type, constructor);
}

Expand Down
3 changes: 1 addition & 2 deletions src/main/java/com/minelittlepony/mson/impl/Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.client.model.ModelPart;
import net.minecraft.client.network.AbstractClientPlayerEntity;
import net.minecraft.client.render.entity.EntityRendererFactory;
import net.minecraft.client.render.entity.PlayerEntityRenderer;
import net.minecraft.client.render.entity.model.PlayerEntityModel;
Expand Down Expand Up @@ -72,7 +71,7 @@ static void exportBbModels(Iterable<? extends AbstractModelKeyImpl<?>> keys) {
});
}

static Function<EntityRendererFactory.Context, PlayerEntityRenderer> playerRendererFactor(ModelKey<? extends PlayerEntityModel<AbstractClientPlayerEntity>> key) {
static Function<EntityRendererFactory.Context, PlayerEntityRenderer> playerRendererFactor(ModelKey<? extends PlayerEntityModel> key) {
return r -> new PlayerEntityRenderer(r, false) {{
this.model = key.createModel();
}};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,12 @@ private void computeContents() {
for (Cuboid cube : accessor.getCuboids()) {
Cube cu = ((Cube)cube);
for (int i = 0; i < cu.sideCount(); i++) {
Quad quad = (Quad)cu.getSide(i);
for (Vertex vert : quad.vertices) {
Quad quad = (Quad)(Object)cu.getSide(i);
for (Vertex vert : quad.vertices()) {
fragments.add(new Fragment(
vert.u, vert.v,
vertices.computeIfAbsent(vert.pos, Function.identity()),
normals.computeIfAbsent(quad.direction, Function.identity())
vert.u(), vert.v(),
vertices.computeIfAbsent(vert.pos(), Function.identity()),
normals.computeIfAbsent(quad.direction(), Function.identity())
));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
@Mixin(EntityRenderDispatcher.class)
abstract class MixinEntityRenderDispatcher implements EntityRendererRegistry {
@Shadow
private Map<EntityType<?>, EntityRenderer<? extends Entity>> renderers;
private Map<EntityType<?>, EntityRenderer<? extends Entity, ?>> renderers;
private Map<Identifier, Map.Entry<Predicate<AbstractClientPlayerEntity>, PlayerEntityRenderer>> customModelRenderers;
@Shadow
private @Final EntityModelLoader modelLoader;
Expand All @@ -48,9 +48,11 @@ private EntityRendererFactory.Context createContext() {
EntityRenderDispatcher self = (EntityRenderDispatcher)(Object)this;
return new EntityRendererFactory.Context(self,
mc.getItemRenderer(),
mc.getMapRenderer(),
mc.getBlockRenderManager(),
mc.getEntityRenderDispatcher().getHeldItemRenderer(), mc.getResourceManager(),
mc.getResourceManager(),
modelLoader,
mc.getEquipmentModelLoader(),
mc.textRenderer
);
}
Expand All @@ -68,7 +70,7 @@ public <R extends PlayerEntityRenderer> void registerPlayerRenderer(Identifier i
}

@Override
public <T extends Entity, R extends EntityRenderer<?>> void registerEntityRenderer(EntityType<T> type, Function<EntityRendererFactory.Context, R> constructor) {
public <T extends Entity, R extends EntityRenderer<?, ?>> void registerEntityRenderer(EntityType<T> type, Function<EntityRendererFactory.Context, R> constructor) {
try {
if (renderers instanceof ImmutableMap) {
renderers = new HashMap<>(renderers);
Expand All @@ -84,7 +86,7 @@ public <T extends Entity, R extends EntityRenderer<?>> void registerEntityRender
at = @At("HEAD"),
cancellable = true
)
private void onGetRenderer(Entity entity, CallbackInfoReturnable<EntityRenderer<?>> info) {
private void onGetRenderer(Entity entity, CallbackInfoReturnable<EntityRenderer<?, ?>> info) {
if (entity instanceof AbstractClientPlayerEntity player) {
customModelRenderers.values().stream()
.filter(entry -> entry.getKey().test(player))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ public void setSides(Rect[] sides) {
}
@Override
public Rect getSide(int index) {
return (Rect)sides[index];
return (Rect)(Object)sides[index];
}
@Override
public void setSide(int index, Rect value) {
sides[index] = (ModelPart.Quad)value;
sides[index] = (ModelPart.Quad)(Object)value;
}
@Override
public int sideCount() {
Expand All @@ -74,11 +74,11 @@ abstract class MixinQuad implements Rect {

@Override
public Vert getVertex(int index) {
return (Vert)vertices[index];
return (Vert)(Object)vertices[index];
}
@Override
public void setVertex(int index, Vert value) {
vertices[index] = (ModelPart.Vertex)value;
vertices[index] = (ModelPart.Vertex)(Object)value;
}

@Override
Expand Down Expand Up @@ -112,10 +112,4 @@ public Rect setVertices(boolean reflect, Vert...vertices) {

@Mixin(ModelPart.Vertex.class)
abstract class MixinVertex implements Vert {
@Accessor("pos") @Override
public abstract Vector3f getPos();
@Accessor("u") @Override
public abstract float getU();
@Accessor("v") @Override
public abstract float getV();
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ public JsonObject toJson(JsonBuffer exporter) {
children.forEach((key, value) -> js.add(key, exporter.write(value)));
}));
if (rotationData != ModelTransform.NONE) {
exporter.array(json, "pivot", rotationData.pivotX, rotationData.pivotY, rotationData.pivotZ);
exporter.array(json, "rotate", rotationData.pitch, rotationData.yaw, rotationData.roll);
exporter.array(json, "pivot", rotationData.pivotX(), rotationData.pivotY(), rotationData.pivotZ());
exporter.array(json, "rotate", rotationData.pitch(), rotationData.yaw(), rotationData.roll());
}
});
}
Expand Down
Loading

0 comments on commit c88266d

Please sign in to comment.