aboutsummaryrefslogtreecommitdiff
path: root/defaults
diff options
context:
space:
mode:
authorSHsuperCM <shsupercm@gmail.com>2022-10-27 15:45:43 +0300
committerSHsuperCM <shsupercm@gmail.com>2022-10-27 17:20:37 +0300
commita75d755df8e0c551cd40701017018719667ff6eb (patch)
treecf15d133065ffa864bbe56f1780b0dc9cf40a9f4 /defaults
parent237adf03cc55b4120330e2fbc4bc4178c0361f2d (diff)
downloadCITResewn-a75d755df8e0c551cd40701017018719667ff6eb.tar.gz
CITResewn-a75d755df8e0c551cd40701017018719667ff6eb.tar.bz2
CITResewn-a75d755df8e0c551cd40701017018719667ff6eb.zip
22w43a Bandage
Diffstat (limited to 'defaults')
-rw-r--r--defaults/src/main/java/shcm/shsupercm/fabric/citresewn/defaults/cit/types/TypeEnchantment.java11
-rw-r--r--defaults/src/main/java/shcm/shsupercm/fabric/citresewn/defaults/mixin/common/ModelLoaderMixin.java14
-rw-r--r--defaults/src/main/java/shcm/shsupercm/fabric/citresewn/defaults/mixin/common/ResourceFinderMixin.java (renamed from defaults/src/main/java/shcm/shsupercm/fabric/citresewn/defaults/mixin/common/SpriteAtlasTextureMixin.java)16
-rw-r--r--defaults/src/main/java/shcm/shsupercm/fabric/citresewn/defaults/mixin/types/item/ModelLoaderMixin.java23
4 files changed, 29 insertions, 35 deletions
diff --git a/defaults/src/main/java/shcm/shsupercm/fabric/citresewn/defaults/cit/types/TypeEnchantment.java b/defaults/src/main/java/shcm/shsupercm/fabric/citresewn/defaults/cit/types/TypeEnchantment.java
index 1d20201..692d55b 100644
--- a/defaults/src/main/java/shcm/shsupercm/fabric/citresewn/defaults/cit/types/TypeEnchantment.java
+++ b/defaults/src/main/java/shcm/shsupercm/fabric/citresewn/defaults/cit/types/TypeEnchantment.java
@@ -7,8 +7,7 @@ import net.minecraft.client.render.*;
import net.minecraft.resource.ResourceManager;
import net.minecraft.util.Identifier;
import net.minecraft.util.Util;
-import net.minecraft.util.math.Matrix4f;
-import net.minecraft.util.math.Vec3f;
+import org.joml.Matrix4f;
import org.lwjgl.opengl.GL11;
import shcm.shsupercm.fabric.citresewn.api.CITGlobalProperties;
import shcm.shsupercm.fabric.citresewn.api.CITTypeContainer;
@@ -311,10 +310,10 @@ public class TypeEnchantment extends CITType {
float l = Util.getMeasuringTimeMs() * CITResewnDefaultsConfig.INSTANCE.type_enchantment_scroll_multiplier * speed;
float x = (l % 110000f) / 110000f;
float y = (l % 30000f) / 30000f;
- Matrix4f matrix4f = Matrix4f.translate(-x, y, 0.0f);
- matrix4f.multiply(Vec3f.POSITIVE_Z.getDegreesQuaternion(rotation));
- matrix4f.multiply(Matrix4f.scale(scale, scale, scale));
- setTextureMatrix(matrix4f);
+ setTextureMatrix(new Matrix4f()
+ .translation(-x, y, 0.0f)
+ .rotateZ(rotation)
+ .scale(scale));
setShaderColor(r, g, b, a * methodIntensity.intensity);
}
diff --git a/defaults/src/main/java/shcm/shsupercm/fabric/citresewn/defaults/mixin/common/ModelLoaderMixin.java b/defaults/src/main/java/shcm/shsupercm/fabric/citresewn/defaults/mixin/common/ModelLoaderMixin.java
index a1e8e54..a652bd9 100644
--- a/defaults/src/main/java/shcm/shsupercm/fabric/citresewn/defaults/mixin/common/ModelLoaderMixin.java
+++ b/defaults/src/main/java/shcm/shsupercm/fabric/citresewn/defaults/mixin/common/ModelLoaderMixin.java
@@ -1,16 +1,14 @@
package shcm.shsupercm.fabric.citresewn.defaults.mixin.common;
import com.mojang.datafixers.util.Either;
+import net.minecraft.client.MinecraftClient;
import net.minecraft.client.render.model.ModelLoader;
import net.minecraft.client.render.model.json.JsonUnbakedModel;
import net.minecraft.client.render.model.json.ModelOverride;
import net.minecraft.client.util.SpriteIdentifier;
-import net.minecraft.resource.ResourceManager;
import net.minecraft.util.Identifier;
import org.apache.commons.io.IOUtils;
-import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
-import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@@ -28,12 +26,10 @@ import java.util.stream.Collectors;
*/
@Mixin(ModelLoader.class)
public class ModelLoaderMixin {
- @Shadow @Final private ResourceManager resourceManager;
-
@Inject(method = "loadModelFromJson", cancellable = true, at = @At("HEAD"))
public void citresewn$forceLiteralResewnModelIdentifier(Identifier id, CallbackInfoReturnable<JsonUnbakedModel> cir) {
if (id instanceof ResewnItemModelIdentifier) {
- try (InputStream is = resourceManager.getResource(id).orElseThrow().getInputStream()) {
+ try (InputStream is = MinecraftClient.getInstance().getResourceManager().getResource(id).orElseThrow().getInputStream()) {
JsonUnbakedModel json = JsonUnbakedModel.deserialize(IOUtils.toString(is, StandardCharsets.UTF_8));
json.id = id.toString();
json.id = json.id.substring(0, json.id.length() - 5);
@@ -44,7 +40,7 @@ public class ModelLoaderMixin {
String originalPath = left.get().getTextureId().getPath();
String[] split = originalPath.split("/");
if (originalPath.startsWith("./") || (split.length > 2 && split[1].equals("cit"))) {
- Identifier resolvedIdentifier = CITType.resolveAsset(id, originalPath, "textures", ".png", resourceManager);
+ Identifier resolvedIdentifier = CITType.resolveAsset(id, originalPath, "textures", ".png", MinecraftClient.getInstance().getResourceManager());
if (resolvedIdentifier != null)
return Either.left(new SpriteIdentifier(left.get().getAtlasId(), resolvedIdentifier));
}
@@ -56,7 +52,7 @@ public class ModelLoaderMixin {
if (parentId != null) {
String[] parentIdPathSplit = parentId.getPath().split("/");
if (parentId.getPath().startsWith("./") || (parentIdPathSplit.length > 2 && parentIdPathSplit[1].equals("cit"))) {
- parentId = CITType.resolveAsset(id, parentId.getPath(), "models", ".json", resourceManager);
+ parentId = CITType.resolveAsset(id, parentId.getPath(), "models", ".json", MinecraftClient.getInstance().getResourceManager());
if (parentId != null)
((JsonUnbakedModelAccessor) json).setParentId(new ResewnItemModelIdentifier(parentId));
}
@@ -65,7 +61,7 @@ public class ModelLoaderMixin {
json.getOverrides().replaceAll(override -> {
String[] modelIdPathSplit = override.getModelId().getPath().split("/");
if (override.getModelId().getPath().startsWith("./") || (modelIdPathSplit.length > 2 && modelIdPathSplit[1].equals("cit"))) {
- Identifier resolvedOverridePath = CITType.resolveAsset(id, override.getModelId().getPath(), "models", ".json", resourceManager);
+ Identifier resolvedOverridePath = CITType.resolveAsset(id, override.getModelId().getPath(), "models", ".json", MinecraftClient.getInstance().getResourceManager());
if (resolvedOverridePath != null)
return new ModelOverride(new ResewnItemModelIdentifier(resolvedOverridePath), override.streamConditions().collect(Collectors.toList()));
}
diff --git a/defaults/src/main/java/shcm/shsupercm/fabric/citresewn/defaults/mixin/common/SpriteAtlasTextureMixin.java b/defaults/src/main/java/shcm/shsupercm/fabric/citresewn/defaults/mixin/common/ResourceFinderMixin.java
index 0e05a42..7893760 100644
--- a/defaults/src/main/java/shcm/shsupercm/fabric/citresewn/defaults/mixin/common/SpriteAtlasTextureMixin.java
+++ b/defaults/src/main/java/shcm/shsupercm/fabric/citresewn/defaults/mixin/common/ResourceFinderMixin.java
@@ -1,6 +1,6 @@
package shcm.shsupercm.fabric.citresewn.defaults.mixin.common;
-import net.minecraft.client.texture.SpriteAtlasTexture;
+import net.minecraft.resource.ResourceFinder;
import net.minecraft.util.Identifier;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
@@ -9,13 +9,15 @@ import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
-@Mixin(SpriteAtlasTexture.class)
-public class SpriteAtlasTextureMixin {
- @Shadow @Final private static String PNG_EXTENSION;
+@Mixin(ResourceFinder.class)
+public class ResourceFinderMixin {
- @Inject(method = "getTexturePath", cancellable = true, at = @At("HEAD"))
- public void citresewn$forceAbsoluteTextureIdentifier(Identifier id, CallbackInfoReturnable<Identifier> cir) {
- if (id.getPath().endsWith(PNG_EXTENSION))
+ @Shadow @Final private String fileExtension;
+
+ @Inject(method = "toResourcePath", cancellable = true, at =
+ @At("HEAD"))
+ private void citresewn$forceAbsoluteTextureIdentifier(Identifier id, CallbackInfoReturnable<Identifier> cir) {
+ if (id.getPath().endsWith(".png") && this.fileExtension.equals(".png"))
cir.setReturnValue(id);
}
}
diff --git a/defaults/src/main/java/shcm/shsupercm/fabric/citresewn/defaults/mixin/types/item/ModelLoaderMixin.java b/defaults/src/main/java/shcm/shsupercm/fabric/citresewn/defaults/mixin/types/item/ModelLoaderMixin.java
index 68d6bfc..4385f96 100644
--- a/defaults/src/main/java/shcm/shsupercm/fabric/citresewn/defaults/mixin/types/item/ModelLoaderMixin.java
+++ b/defaults/src/main/java/shcm/shsupercm/fabric/citresewn/defaults/mixin/types/item/ModelLoaderMixin.java
@@ -3,12 +3,11 @@ package shcm.shsupercm.fabric.citresewn.defaults.mixin.types.item;
import net.minecraft.client.color.block.BlockColors;
import net.minecraft.client.render.model.BakedModel;
import net.minecraft.client.render.model.ModelLoader;
-import net.minecraft.client.render.model.SpriteAtlasManager;
import net.minecraft.client.render.model.UnbakedModel;
import net.minecraft.client.render.model.json.JsonUnbakedModel;
import net.minecraft.client.render.model.json.ModelOverride;
-import net.minecraft.client.texture.TextureManager;
-import net.minecraft.resource.ResourceManager;
+import net.minecraft.client.texture.Sprite;
+import net.minecraft.client.util.SpriteIdentifier;
import net.minecraft.util.Identifier;
import net.minecraft.util.profiler.Profiler;
import org.spongepowered.asm.mixin.Final;
@@ -18,13 +17,13 @@ import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.ModifyArg;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
-import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import shcm.shsupercm.fabric.citresewn.CITResewn;
import shcm.shsupercm.fabric.citresewn.cit.CIT;
import shcm.shsupercm.fabric.citresewn.defaults.cit.types.TypeItem;
import shcm.shsupercm.fabric.citresewn.defaults.common.ResewnItemModelIdentifier;
import java.util.*;
+import java.util.function.BiFunction;
import static shcm.shsupercm.fabric.citresewn.CITResewn.info;
import static shcm.shsupercm.fabric.citresewn.defaults.cit.types.TypeItem.CONTAINER;
@@ -38,7 +37,7 @@ public class ModelLoaderMixin {
@Inject(method = "<init>", at =
@At(value = "INVOKE", ordinal = 0, target = "Lnet/minecraft/util/profiler/Profiler;swap(Ljava/lang/String;)V"))
- public void citresewn$addTypeItemModels(ResourceManager resourceManager, BlockColors blockColors, Profiler profiler, int i, CallbackInfo ci) {
+ public void citresewn$addTypeItemModels(BlockColors blockColors, Profiler profiler, Map map, Map map2, CallbackInfo ci) {
profiler.swap("citresewn:type_item_models");
if (!CONTAINER.active())
return;
@@ -46,7 +45,7 @@ public class ModelLoaderMixin {
info("Loading item CIT models...");
for (CIT<TypeItem> cit : CONTAINER.loaded)
try {
- cit.type.loadUnbakedAssets(resourceManager);
+ //cit.type.loadUnbakedAssets(resourceManager);
for (JsonUnbakedModel unbakedModel : cit.type.unbakedAssets.values()) {
ResewnItemModelIdentifier id = new ResewnItemModelIdentifier(unbakedModel.id);
@@ -61,12 +60,11 @@ public class ModelLoaderMixin {
TypeItem.GENERATED_SUB_CITS_SEEN.clear();
}
- @Inject(method = "upload", at = @At("RETURN"))
- public void citresewn$linkTypeItemModels(TextureManager textureManager, Profiler profiler, CallbackInfoReturnable<SpriteAtlasManager> cir) {
+ @Inject(method = "bake", at = @At("RETURN"))
+ public void citresewn$linkTypeItemModels(BiFunction<Identifier, SpriteIdentifier, Sprite> spriteLoader, CallbackInfo ci) {
if (!CONTAINER.active())
return;
- profiler.push("citresewn:type_item_linking");
info("Linking baked models to item CITs...");
for (CIT<TypeItem> cit : CONTAINER.loaded) {
@@ -83,13 +81,12 @@ public class ModelLoaderMixin {
}
cit.type.unbakedAssets = null;
}
-
- profiler.pop();
}
@ModifyArg(method = "loadModelFromJson", at =
- @At(value = "INVOKE", target = "Lnet/minecraft/resource/ResourceManager;openAsReader(Lnet/minecraft/util/Identifier;)Ljava/io/BufferedReader;"))
- public Identifier citresewn$fixDuplicatePrefixSuffix(Identifier original) {
+ @At(value = "INVOKE", ordinal = 1, target = "Ljava/util/Map;get(Ljava/lang/Object;)Ljava/lang/Object;"))
+ public Object citresewn$fixDuplicatePrefixSuffix(Object key) {
+ Identifier original = (Identifier) key;
if (CONTAINER.active() && original.getPath().startsWith("models/models/") && original.getPath().endsWith(".json.json") && original.getPath().contains("cit"))
return new Identifier(original.getNamespace(), original.getPath().substring(7, original.getPath().length() - 5));