From 6f9fd38cb06ea4c00977aba53900f1f12dfaec26 Mon Sep 17 00:00:00 2001 From: Sollace Date: Thu, 9 Jun 2022 21:35:51 +0200 Subject: [PATCH] 1.18.2 -> 1.19 --- build.gradle | 4 +- gradle.properties | 18 ++++----- .../pony/network/fabric/PonyDataCallback.java | 2 +- .../client/GuiPonySettings.java | 32 ++++++++-------- .../client/hdskins/PonyPreview.java | 5 +-- .../client/mixin/MixinClientPlayerEntity.java | 2 +- .../armour/DefaultArmourTextureResolver.java | 2 +- .../client/pony/BackgroundPonyList.java | 2 +- .../minelittlepony/client/pony/PonyData.java | 37 ++++++++----------- .../client/pony/PonyDataSerialiser.java | 5 ++- .../render/blockentity/skull/PonySkull.java | 4 +- .../render/entity/PonyStandRenderer.java | 6 +-- .../render/entity/feature/SkullFeature.java | 6 +-- .../render/entity/npc/PonyTextures.java | 2 +- 14 files changed, 61 insertions(+), 66 deletions(-) diff --git a/build.gradle b/build.gradle index 3e02f5b2..7d97459f 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ buildscript { } plugins { id 'java-library' - id 'fabric-loom' version '0.10-SNAPSHOT' + id 'fabric-loom' version '0.12-SNAPSHOT' id 'maven-publish' id 'com.modrinth.minotaur' version '1.1.0' id 'org.ajoberstar.reckon' version '0.13.0' @@ -59,7 +59,7 @@ dependencies { modApi fabricApi.module("fabric-api-base", project.fabric_version) modApi fabricApi.module("fabric-lifecycle-events-v1", project.fabric_version) modApi fabricApi.module("fabric-resource-loader-v0", project.fabric_version) - modApi fabricApi.module("fabric-networking-v0", project.fabric_version) + modApi fabricApi.module("fabric-networking-api-v1", project.fabric_version) modApi "com.minelittlepony:kirin:${project.kirin_version}" include "com.minelittlepony:kirin:${project.kirin_version}" diff --git a/gradle.properties b/gradle.properties index db90bde0..44f07f50 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,10 +3,10 @@ org.gradle.daemon=false # Fabric Properties # check these on https://fabricmc.net/develop - minecraft_version=1.18.2 - yarn_mappings=1.18.2+build.1 - loader_version=0.13.3 - fabric_version=0.47.8+1.18.2 + minecraft_version=1.19 + yarn_mappings=1.19+build.1 + loader_version=0.14.7 + fabric_version=0.55.3+1.19 # Mod Properties group=com.minelittlepony @@ -15,12 +15,12 @@ org.gradle.daemon=false description=Mine Little Pony turns players and mobs into ponies. Press F9 ingame to access settings. # Publishing - minecraft_version_range=>=1.18.1 + minecraft_version_range=>=1.19.0 modrinth_loader_type=fabric modrinth_project_id=JBjInUXM # Dependencies - modmenu_version=3.1.0 - kirin_version=1.10.0 - hd_skins_version=6.5.2 - mson_version=1.5.1 + modmenu_version=4.0.0 + kirin_version=1.11.0-beta.2 + hd_skins_version=6.6.0 + mson_version=1.6.0-beta.3 diff --git a/src/main/java/com/minelittlepony/api/pony/network/fabric/PonyDataCallback.java b/src/main/java/com/minelittlepony/api/pony/network/fabric/PonyDataCallback.java index d6a53403..72402f41 100644 --- a/src/main/java/com/minelittlepony/api/pony/network/fabric/PonyDataCallback.java +++ b/src/main/java/com/minelittlepony/api/pony/network/fabric/PonyDataCallback.java @@ -15,7 +15,7 @@ import com.minelittlepony.client.MineLittlePony; public interface PonyDataCallback { Event EVENT = EventFactory.createArrayBacked(PonyDataCallback.class, listeners -> (sender, data, noSkin, env) -> { - MineLittlePony.logger.info("Got pony data on the " + env + " from " + sender.getName().asString() + " with " + (noSkin ? "un" : "") + "set skin and he is a " + data.getRace() + "!"); + MineLittlePony.logger.info("Got pony data on the " + env + " from " + sender.getName().getString() + " with " + (noSkin ? "un" : "") + "set skin and he is a " + data.getRace() + "!"); for (PonyDataCallback event : listeners) { event.onPonyDataAvailable(sender, data, noSkin, env); } diff --git a/src/main/java/com/minelittlepony/client/GuiPonySettings.java b/src/main/java/com/minelittlepony/client/GuiPonySettings.java index 917f436b..fbd8af6e 100644 --- a/src/main/java/com/minelittlepony/client/GuiPonySettings.java +++ b/src/main/java/com/minelittlepony/client/GuiPonySettings.java @@ -2,8 +2,7 @@ package com.minelittlepony.client; import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.text.LiteralText; -import net.minecraft.text.TranslatableText; +import net.minecraft.text.*; import com.minelittlepony.client.render.MobRenderers; import com.minelittlepony.client.settings.ClientPonyConfig; @@ -25,13 +24,16 @@ import org.jetbrains.annotations.Nullable; * */ public class GuiPonySettings extends GameGui { - private static final String OPTIONS_PREFIX = "minelp.options."; - private static final String PONY_LEVEL = OPTIONS_PREFIX + "ponylevel"; - private static final String MOB_PREFIX = "minelp.mobs."; + public static final Text SCALE_MEGA = Text.translatable("minelp.debug.scale.meg"); + public static final Text SCALE_MAX = Text.translatable("minelp.debug.scale.max"); + public static final Text SCALE_MID = Text.translatable("minelp.debug.scale.mid"); + public static final Text SCALE_SHOW = Text.translatable("minelp.debug.scale.sa"); + public static final Text SCALE_MIN = Text.translatable("minelp.debug.scale.min"); + private ClientPonyConfig config; private final ScrollContainer content = new ScrollContainer(); @@ -39,7 +41,7 @@ public class GuiPonySettings extends GameGui { private final boolean hiddenOptions; public GuiPonySettings(@Nullable Screen parent) { - super(new LiteralText(OPTIONS_PREFIX + "title"), parent); + super(Text.literal(OPTIONS_PREFIX + "title"), parent); config = (ClientPonyConfig)MineLittlePony.getInstance().getConfig(); @@ -83,7 +85,7 @@ public class GuiPonySettings extends GameGui { content.addButton(new EnumSlider<>(LEFT, row += 20, config.ponyLevel.get()) .onChange(config.ponyLevel::set) - .setTextFormat(sender -> new TranslatableText(PONY_LEVEL + "." + sender.getValue().name().toLowerCase())) + .setTextFormat(sender -> Text.translatable(PONY_LEVEL + "." + sender.getValue().name().toLowerCase())) .setTooltipFormat(sender -> Tooltip.of(PONY_LEVEL + "." + sender.getValue().name().toLowerCase() + ".tooltip", 200))); boolean allowCameraChange = client.player == null || client.player.isCreative() || client.player.isSpectator() || client.isInSingleplayer(); @@ -110,7 +112,7 @@ public class GuiPonySettings extends GameGui { button.getStyle().setText(OPTIONS_PREFIX + i.name().toLowerCase()); if (!enabled) { button.getStyle() - .setTooltip(new TranslatableText(OPTIONS_PREFIX + "option.disabled")) + .setTooltip(Text.translatable(OPTIONS_PREFIX + "option.disabled")) .setTooltipOffset(0, 0); } } @@ -139,29 +141,29 @@ public class GuiPonySettings extends GameGui { SkinsProxy.instance.renderOption(this, parent, row, RIGHT, content); } - public TranslatableText describeCurrentScale(AbstractSlider sender) { + public Text describeCurrentScale(AbstractSlider sender) { float value = sender.getValue(); if (value >= 3) { - return new TranslatableText("minelp.debug.scale.meg"); + return SCALE_MEGA; } if (value == 2) { - return new TranslatableText("minelp.debug.scale.max"); + return SCALE_MAX; } if (value == 1) { - return new TranslatableText("minelp.debug.scale.mid"); + return SCALE_MID; } if (value == 0.9F) { - return new TranslatableText("minelp.debug.scale.sa"); + return SCALE_SHOW; } if (value <= 0.1F) { - return new TranslatableText("minelp.debug.scale.min"); + return SCALE_MIN; } value *= 100F; value = Math.round(value); value /= 100F; - return new TranslatableText("minelp.debug.scale.value", value); + return Text.translatable("minelp.debug.scale.value", value); } @Override diff --git a/src/main/java/com/minelittlepony/client/hdskins/PonyPreview.java b/src/main/java/com/minelittlepony/client/hdskins/PonyPreview.java index 15c9bc94..07d348ad 100644 --- a/src/main/java/com/minelittlepony/client/hdskins/PonyPreview.java +++ b/src/main/java/com/minelittlepony/client/hdskins/PonyPreview.java @@ -2,7 +2,6 @@ package com.minelittlepony.client.hdskins; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.client.world.ClientWorld; -import net.minecraft.text.LiteralText; import net.minecraft.text.Text; import net.minecraft.util.Identifier; @@ -101,7 +100,7 @@ class PonyPreview extends PlayerPreview { List lines = value.getOptions().stream().map(option -> { boolean selected = value.matches(option); - return new LiteralText((selected ? "* " : " ") + option.name()).styled(s -> { + return Text.literal((selected ? "* " : " ") + option.name()).styled(s -> { int color = option.getChannelAdjustedColorCode(); return (color == 0 ? s : s.withColor(color)).withItalic(selected); }); @@ -109,7 +108,7 @@ class PonyPreview extends PlayerPreview { lines.add(0, Text.of(key.toUpperCase() + ": " + value.getHexValue())); if (lines.size() == 1) { - lines.add(new LiteralText(value.name()).styled(s -> { + lines.add(Text.literal(value.name()).styled(s -> { int color = value.getChannelAdjustedColorCode(); return color == 0 ? s : s.withColor(value.getColorCode()); })); diff --git a/src/main/java/com/minelittlepony/client/mixin/MixinClientPlayerEntity.java b/src/main/java/com/minelittlepony/client/mixin/MixinClientPlayerEntity.java index e213643f..bba1f36d 100644 --- a/src/main/java/com/minelittlepony/client/mixin/MixinClientPlayerEntity.java +++ b/src/main/java/com/minelittlepony/client/mixin/MixinClientPlayerEntity.java @@ -17,7 +17,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(ClientPlayerEntity.class) abstract class MixinClientPlayerEntity extends AbstractClientPlayerEntity implements Pony.RegistrationHandler { - public MixinClientPlayerEntity() { super(null, null); } + public MixinClientPlayerEntity() { super(null, null, null); } private Pony pony; diff --git a/src/main/java/com/minelittlepony/client/model/armour/DefaultArmourTextureResolver.java b/src/main/java/com/minelittlepony/client/model/armour/DefaultArmourTextureResolver.java index cbd3558f..4b79b6d4 100644 --- a/src/main/java/com/minelittlepony/client/model/armour/DefaultArmourTextureResolver.java +++ b/src/main/java/com/minelittlepony/client/model/armour/DefaultArmourTextureResolver.java @@ -120,7 +120,7 @@ public class DefaultArmourTextureResolver implements IArmourTextureResolver { } private final boolean isValid(Identifier texture) { - return MinecraftClient.getInstance().getResourceManager().containsResource(texture); + return MinecraftClient.getInstance().getResourceManager().getResource(texture).isPresent(); } @Override diff --git a/src/main/java/com/minelittlepony/client/pony/BackgroundPonyList.java b/src/main/java/com/minelittlepony/client/pony/BackgroundPonyList.java index 1f28f0e3..46060022 100644 --- a/src/main/java/com/minelittlepony/client/pony/BackgroundPonyList.java +++ b/src/main/java/com/minelittlepony/client/pony/BackgroundPonyList.java @@ -33,7 +33,7 @@ class BackgroundPonyList { public void reloadAll(ResourceManager resourceManager) { backgroundPonyList.clear(); - backgroundPonyList.addAll(resourceManager.findResources("textures/entity/pony", path -> path.endsWith(".png"))); + backgroundPonyList.addAll(resourceManager.findResources("textures/entity/pony", path -> path.getPath().endsWith(".png")).keySet()); MineLittlePony.logger.info("Detected {} background ponies installed.", backgroundPonyList.size()); } diff --git a/src/main/java/com/minelittlepony/client/pony/PonyData.java b/src/main/java/com/minelittlepony/client/pony/PonyData.java index 57bc2532..25223053 100644 --- a/src/main/java/com/minelittlepony/client/pony/PonyData.java +++ b/src/main/java/com/minelittlepony/client/pony/PonyData.java @@ -1,7 +1,6 @@ package com.minelittlepony.client.pony; import net.minecraft.client.MinecraftClient; -import net.minecraft.resource.Resource; import net.minecraft.util.Identifier; import com.google.common.base.MoreObjects; import com.google.gson.annotations.Expose; @@ -16,11 +15,8 @@ import com.minelittlepony.client.MineLittlePony; import com.minelittlepony.client.util.render.NativeUtil; import com.minelittlepony.common.util.animation.Interpolator; -import java.io.FileNotFoundException; import java.io.IOException; -import java.util.Map; -import java.util.TreeMap; -import java.util.UUID; +import java.util.*; import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Unmodifiable; @@ -45,24 +41,21 @@ public class PonyData implements IPonyData { return MEM_NULL; } - try (Resource res = MinecraftClient.getInstance().getResourceManager().getResource(identifier)) { - PonyData data = res.getMetadata(SERIALISER); - - if (data != null) { - return Memoize.of(data); + return MinecraftClient.getInstance().getResourceManager().getResource(identifier).flatMap(res -> { + try { + return res.getMetadata().decode(SERIALISER); + } catch (IOException e) { + MineLittlePony.logger.warn("Unable to read {} metadata", identifier, e); } - } catch (FileNotFoundException e) { - // Ignore uploaded texture - } catch (IOException e) { - MineLittlePony.logger.warn("Unable to read {} metadata", identifier, e); - } - - return Memoize.load(callback -> { - NativeUtil.parseImage(identifier, img -> { - callback.accept(new NativePonyData(img)); - }, e -> { - MineLittlePony.logger.fatal("Unable to read {} metadata", identifier, e); - callback.accept(NULL); + return null; + }).map(Memoize::of).orElseGet(() -> { + return Memoize.load(callback -> { + NativeUtil.parseImage(identifier, img -> { + callback.accept(new NativePonyData(img)); + }, e -> { + MineLittlePony.logger.fatal("Unable to read {} metadata", identifier, e); + callback.accept(NULL); + }); }); }); } diff --git a/src/main/java/com/minelittlepony/client/pony/PonyDataSerialiser.java b/src/main/java/com/minelittlepony/client/pony/PonyDataSerialiser.java index d4b0e465..6905000b 100644 --- a/src/main/java/com/minelittlepony/client/pony/PonyDataSerialiser.java +++ b/src/main/java/com/minelittlepony/client/pony/PonyDataSerialiser.java @@ -3,10 +3,11 @@ package com.minelittlepony.client.pony; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.JsonObject; +import com.minelittlepony.api.pony.IPonyData; import net.minecraft.resource.metadata.ResourceMetadataReader; -class PonyDataSerialiser implements ResourceMetadataReader { +class PonyDataSerialiser implements ResourceMetadataReader { private static final Gson gson = new GsonBuilder() .excludeFieldsWithoutExposeAnnotation() @@ -18,7 +19,7 @@ class PonyDataSerialiser implements ResourceMetadataReader { } @Override - public PonyData fromJson(JsonObject json) { + public IPonyData fromJson(JsonObject json) { return gson.fromJson(json, PonyData.class); } } diff --git a/src/main/java/com/minelittlepony/client/render/blockentity/skull/PonySkull.java b/src/main/java/com/minelittlepony/client/render/blockentity/skull/PonySkull.java index 6d9ba56a..12649526 100644 --- a/src/main/java/com/minelittlepony/client/render/blockentity/skull/PonySkull.java +++ b/src/main/java/com/minelittlepony/client/render/blockentity/skull/PonySkull.java @@ -10,8 +10,8 @@ import com.mojang.authlib.GameProfile; import net.minecraft.client.render.VertexConsumer; import net.minecraft.client.util.DefaultSkinHelper; import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.entity.player.PlayerEntity; import net.minecraft.util.Identifier; +import net.minecraft.util.dynamic.DynamicSerializableUuid; import org.jetbrains.annotations.Nullable; @@ -35,7 +35,7 @@ public class PonySkull extends AbstractPonySkull { return skin; } - return DefaultSkinHelper.getTexture(PlayerEntity.getUuidFromProfile(profile)); + return DefaultSkinHelper.getTexture(DynamicSerializableUuid.getUuidFromProfile(profile)); } return DefaultSkinHelper.getTexture(); diff --git a/src/main/java/com/minelittlepony/client/render/entity/PonyStandRenderer.java b/src/main/java/com/minelittlepony/client/render/entity/PonyStandRenderer.java index c7da40db..d4b4c369 100644 --- a/src/main/java/com/minelittlepony/client/render/entity/PonyStandRenderer.java +++ b/src/main/java/com/minelittlepony/client/render/entity/PonyStandRenderer.java @@ -34,9 +34,9 @@ public class PonyStandRenderer extends ArmorStandEntityRenderer { features.clear(); addFeature(new Armour(this, context)); - addFeature(new HeldItemFeatureRenderer<>(this)); + addFeature(new HeldItemFeatureRenderer<>(this, context.getHeldItemRenderer())); addFeature(new ElytraFeatureRenderer<>(this, context.getModelLoader())); - addFeature(new HeadFeatureRenderer<>(this, context.getModelLoader())); + addFeature(new HeadFeatureRenderer<>(this, context.getModelLoader(), context.getHeldItemRenderer())); } @Override @@ -89,6 +89,6 @@ public class PonyStandRenderer extends ArmorStandEntityRenderer { } static boolean isPonita(ArmorStandEntity entity) { - return entity.hasCustomName() && "Ponita".equals(entity.getCustomName().asString()); + return entity.hasCustomName() && "Ponita".equals(entity.getCustomName().getString()); } } diff --git a/src/main/java/com/minelittlepony/client/render/entity/feature/SkullFeature.java b/src/main/java/com/minelittlepony/client/render/entity/feature/SkullFeature.java index 812d5cb8..ab2e1596 100644 --- a/src/main/java/com/minelittlepony/client/render/entity/feature/SkullFeature.java +++ b/src/main/java/com/minelittlepony/client/render/entity/feature/SkullFeature.java @@ -12,8 +12,7 @@ import net.minecraft.block.AbstractSkullBlock; import net.minecraft.block.SkullBlock; import net.minecraft.block.SkullBlock.SkullType; import net.minecraft.client.MinecraftClient; -import net.minecraft.client.render.RenderLayer; -import net.minecraft.client.render.VertexConsumerProvider; +import net.minecraft.client.render.*; import net.minecraft.client.render.block.entity.SkullBlockEntityModel; import net.minecraft.client.render.block.entity.SkullBlockEntityRenderer; import net.minecraft.client.render.entity.model.EntityModel; @@ -76,7 +75,8 @@ public class SkullFeature & IPo stack.scale(0.625F, -0.625F, -0.625F); stack.translate(0, 0.6F, -0.21F); - MinecraftClient.getInstance().getHeldItemRenderer().renderItem(entity, itemstack, ModelTransformation.Mode.HEAD, false, stack, renderContext, lightUv); + MinecraftClient.getInstance().getItemRenderer() + .renderItem(entity, itemstack, ModelTransformation.Mode.HEAD, false, stack, renderContext, entity.world, lightUv, OverlayTexture.DEFAULT_UV, entity.getId() + ModelTransformation.Mode.HEAD.ordinal()); } private void renderSkull(MatrixStack stack, VertexConsumerProvider renderContext, ItemStack itemstack, boolean isVillager, float limbDistance, int lightUv) { diff --git a/src/main/java/com/minelittlepony/client/render/entity/npc/PonyTextures.java b/src/main/java/com/minelittlepony/client/render/entity/npc/PonyTextures.java index 40f22f1e..08c97683 100644 --- a/src/main/java/com/minelittlepony/client/render/entity/npc/PonyTextures.java +++ b/src/main/java/com/minelittlepony/client/render/entity/npc/PonyTextures.java @@ -82,7 +82,7 @@ public class PonyTextures implem } protected Optional verifyTexture(Identifier texture) { - if (!resourceManager.containsResource(texture)) { + if (resourceManager.getResource(texture).isEmpty()) { MineLittlePony.logger.warn("Villager texture `" + texture + "` was not found."); return Optional.empty(); }