Skip to content

Commit

Permalink
Backport to 1.21.3 for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
Aeltumn committed Nov 26, 2024
1 parent 7c0a707 commit 8f1b81e
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 65 deletions.
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ allprojects {
maven("https://maven.enginehub.org/repo/")
maven("https://maven.fabricmc.net/")
maven("https://maven.neoforged.net/releases/")
maven("https://maven.terraformersmc.com/")
mavenCentral()
maven {
setUrl("https://api.modrinth.com/maven")
Expand Down
1 change: 1 addition & 0 deletions common/src/main/resources/noxesium.accesswidener
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ accessWidener v1 named

accessible class com/mojang/blaze3d/platform/GlStateManager$BlendState
accessible class net/minecraft/client/resources/SkinManager$TextureCache
accessible class net/minecraft/client/renderer/texture/SimpleTexture$TextureImage

accessible field com/mojang/blaze3d/platform/GlStateManager BLEND Lcom/mojang/blaze3d/platform/GlStateManager$BlendState;
accessible field com/mojang/blaze3d/platform/GlStateManager$BooleanState enabled Z
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import net.minecraft.client.gui.font.FontSet;
import net.minecraft.client.gui.font.glyphs.BakedGlyph;
import net.minecraft.client.gui.font.glyphs.SpecialGlyphs;
import net.minecraft.client.renderer.texture.SimpleTexture;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.client.resources.DefaultPlayerSkin;
import net.minecraft.resources.ResourceLocation;
Expand Down Expand Up @@ -40,11 +41,8 @@ public CustomSkullFont(SkullFontModule module, TextureManager textureManager, Re

try {
ResourceLocation location = DefaultPlayerSkin.getDefaultTexture();
Resource resource = Minecraft.getInstance().getResourceManager().getResourceOrThrow(location);
NativeImage image;
try (InputStream inputstream = resource.open()) {
image = NativeImage.read(inputstream);
}
var simpleTexture = SimpleTexture.TextureImage.load(Minecraft.getInstance().getResourceManager(), location);
var image = simpleTexture.getImage();
fallbackGlyph = module.processImage(image, false);
grayscaleFallbackGlyph = module.processImage(image, true);
} catch (Exception x) {
Expand Down Expand Up @@ -173,7 +171,7 @@ public float getBearingTop() {

@Override
public void upload(int i, int j) {
image.upload(0, i, j, 0, 0, 8, 8, false);
image.upload(0, i, j, 0, 0, 8, 8, false, false);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@
import com.noxcrew.noxesium.mixin.feature.component.ext.FontManagerExt;
import com.noxcrew.noxesium.mixin.feature.component.ext.MinecraftExt;
import com.noxcrew.noxesium.mixin.feature.component.ext.SkinManagerExt;
import com.noxcrew.noxesium.mixin.feature.component.ext.SkinTextureDownloaderExt;
import com.noxcrew.noxesium.mixin.feature.component.ext.TextureCacheExt;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.minecraft.Util;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.texture.HttpTexture;
import net.minecraft.client.resources.DefaultPlayerSkin;
import net.minecraft.client.resources.SkinManager;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.ARGB;
Expand All @@ -27,7 +28,6 @@
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.UncheckedIOException;
import java.nio.file.Path;
import java.util.HashMap;
import java.util.Map;
Expand Down Expand Up @@ -167,19 +167,21 @@ public void loadGlyph(int next, SkullConfig config) {
} else {
// If this skin isn't known we download it first
var resourceLocation = ResourceLocation.withDefaultNamespace("skins/" + string);
CompletableFuture.supplyAsync(() -> {
// At this point the texture has been saved to the file, so we can read out the native image
var httpTexture = new HttpTexture(file2, information.getUrl(), DefaultPlayerSkin.getDefaultTexture(), true, () -> {
// At this point the texture has been saved to the file, so we can read out the native image
try {
NativeImage nativeImage;
try {
nativeImage = SkinTextureDownloaderExt.invokeProcessLegacySkin(SkinTextureDownloaderExt.invokeDownloadSkin(file2.toPath(), information.getUrl()), information.getUrl());
imageFuture.complete(processImage(nativeImage, properties.grayscale()));
} catch (IOException x) {
throw new UncheckedIOException(x);
try (InputStream inputStream = new FileInputStream(file2)) {
nativeImage = NativeImage.read(inputStream);
}
return nativeImage;
}, Util.nonCriticalIoPool().forName("downloadTexture"))
// Let the texture manager register the skin and do the downloading for us
.thenCompose((nativeImage) -> SkinTextureDownloaderExt.invokeRegisterTextureInManager(resourceLocation, nativeImage));
imageFuture.complete(processImage(nativeImage, properties.grayscale()));
} catch (IOException x) {
x.printStackTrace();
}
});

// Let the texture manager register the skin and do the downloading for us
Minecraft.getInstance().getTextureManager().register(resourceLocation, httpTexture);
}
}
} catch (Exception x) {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import com.noxcrew.noxesium.feature.rule.InventoryHelper;
import net.minecraft.client.renderer.entity.LivingEntityRenderer;
import net.minecraft.client.renderer.entity.state.ArmedEntityRenderState;
import net.minecraft.world.entity.HumanoidArm;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
Expand All @@ -14,11 +13,11 @@
/**
* Overrides the item shown as being held in the main hand on the 3d player model.
*/
@Mixin(ArmedEntityRenderState.class)
@Mixin(LivingEntityRenderer.class)
public abstract class HandItemOverrideRenderMixin {

@Redirect(method = "extractArmedEntityRenderState", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/LivingEntity;getItemHeldByArm(Lnet/minecraft/world/entity/HumanoidArm;)Lnet/minecraft/world/item/ItemStack;"))
private static ItemStack getItemByArm(LivingEntity instance, HumanoidArm humanoidArm) {
@Redirect(method = "extractRenderState(Lnet/minecraft/world/entity/LivingEntity;Lnet/minecraft/client/renderer/entity/state/LivingEntityRenderState;F)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/LivingEntity;getItemHeldByArm(Lnet/minecraft/world/entity/HumanoidArm;)Lnet/minecraft/world/item/ItemStack;"))
public ItemStack getItemByArm(LivingEntity instance, HumanoidArm humanoidArm) {
if (instance instanceof Player player && humanoidArm == player.getMainArm()) {
return InventoryHelper.getRealSelected(player.getInventory());
} else {
Expand Down
8 changes: 4 additions & 4 deletions fabric/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@
],
"depends": {
"fabric": "*",
"fabricloader": ">=0.16.9",
"fabric-api": ">=0.109.1",
"minecraft": ">=1.21.4-beta.1"
"fabricloader": ">=0.16.7",
"fabric-api": ">=0.106.1",
"minecraft": ">=1.21.2"
},
"suggests": {
"sodium": ">=0.6.0-beta.3"
"sodium": ">=0.6.0"
},
"breaks": {
"optifabric": "*"
Expand Down
1 change: 0 additions & 1 deletion fabric/src/main/resources/noxesium-fabric.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
"feature.component.ext.FontSetExt",
"feature.component.ext.MinecraftExt",
"feature.component.ext.SkinManagerExt",
"feature.component.ext.SkinTextureDownloaderExt",
"feature.component.ext.TextureCacheExt",
"rules.BoatCollisionMixin",
"rules.CustomCreativeReloadMixin",
Expand Down
14 changes: 7 additions & 7 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ org.gradle.parallel=true

# Fabric Properties
# check these on https://modmuss50.me/fabric.html
minecraft_version=1.21.4-pre1
yarn_mappings=1.21.4-pre1+build.4
loader_version=0.16.9
minecraft_version=1.21.2
yarn_mappings=1.21.2+build.1
loader_version=0.16.7

# Fabric API
fabric_version=0.109.1+1.21.4
fabric_version=0.106.1+1.21.2

## This is the version of minecraft that the 'common' project uses, you can find a list of all versions here
## https://projects.neoforged.net/neoforged/neoform
Expand All @@ -20,9 +20,9 @@ forge_version=21.3.40-beta
mod_version=2.5.0-SNAPSHOT

# Mod dependencies
sodium = mc1.21.3-0.6.0-beta.5-fabric
sodium = mc1.21.3-0.6.0-fabric
modmenu = 12.0.0-beta.1

# Enabled mods
enableSodium = false
enableModMenu = false
enableSodium = true
enableModMenu = true

0 comments on commit 8f1b81e

Please sign in to comment.