1.20.4 -> 1.20.5

This commit is contained in:
Sollace 2024-04-30 15:45:36 +01:00
parent 36702e1fec
commit 807fb3213a
No known key found for this signature in database
GPG key ID: E52FACE7B5C773DB
30 changed files with 211 additions and 180 deletions

View file

@ -4,7 +4,7 @@ buildscript {
}
}
plugins {
id 'fabric-loom' version '1.5-SNAPSHOT'
id 'fabric-loom' version '1.6-SNAPSHOT'
id 'maven-publish'
id 'com.modrinth.minotaur' version '2.+'
id 'org.ajoberstar.reckon' version '0.13.0'
@ -13,7 +13,7 @@ apply plugin: 'dex.plugins.outlet'
java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
languageVersion = JavaLanguageVersion.of(21)
}
withSourcesJar()
}

View file

@ -3,10 +3,10 @@ org.gradle.daemon=false
# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=1.20.4
yarn_mappings=1.20.4+build.1
loader_version=0.15.1
fabric_version=0.91.2+1.20.4
minecraft_version=1.20.5
yarn_mappings=1.20.5+build.1
loader_version=0.15.7
fabric_version=0.97.5+1.20.5
# Mod Properties
group=com.minelittlepony
@ -19,7 +19,7 @@ org.gradle.daemon=false
modrinth_project_id=JBjInUXM
# Dependencies
modmenu_version=9.0.0-pre.1
kirin_version=1.17.1+1.20.4
hd_skins_version=6.12.2+1.20.4
mson_version=1.9.3+1.20.2
modmenu_version=10.0.0-beta.1
kirin_version=1.18.0-beta.1+1.20.5
hd_skins_version=6.12.3-beta.2+1.20.5
mson_version=1.9.3+1.20.5

View file

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

View file

@ -4,10 +4,11 @@ import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.client.networking.v1.ClientLoginConnectionEvents;
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;
import net.fabricmc.fabric.api.networking.v1.PacketByteBufs;
import net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents;
import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking;
import net.fabricmc.fabric.api.networking.v1.*;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.network.PacketByteBuf;
import net.minecraft.network.codec.PacketCodec;
import net.minecraft.network.packet.CustomPayload;
import net.minecraft.util.Identifier;
import org.apache.logging.log4j.LogManager;
@ -17,8 +18,6 @@ import com.minelittlepony.api.pony.PonyData;
@Environment(EnvType.CLIENT)
public class Channel {
private static final Identifier CLIENT_PONY_DATA = new Identifier("minelittlepony", "pony_data");
private static final Identifier REQUEST_PONY_DATA = new Identifier("minelittlepony", "request_pony_data");
private static final Logger LOGGER = LogManager.getLogger("MineLittlePony:Networking");
private static boolean registered;
@ -27,20 +26,24 @@ public class Channel {
ClientLoginConnectionEvents.INIT.register((handler, client) -> {
registered = false;
});
ServerPlayConnectionEvents.JOIN.register((handler, sender, server) -> {
LOGGER.info("Sending consent packet to " + handler.getPlayer().getName().getString());
sender.sendPacket(REQUEST_PONY_DATA, PacketByteBufs.empty());
sender.sendPacket(PonyDataRequest.INSTANCE);
});
ClientPlayNetworking.registerGlobalReceiver(REQUEST_PONY_DATA, (client, handler, ignored, sender) -> {
PayloadTypeRegistry.playS2C().register(PonyDataRequest.ID, PonyDataRequest.CODEC);
PayloadTypeRegistry.playS2C().register(PonyDataPayload.ID, PonyDataPayload.CODEC);
PayloadTypeRegistry.playC2S().register(PonyDataPayload.ID, PonyDataPayload.CODEC);
ClientPlayNetworking.registerGlobalReceiver(PonyDataRequest.ID, (packet, context) -> {
registered = true;
LOGGER.info("Server has just consented");
});
ServerPlayNetworking.registerGlobalReceiver(CLIENT_PONY_DATA, (server, player, ignore, buffer, ignore2) -> {
PonyData packet = MsgPonyData.read(buffer);
server.execute(() -> {
PonyDataCallback.EVENT.invoker().onPonyDataAvailable(player, packet, EnvType.SERVER);
ServerPlayNetworking.registerGlobalReceiver(PonyDataPayload.ID, (packet, context) -> {
context.player().server.execute(() -> {
PonyDataCallback.EVENT.invoker().onPonyDataAvailable(context.player(), packet.data(), EnvType.SERVER);
});
});
}
@ -57,7 +60,31 @@ public class Channel {
throw new RuntimeException("Client packet send called by the server");
}
ClientPlayNetworking.send(CLIENT_PONY_DATA, MsgPonyData.write(packet, PacketByteBufs.create()));
ClientPlayNetworking.send(new PonyDataPayload(packet));
return true;
}
record PonyDataPayload(PonyData data) implements CustomPayload {
public static final Id<PonyDataPayload> ID = new Id<>(new Identifier("minelittlepony", "pony_data"));
public static final PacketCodec<PacketByteBuf, PonyDataPayload> CODEC = CustomPayload.codecOf(
(p, buffer) -> MsgPonyData.write(p.data(), buffer),
buffer -> new PonyDataPayload(MsgPonyData.read(buffer))
);
@Override
public Id<PonyDataPayload> getId() {
return ID;
}
}
record PonyDataRequest() implements CustomPayload {
public static final PonyDataRequest INSTANCE = new PonyDataRequest();
private static final Id<PonyDataRequest> ID = new Id<>(new Identifier("minelittlepony", "request_pony_data"));
public static final PacketCodec<PacketByteBuf, PonyDataRequest> CODEC = PacketCodec.unit(INSTANCE);
@Override
public Id<? extends CustomPayload> getId() {
return ID;
}
}
}

View file

@ -3,30 +3,31 @@ package com.minelittlepony.api.pony;
import net.minecraft.client.util.DefaultSkinHelper;
import net.minecraft.client.util.SkinTextures;
import net.minecraft.util.Identifier;
import net.minecraft.util.Util;
import com.minelittlepony.api.pony.meta.Race;
import com.minelittlepony.client.MineLittlePony;
import java.util.*;
import java.util.function.Function;
public final class DefaultPonySkinHelper {
public static final Identifier STEVE = new Identifier("minelittlepony", "textures/entity/player/wide/steve_pony.png");
public static final Identifier STEVE = MineLittlePony.id("textures/entity/player/wide/steve_pony.png");
public static final Identifier SEAPONY_SKIN_TYPE_ID = new Identifier("minelp", "seapony");
public static final Identifier NIRIK_SKIN_TYPE_ID = new Identifier("minelp", "nirik");
public static final Identifier SEAPONY_SKIN_TYPE_ID = MineLittlePony.id("seapony");
public static final Identifier NIRIK_SKIN_TYPE_ID = MineLittlePony.id("nirik");
private static final Map<SkinTextures, SkinTextures> SKINS = new HashMap<>();
private static final Function<SkinTextures, SkinTextures> SKINS = Util.memoize(original -> new SkinTextures(
new Identifier("minelittlepony", original.texture().getPath().replace(".png", "_pony.png")),
null,
null,
null,
original.model(),
false
));
public static SkinTextures getTextures(SkinTextures original) {
return SKINS.computeIfAbsent(original, o -> {
return new SkinTextures(
new Identifier("minelittlepony", original.texture().getPath().replace(".png", "_pony.png")),
null,
null,
null,
original.model(),
false
);
});
return SKINS.apply(original);
}
public static String getModelType(UUID id) {

View file

@ -87,7 +87,7 @@ public class HorseCam {
public static float rescaleCameraPitch(double toHeight, float originalPitch) {
MinecraftClient client = MinecraftClient.getInstance();
PlayerEntity player = client.player;
client.gameRenderer.updateTargetedEntity(client.getTickDelta());
client.gameRenderer.updateCrosshairTarget(client.getTickDelta());
HitResult hit = client.crosshairTarget;
if (client.targetedEntity != null) {

View file

@ -9,7 +9,6 @@ import com.minelittlepony.client.render.PonyRenderDispatcher;
import com.minelittlepony.common.client.gui.VisibilityMode;
import com.minelittlepony.common.client.gui.element.Button;
import com.minelittlepony.common.client.gui.sprite.TextureSprite;
import com.minelittlepony.common.event.ClientReadyCallback;
import com.minelittlepony.common.event.ScreenInitCallback;
import com.minelittlepony.common.event.SkinFilterCallback;
import com.minelittlepony.common.util.GamePaths;
@ -48,6 +47,7 @@ public class MineLittlePony implements ClientModInitializer {
private final KeyBinding keyBinding = new KeyBinding("key.minelittlepony.settings", InputUtil.Type.KEYSYM, GLFW.GLFW_KEY_F9, "key.categories.misc");
private final PonyRenderDispatcher renderDispatcher = new PonyRenderDispatcher();
private boolean initialized;
private boolean hasHdSkins;
private boolean hasModMenu;
@ -63,6 +63,10 @@ public class MineLittlePony implements ClientModInitializer {
return instance;
}
public static Identifier id(String name) {
return new Identifier("minelittlepony", name);
}
@Override
public void onInitializeClient() {
hasHdSkins = FabricLoader.getInstance().isModLoaded("hdskins");
@ -81,11 +85,7 @@ public class MineLittlePony implements ClientModInitializer {
SkinFilterCallback.EVENT.register(new LegacySkinConverter());
// general events
ClientReadyCallback.Handler.register();
ClientTickEvents.END_CLIENT_TICK.register(this::onTick);
ClientReadyCallback.EVENT.register(client -> {
renderDispatcher.initialise(client.getEntityRenderDispatcher(), false);
});
ScreenInitCallback.EVENT.register(this::onScreenInit);
config.load();
@ -97,6 +97,10 @@ public class MineLittlePony implements ClientModInitializer {
}
private void onTick(MinecraftClient client) {
if (!initialized) {
initialized = true;
renderDispatcher.initialise(client.getEntityRenderDispatcher(), false);
}
boolean inGame = client.world != null && client.player != null && client.currentScreen == null;
boolean mainMenu = client.currentScreen instanceof TitleScreen;

View file

@ -6,11 +6,11 @@ import com.minelittlepony.api.pony.*;
import com.minelittlepony.api.pony.meta.Wearable;
import com.minelittlepony.common.client.gui.ScrollContainer;
import com.minelittlepony.common.client.gui.element.Button;
import com.minelittlepony.common.event.ClientReadyCallback;
import com.minelittlepony.hdskins.client.*;
import com.minelittlepony.hdskins.client.gui.GuiSkins;
import com.minelittlepony.hdskins.client.gui.player.DummyPlayer;
import com.minelittlepony.hdskins.client.gui.player.skins.PlayerSkins.PlayerSkin;
import com.minelittlepony.hdskins.client.profile.SkinLoader.ProvidedSkins;
import com.minelittlepony.hdskins.profile.SkinType;
import com.mojang.authlib.GameProfile;
@ -37,7 +37,7 @@ public class MineLPHDSkins extends SkinsProxy implements ClientModInitializer {
static SkinType seaponySkinType;
static SkinType nirikSkinType;
static final Map<SkinType, Wearable> wearableTypes = new HashMap<>();
static final Map<SkinType, Wearable> WEARABLE_TYPES = new HashMap<>();
@Override
public void onInitializeClient() {
@ -48,18 +48,18 @@ public class MineLPHDSkins extends SkinsProxy implements ClientModInitializer {
nirikSkinType = SkinType.register(DefaultPonySkinHelper.NIRIK_SKIN_TYPE_ID, Items.LAVA_BUCKET.getDefaultStack());
Wearable.REGISTRY.values().forEach(wearable -> {
if (wearable != Wearable.NONE) {
wearableTypes.put(SkinType.register(wearable.getId(), Items.BUNDLE.getDefaultStack()), wearable);
WEARABLE_TYPES.put(SkinType.register(wearable.getId(), Items.BUNDLE.getDefaultStack()), wearable);
}
});
ClientReadyCallback.EVENT.register(client -> {
// Clear ponies when skins are cleared
SkinCacheClearCallback.EVENT.register(MineLittlePony.getInstance().getManager()::clearCache);
// Ponify the skins GUI.
GuiSkins.setSkinsGui(GuiSkinsMineLP::new);
// Clear ponies when skins are cleared
SkinCacheClearCallback.EVENT.register(() -> {
MineLittlePony.getInstance().getManager().clearCache();
});
// Ponify the skins GUI.
GuiSkins.setSkinsGui(GuiSkinsMineLP::new);
HDSkins.getInstance().getSkinPrioritySorter().addSelector((skinType, playerSkins) -> {
if (skinType == SkinType.SKIN && PonyConfig.getInstance().mixedHumanSkins.get()) {
Optional<Pony> hdPony = getPony(playerSkins.hd());
@ -75,7 +75,7 @@ public class MineLPHDSkins extends SkinsProxy implements ClientModInitializer {
});
}
static Optional<Pony> getPony(PlayerSkins.Layer layer) {
static Optional<Pony> getPony(PlayerSkinLayers.Layer layer) {
return layer
.getSkin(SkinType.SKIN)
.map(Pony.getManager()::getPony);
@ -103,8 +103,9 @@ public class MineLPHDSkins extends SkinsProxy implements ClientModInitializer {
if (entity instanceof AbstractClientPlayerEntity player) {
return PlayerSkins.of(player)
.map(PlayerSkins::combined)
.map(PlayerSkins.Layer::getProvidedSkinTypes)
.map(PlayerSkins::layers)
.map(PlayerSkinLayers::combined)
.map(PlayerSkinLayers.Layer::getProvidedSkinTypes)
.orElseGet(Set::of);
}
@ -132,13 +133,17 @@ public class MineLPHDSkins extends SkinsProxy implements ClientModInitializer {
}
}
return Optional.of(player).flatMap(PlayerSkins::of).map(PlayerSkins::combined).flatMap(skins -> skins.getSkin(type));
return Optional.of(player)
.flatMap(PlayerSkins::of)
.map(PlayerSkins::layers)
.map(PlayerSkinLayers::combined)
.flatMap(skins -> skins.getSkin(type));
}
@Override
public Identifier getSkinTexture(GameProfile profile) {
return HDSkins.getInstance().getProfileRepository()
.getNow(profile)
.load(profile).getNow(ProvidedSkins.EMPTY)
.getSkin(SkinType.SKIN)
.orElseGet(() -> super.getSkinTexture(profile));
}

View file

@ -35,7 +35,7 @@ class PonifiedDualCarouselWidget extends DualCarouselWidget {
return super.getDefaultSkin(SkinType.SKIN, modelVariant);
}
Wearable wearable = MineLPHDSkins.wearableTypes.getOrDefault(type, Wearable.NONE);
Wearable wearable = MineLPHDSkins.WEARABLE_TYPES.getOrDefault(type, Wearable.NONE);
if (wearable != Wearable.NONE) {
return NativeImageFilters.GREYSCALE.load(wearable.getDefaultTexture(), wearable.getDefaultTexture(), getExclusion());

View file

@ -1,19 +1,10 @@
package com.minelittlepony.client.mixin;
import com.minelittlepony.api.pony.Pony;
import com.minelittlepony.client.render.EquineRenderManager;
import net.minecraft.client.network.AbstractClientPlayerEntity;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityDimensions;
import net.minecraft.entity.EntityPose;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(ClientPlayerEntity.class)
abstract class MixinClientPlayerEntity extends AbstractClientPlayerEntity implements EquineRenderManager.RegistrationHandler {
@ -21,39 +12,8 @@ abstract class MixinClientPlayerEntity extends AbstractClientPlayerEntity implem
private final EquineRenderManager.SyncedPony syncedPony = new EquineRenderManager.SyncedPony();
@Inject(method = "startRiding(Lnet/minecraft/entity/Entity;Z)Z", at = @At("RETURN"))
private void onStartRiding(Entity entity, boolean bl, CallbackInfoReturnable<Boolean> info) {
calculateDimensions();
}
@Inject(method = "dismountVehicle()V", at = @At("RETURN"))
private void onStopRiding(CallbackInfo info) {
calculateDimensions();
}
@Override
public EquineRenderManager.SyncedPony getSyncedPony() {
return syncedPony;
}
@Override
public float getActiveEyeHeight(EntityPose pose, EntityDimensions dimensions) {
float value = super.getActiveEyeHeight(pose, dimensions);
Pony pony = Pony.getManager().getPony(this);
if (!pony.race().isHuman()) {
float factor = pony.size().eyeHeightFactor();
if (factor != 1) {
value *= factor;
if (hasVehicle()) {
value += getVehicle().getHeight();
}
return Math.max(value, 0.1F);
}
}
return value;
}
}

View file

@ -1,7 +1,6 @@
package com.minelittlepony.client.mixin;
import net.minecraft.client.render.*;
import net.minecraft.client.util.math.MatrixStack;
import org.joml.Matrix4f;
import org.spongepowered.asm.mixin.Mixin;
@ -14,12 +13,12 @@ import com.minelittlepony.api.model.RenderPass;
@Mixin(GameRenderer.class)
abstract class MixinGameRenderer {
@Inject(method = "renderWorld", at = @At("HEAD"))
private void beforeRenderWorld(float tickDelta, long limitTime, MatrixStack matrices, CallbackInfo info) {
private void beforeRenderWorld(float tickDelta, long limitTime, CallbackInfo info) {
RenderPass.swap(RenderPass.WORLD);
}
@Inject(method = "renderWorld", at = @At("RETURN"))
private void afterRenderWorld(float tickDelta, long limitTime, MatrixStack matrices, CallbackInfo info) {
private void afterRenderWorld(float tickDelta, long limitTime, CallbackInfo info) {
RenderPass.swap(RenderPass.GUI);
}
}
@ -31,7 +30,14 @@ abstract class MixinWorldRenderer {
target = "net.minecraft.client.render.VertexConsumerProvider$Immediate.drawCurrentLayer()V",
ordinal = 0
))
private void onRender(MatrixStack matrices, float tickDelta, long limitTime, boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer, LightmapTextureManager lightmapTextureManager, Matrix4f positionMatrix, CallbackInfo info) {
private void onRender( float tickDelta,
long limitTime,
boolean renderBlockOutline,
Camera camera,
GameRenderer gameRenderer,
LightmapTextureManager lightmapTextureManager,
Matrix4f matrix4f,
Matrix4f matrix4f2, CallbackInfo info) {
RenderPass.swap(RenderPass.HUD);
}
}

View file

@ -0,0 +1,29 @@
package com.minelittlepony.client.mixin;
import net.minecraft.entity.*;
import net.minecraft.entity.player.PlayerEntity;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import com.minelittlepony.api.pony.Pony;
@Mixin(LivingEntity.class)
abstract class MixinLivingEntity {
@Inject(method = "getBaseDimensions", at = @At("RETURN"), cancellable = true)
private void onGetBaseDimensions(EntityPose pose, CallbackInfoReturnable<EntityDimensions> info) {
if (((Object)this) instanceof PlayerEntity player) {
Pony pony = Pony.getManager().getPony(player);
if (!pony.race().isHuman()) {
float factor = pony.size().eyeHeightFactor();
if (factor != 1) {
EntityDimensions dimensions = info.getReturnValue();
info.setReturnValue(dimensions.withEyeHeight(dimensions.eyeHeight() * factor));
}
}
}
}
}

View file

@ -8,6 +8,7 @@ import net.minecraft.client.render.block.entity.BlockEntityRenderer;
import net.minecraft.client.render.block.entity.SkullBlockEntityModel;
import net.minecraft.client.render.block.entity.SkullBlockEntityRenderer;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.component.type.ProfileComponent;
import net.minecraft.util.math.Direction;
import org.spongepowered.asm.mixin.Mixin;
@ -17,7 +18,6 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import com.minelittlepony.client.render.blockentity.skull.PonySkullRenderer;
import com.mojang.authlib.GameProfile;
import org.jetbrains.annotations.Nullable;
@ -46,9 +46,9 @@ abstract class MixinSkullBlockEntityRenderer implements BlockEntityRenderer<Skul
@Inject(method = "getRenderLayer("
+ "Lnet/minecraft/block/SkullBlock$SkullType;"
+ "Lcom/mojang/authlib/GameProfile;"
+ "Lnet/minecraft/component/type/ProfileComponent;"
+ ")Lnet/minecraft/client/render/RenderLayer;", at = @At("HEAD"), cancellable = true)
private static void onGetRenderLayer(SkullBlock.SkullType skullType, @Nullable GameProfile profile, CallbackInfoReturnable<RenderLayer> info) {
private static void onGetRenderLayer(SkullBlock.SkullType skullType, @Nullable ProfileComponent profile, CallbackInfoReturnable<RenderLayer> info) {
if (!info.isCancelled()) {
RenderLayer result = PonySkullRenderer.getSkullRenderLayer(skullType, profile);
if (result != null) {

View file

@ -2,11 +2,12 @@ package com.minelittlepony.client.model.armour;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.texture.TextureManager;
import net.minecraft.component.DataComponentTypes;
import net.minecraft.component.type.CustomModelDataComponent;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.EquipmentSlot;
import net.minecraft.item.ArmorItem;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NbtElement;
import net.minecraft.registry.Registries;
import net.minecraft.util.Identifier;
import com.google.common.base.Strings;
@ -48,7 +49,7 @@ public class ArmourTextureResolver {
public Identifier getTexture(LivingEntity entity, ItemStack stack, EquipmentSlot slot, ArmourLayer layer, @Nullable String type) {
Identifier material = stack.getItem() instanceof ArmorItem armor
? new Identifier(armor.getMaterial().getName())
? armor.getMaterial().getKey().get().getValue()
: Registries.ITEM.getId(stack.getItem());
String custom = getCustom(stack);
@ -79,8 +80,9 @@ public class ArmourTextureResolver {
}
private String getCustom(ItemStack stack) {
if (stack.hasNbt() && stack.getNbt().contains("CustomModelData", NbtElement.NUMBER_TYPE)) {
return "custom_" + stack.getNbt().getInt("CustomModelData");
CustomModelDataComponent customModelData = stack.get(DataComponentTypes.CUSTOM_MODEL_DATA);
if (customModelData != null) {
return "custom_" + customModelData.value();
}
return "none";
}

View file

@ -86,7 +86,7 @@ public class EquineRenderManager<T extends LivingEntity, M extends EntityModel<T
}
}
public void setupTransforms(T entity, MatrixStack stack, float ageInTicks, float rotationYaw, float tickDelta) {
public void setupTransforms(T entity, MatrixStack stack, float animationProgress, float bodyYaw, float tickDelta, float scale) {
float s = getScaleFactor();
stack.scale(s, s, s);
@ -109,10 +109,10 @@ public class EquineRenderManager<T extends LivingEntity, M extends EntityModel<T
}
}
rotationYaw = getMountedYaw(entity, rotationYaw, tickDelta);
transformer.setupTransforms(entity, stack, ageInTicks, rotationYaw, tickDelta);
bodyYaw = getMountedYaw(entity, bodyYaw, tickDelta);
transformer.setupTransforms(entity, stack, animationProgress, bodyYaw, tickDelta, scale);
PonyPosture.of(getModels().body().getAttributes()).apply(entity, getModels().body(), stack, rotationYaw, tickDelta, 1);
PonyPosture.of(getModels().body().getAttributes()).apply(entity, getModels().body(), stack, bodyYaw, tickDelta, 1);
}
private void translateRider(T entity, Pony pony, LivingEntity passenger, Pony passengerPony, MatrixStack stack, float tickDelta) {
@ -168,7 +168,7 @@ public class EquineRenderManager<T extends LivingEntity, M extends EntityModel<T
}
public interface Transformer<T extends LivingEntity> {
void setupTransforms(T entity, MatrixStack stack, float ageInTicks, float rotationYaw, float partialTicks);
void setupTransforms(T entity, MatrixStack stack, float animationProgress, float bodyYaw, float tickDelta, float scale);
}
public interface RegistrationHandler {

View file

@ -7,13 +7,13 @@ import com.minelittlepony.client.model.AbstractPonyModel;
import com.minelittlepony.client.render.MobRenderers;
import com.minelittlepony.client.render.blockentity.skull.PonySkullRenderer.ISkull;
import com.minelittlepony.mson.api.ModelKey;
import com.mojang.authlib.GameProfile;
import java.util.function.Supplier;
import net.minecraft.client.model.ModelPart;
import net.minecraft.client.render.VertexConsumer;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.component.type.ProfileComponent;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.RotationAxis;
@ -38,7 +38,7 @@ public class MobSkull implements ISkull {
}
@Override
public Identifier getSkinResource(@Nullable GameProfile profile) {
public Identifier getSkinResource(@Nullable ProfileComponent profile) {
return texture;
}

View file

@ -7,7 +7,6 @@ import com.minelittlepony.api.pony.SkinsProxy;
import com.minelittlepony.api.pony.meta.Race;
import com.minelittlepony.client.model.*;
import com.minelittlepony.client.render.blockentity.skull.PonySkullRenderer.ISkull;
import com.mojang.authlib.GameProfile;
import java.util.HashMap;
import java.util.Map;
@ -15,6 +14,7 @@ import java.util.Map;
import net.minecraft.client.render.VertexConsumer;
import net.minecraft.client.util.DefaultSkinHelper;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.component.type.ProfileComponent;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.RotationAxis;
@ -35,17 +35,17 @@ public class PlayerPonySkull implements ISkull {
}
@Override
public Identifier getSkinResource(@Nullable GameProfile profile) {
renderingEars = profile != null && "deadmau5".equals(profile.getName());
public Identifier getSkinResource(@Nullable ProfileComponent profile) {
renderingEars = profile != null && "deadmau5".equals(profile.gameProfile().getName());
if (profile != null) {
Identifier skin = SkinsProxy.instance.getSkinTexture(profile);
Identifier skin = SkinsProxy.instance.getSkinTexture(profile.gameProfile());
if (skin != null) {
return skin;
}
return DefaultSkinHelper.getSkinTextures(profile).texture();
return DefaultSkinHelper.getSkinTextures(profile.gameProfile()).texture();
}
return DefaultSkinHelper.getTexture();

View file

@ -7,7 +7,6 @@ import com.minelittlepony.client.model.ModelType;
import com.minelittlepony.client.render.MobRenderers;
import com.minelittlepony.client.render.entity.SkeleponyRenderer;
import com.minelittlepony.client.render.entity.ZomponyRenderer;
import com.mojang.authlib.GameProfile;
import net.minecraft.block.SkullBlock;
import net.minecraft.client.render.OverlayTexture;
@ -15,6 +14,7 @@ import net.minecraft.client.render.RenderLayer;
import net.minecraft.client.render.VertexConsumer;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.component.type.ProfileComponent;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.Direction;
@ -43,7 +43,7 @@ public class PonySkullRenderer {
skullMap.put(SkullBlock.Type.PLAYER, new PlayerPonySkull());
}
public static RenderLayer getSkullRenderLayer(SkullBlock.SkullType skullType, @Nullable GameProfile profile) {
public static RenderLayer getSkullRenderLayer(SkullBlock.SkullType skullType, @Nullable ProfileComponent profile) {
selectedSkull = null;
selectedSkin = null;
@ -109,7 +109,7 @@ public class PonySkullRenderer {
boolean canRender(PonyConfig config);
Identifier getSkinResource(@Nullable GameProfile profile);
Identifier getSkinResource(@Nullable ProfileComponent profile);
boolean bindPony(Pony pony);
}

View file

@ -27,6 +27,7 @@ import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.entity.mob.MobEntity;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.Vec3d;
public abstract class AbstractPonyRenderer<T extends MobEntity, M extends EntityModel<T> & PonyModel<T> & ModelWithArms> extends MobEntityRenderer<T, M> implements PonyRenderContext<T, M> {
@ -74,8 +75,8 @@ public abstract class AbstractPonyRenderer<T extends MobEntity, M extends Entity
}
@Override
protected void setupTransforms(T entity, MatrixStack stack, float ageInTicks, float rotationYaw, float partialTicks) {
manager.setupTransforms(entity, stack, ageInTicks, rotationYaw, partialTicks);
protected void setupTransforms(T entity, MatrixStack stack, float animationProgress, float bodyYaw, float tickDelta, float scale) {
manager.setupTransforms(entity, stack, animationProgress, bodyYaw, tickDelta, scale);
}
@Override
@ -94,18 +95,20 @@ public abstract class AbstractPonyRenderer<T extends MobEntity, M extends Entity
if (!entity.hasVehicle()) {
stack.translate(0, 0, -entity.getWidth() / 2); // move us to the center of the shadow
} else {
stack.translate(0, entity.getRidingOffset(entity.getVehicle()), 0);
// TODO: Check this
Vec3d attachmentPos = entity.getVehicleAttachmentPos(entity.getVehicle());
stack.translate(attachmentPos.getX(), attachmentPos.getY(), attachmentPos.getZ());
}
stack.scale(scale, scale, scale);
}
@Override
protected void renderLabelIfPresent(T entity, Text name, MatrixStack stack, VertexConsumerProvider renderContext, int maxDistance) {
stack.push();
stack.translate(0, manager.getNamePlateYOffset(entity), 0);
super.renderLabelIfPresent(entity, name, stack, renderContext, maxDistance);
stack.pop();
protected void renderLabelIfPresent(T entity, Text name, MatrixStack matrices, VertexConsumerProvider vertices, int light, float tickDelta) {
matrices.push();
matrices.translate(0, manager.getNamePlateYOffset(entity), 0);
super.renderLabelIfPresent(entity, name, matrices, vertices, light, tickDelta);
matrices.pop();
}
@Override

View file

@ -36,14 +36,14 @@ public class AquaticPlayerPonyRenderer extends FormChangingPlayerPonyRenderer {
}
@Override
protected void setupTransforms(AbstractClientPlayerEntity player, MatrixStack stack, float ageInTicks, float rotationYaw, float partialTicks) {
protected void setupTransforms(AbstractClientPlayerEntity player, MatrixStack matrices, float animationProgress, float bodyYaw, float tickDelta, float scale) {
if (PonyPosture.isSeaponyModifier(player)) {
stack.translate(0, 0.6, 0);
matrices.translate(0, 0.6 * scale, 0);
if (player.isInSneakingPose()) {
stack.translate(0, 0.125, 0);
matrices.translate(0, 0.125 * scale, 0);
}
}
super.setupTransforms(player, stack, ageInTicks, rotationYaw, partialTicks);
super.setupTransforms(player, matrices, animationProgress, bodyYaw, tickDelta, scale);
}
@Override

View file

@ -27,6 +27,7 @@ import net.minecraft.client.render.entity.feature.*;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.Text;
import net.minecraft.util.*;
import net.minecraft.util.math.Vec3d;
public class PlayerPonyRenderer extends PlayerEntityRenderer implements PonyRenderContext<AbstractClientPlayerEntity, ClientPonyModel<AbstractClientPlayerEntity>> {
private final Function<Race, Models<AbstractClientPlayerEntity, ClientPonyModel<AbstractClientPlayerEntity>>> modelsCache;
@ -70,7 +71,9 @@ public class PlayerPonyRenderer extends PlayerEntityRenderer implements PonyRend
@Override
protected void scale(AbstractClientPlayerEntity entity, MatrixStack stack, float tickDelta) {
if (manager.getModels().body().getAttributes().isSitting && entity.hasVehicle()) {
stack.translate(0, entity.getRidingOffset(entity.getVehicle()), 0);
// TODO: Check this
Vec3d attachmentPos = entity.getVehicleAttachmentPos(entity.getVehicle());
stack.translate(attachmentPos.getX(), attachmentPos.getY(), attachmentPos.getZ());
}
}
@ -102,8 +105,8 @@ public class PlayerPonyRenderer extends PlayerEntityRenderer implements PonyRend
}
@Override
protected void setupTransforms(AbstractClientPlayerEntity entity, MatrixStack stack, float ageInTicks, float rotationYaw, float partialTicks) {
manager.setupTransforms(entity, stack, ageInTicks, rotationYaw, partialTicks);
protected void setupTransforms(AbstractClientPlayerEntity entity, MatrixStack matrices, float animationProgress, float bodyYaw, float tickDelta, float scale) {
manager.setupTransforms(entity, matrices, animationProgress, bodyYaw, tickDelta, scale);
}
@Override
@ -116,7 +119,7 @@ public class PlayerPonyRenderer extends PlayerEntityRenderer implements PonyRend
}
@Override
protected void renderLabelIfPresent(AbstractClientPlayerEntity entity, Text name, MatrixStack stack, VertexConsumerProvider renderContext, int maxDistance) {
protected void renderLabelIfPresent(AbstractClientPlayerEntity entity, Text name, MatrixStack stack, VertexConsumerProvider renderContext, int light, float tickDelta) {
stack.push();
if (entity.isSleeping()) {
@ -127,7 +130,7 @@ public class PlayerPonyRenderer extends PlayerEntityRenderer implements PonyRend
}
}
stack.translate(0, manager.getNamePlateYOffset(entity), 0);
super.renderLabelIfPresent(entity, name, stack, renderContext, maxDistance);
super.renderLabelIfPresent(entity, name, stack, renderContext, light, tickDelta);
stack.pop();
}

View file

@ -52,10 +52,10 @@ public class PonyStandRenderer extends ArmorStandEntityRenderer {
}
@Override
protected void setupTransforms(ArmorStandEntity entity, MatrixStack stack, float f, float g, float h) {
super.setupTransforms(entity, stack, f, g, h);
protected void setupTransforms(ArmorStandEntity entity, MatrixStack stack, float animationProgress, float bodyYaw, float tickDelta, float scale) {
super.setupTransforms(entity, stack, animationProgress, bodyYaw, tickDelta, scale);
if (isPonita(entity)) {
stack.translate(0, 0, -4/16F);
stack.translate(0, 0, scale * -4/16F);
}
}

View file

@ -64,7 +64,7 @@ public class SeaponyRenderer extends GuardianEntityRenderer {
}
@Override
protected void setupTransforms(GuardianEntity entity, MatrixStack stack, float ageInTicks, float rotationYaw, float partialTicks) {
ponyRenderer.manager.setupTransforms(entity, stack, ageInTicks, rotationYaw, partialTicks);
protected void setupTransforms(GuardianEntity entity, MatrixStack stack, float animationProgress, float bodyYaw, float tickDelta, float scale) {
ponyRenderer.manager.setupTransforms(entity, stack, animationProgress, bodyYaw, tickDelta, scale);
}
}

View file

@ -15,10 +15,13 @@ import net.minecraft.client.render.model.BakedModelManager;
import net.minecraft.client.texture.Sprite;
import net.minecraft.client.texture.SpriteAtlasTexture;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.component.DataComponentTypes;
import net.minecraft.component.type.DyedColorComponent;
import net.minecraft.entity.EquipmentSlot;
import net.minecraft.entity.LivingEntity;
import net.minecraft.item.*;
import net.minecraft.item.trim.ArmorTrim;
import net.minecraft.registry.entry.RegistryEntry;
import net.minecraft.util.Identifier;
public class ArmourFeature<T extends LivingEntity, M extends EntityModel<T> & PonyModel<T>> extends AbstractPonyFeature<T, M> {
@ -56,7 +59,6 @@ public class ArmourFeature<T extends LivingEntity, M extends EntityModel<T> & Po
ArmourVariant variant = ArmourTextureResolver.INSTANCE.getVariant(layer, texture);
boolean glint = stack.hasGlint();
Item item = stack.getItem();
pony.getArmourModel(stack, layer, variant)
.filter(m -> m.poseModel(entity, limbAngle, limbDistance, age, headYaw, headPitch, armorSlot, layer, pony.body()))
@ -65,8 +67,10 @@ public class ArmourFeature<T extends LivingEntity, M extends EntityModel<T> & Po
float green = 1;
float blue = 1;
if (item instanceof DyeableArmorItem dyeable) {
int color = dyeable.getColor(stack);
DyedColorComponent colorComponent = stack.get(DataComponentTypes.DYED_COLOR);
if (colorComponent != null) {
int color = colorComponent.rgb();
red = Color.r(color);
green = Color.g(color);
blue = Color.b(color);
@ -74,7 +78,7 @@ public class ArmourFeature<T extends LivingEntity, M extends EntityModel<T> & Po
model.render(matrices, getArmorConsumer(renderContext, texture, glint), light, OverlayTexture.DEFAULT_UV, red, green, blue, 1);
if (item instanceof DyeableArmorItem) {
if (colorComponent != null) {
Identifier tex = ArmourTextureResolver.INSTANCE.getTexture(entity, stack, armorSlot, layer, "overlay");
pony.getArmourModel(stack, layer, ArmourTextureResolver.INSTANCE.getVariant(layer, tex))
.filter(m -> m.poseModel(entity, limbAngle, limbDistance, age, headYaw, headPitch, armorSlot, layer, pony.body()))
@ -83,13 +87,13 @@ public class ArmourFeature<T extends LivingEntity, M extends EntityModel<T> & Po
});
}
if (stack.getItem() instanceof ArmorItem armor) {
ArmorTrim.getTrim(entity.getWorld().getRegistryManager(), stack, true).ifPresent(trim -> {
pony.getArmourModel(stack, layer, ArmourVariant.TRIM)
.filter(m -> m.poseModel(entity, limbAngle, limbDistance, age, headYaw, headPitch, armorSlot, layer, pony.body()))
.ifPresent(m -> {
m.render(matrices, getTrimConsumer(renderContext, armor.getMaterial(), trim, layer, glint), light, OverlayTexture.DEFAULT_UV, 1, 1, 1, 1);
});
ArmorTrim trim = stack.get(DataComponentTypes.TRIM);
if (trim != null && stack.getItem() instanceof ArmorItem armor) {
pony.getArmourModel(stack, layer, ArmourVariant.TRIM)
.filter(m -> m.poseModel(entity, limbAngle, limbDistance, age, headYaw, headPitch, armorSlot, layer, pony.body()))
.ifPresent(m -> {
m.render(matrices, getTrimConsumer(renderContext, armor.getMaterial(), trim, layer, glint), light, OverlayTexture.DEFAULT_UV, 1, 1, 1, 1);
});
}
});
@ -99,7 +103,7 @@ public class ArmourFeature<T extends LivingEntity, M extends EntityModel<T> & Po
return ItemRenderer.getArmorGlintConsumer(provider, ArmorRenderLayers.getArmorTranslucentNoCull(texture, false), false, glint);
}
private static VertexConsumer getTrimConsumer(VertexConsumerProvider provider, ArmorMaterial material, ArmorTrim trim, ArmourLayer layer, boolean glint) {
private static VertexConsumer getTrimConsumer(VertexConsumerProvider provider, RegistryEntry<ArmorMaterial> material, ArmorTrim trim, ArmourLayer layer, boolean glint) {
SpriteAtlasTexture armorTrimsAtlas = MinecraftClient.getInstance().getBakedModelManager().getAtlas(TexturedRenderLayers.ARMOR_TRIMS_ATLAS_TEXTURE);
Sprite sprite = armorTrimsAtlas.getSprite(
layer == ArmourLayer.INNER ? trim.getLeggingsModelId(material) : trim.getGenericModelId(material)

View file

@ -4,7 +4,6 @@ import com.minelittlepony.api.model.BodyPart;
import com.minelittlepony.api.model.PonyModel;
import com.minelittlepony.client.model.AbstractPonyModel;
import com.minelittlepony.client.render.PonyRenderContext;
import com.mojang.authlib.GameProfile;
import java.util.Map;
@ -19,6 +18,7 @@ import net.minecraft.client.render.entity.model.EntityModel;
import net.minecraft.client.render.entity.model.EntityModelLoader;
import net.minecraft.client.render.model.json.ModelTransformationMode;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.component.DataComponentTypes;
import net.minecraft.util.math.RotationAxis;
import net.minecraft.entity.EquipmentSlot;
import net.minecraft.entity.LivingEntity;
@ -26,8 +26,6 @@ import net.minecraft.item.ArmorItem;
import net.minecraft.item.BlockItem;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.NbtHelper;
import net.minecraft.village.VillagerDataContainer;
public class SkullFeature<T extends LivingEntity, M extends EntityModel<T> & PonyModel<T>> extends AbstractPonyFeature<T, M> {
@ -87,20 +85,10 @@ public class SkullFeature<T extends LivingEntity, M extends EntityModel<T> & Pon
stack.translate(0, 0.0625F, 0);
}
GameProfile profile = null;
if (itemstack.hasNbt()) {
NbtCompound nbt = itemstack.getNbt();
if (nbt.contains("SkullOwner", 10)) {
profile = NbtHelper.toGameProfile(nbt.getCompound("SkullOwner"));
}
}
stack.translate(-0.5, 0, -0.5);
SkullType type = ((AbstractSkullBlock) ((BlockItem) itemstack.getItem()).getBlock()).getSkullType();
SkullBlockEntityModel skullBlockEntityModel = (SkullBlockEntityModel)this.headModels.get(type);
RenderLayer renderLayer = SkullBlockEntityRenderer.getRenderLayer(type, profile);
RenderLayer renderLayer = SkullBlockEntityRenderer.getRenderLayer(type, itemstack.get(DataComponentTypes.PROFILE));
SkullBlockEntityRenderer.renderSkull(null, 180, f, stack, renderContext, lightUv, skullBlockEntityModel, renderLayer);
}

View file

@ -33,11 +33,11 @@ public class ZomponyVillagerRenderer extends AbstractNpcRenderer<ZombieVillagerE
}
@Override
protected void setupTransforms(ZombieVillagerEntity entity, MatrixStack stack, float move, float rotationYaw, float ticks) {
protected void setupTransforms(ZombieVillagerEntity entity, MatrixStack matrices, float animationProgress, float bodyYaw, float tickDelta, float scale) {
if (entity.isConverting()) {
rotationYaw += (float) (Math.cos(entity.age * 3.25D) * (Math.PI / 4));
bodyYaw += (float) (Math.cos(entity.age * 3.25D) * (Math.PI / 4));
}
super.setupTransforms(entity, stack, move, rotationYaw, ticks);
super.setupTransforms(entity, matrices, animationProgress, bodyYaw, tickDelta, scale);
}
}

View file

@ -14,7 +14,7 @@ import java.util.function.Function;
public class PlayerTextureSupplier {
public static <T extends LivingEntity> TextureSupplier<T> create(TextureSupplier<T> fallback) {
Function<String, CompletableFuture<Identifier>> customNameCache = Util.memoize(name -> {
return SkullBlockEntity.fetchProfile(name).thenApply(profile -> {
return SkullBlockEntity.fetchProfileByName(name).thenApply(profile -> {
return profile
.map(p -> SkinsProxy.instance.getSkinTexture(p))
.filter(skin -> !Pony.getManager().getPony(skin).race().isHuman())

View file

@ -64,7 +64,7 @@ public interface PonyPosture {
}
}
float roll = (float)player.getRoll() + tickDelta;
float roll = (float)player.getFallFlyingTicks() + tickDelta;
float targetRoll = MathHelper.clamp(roll * roll / 100F, 0, 1);
if (!player.isUsingRiptide()) {
stack.multiply(RotationAxis.NEGATIVE_X.rotationDegrees(targetRoll * (-90 - player.getPitch())));

View file

@ -9,5 +9,3 @@ accessible method net/minecraft/client/render/RenderLayer
accessible method net/minecraft/client/render/RenderLayer$MultiPhase getPhases ()Lnet/minecraft/client/render/RenderLayer$MultiPhaseParameters;
accessible method net/minecraft/client/render/RenderPhase$TextureBase getId ()Ljava/util/Optional;
accessible field net/minecraft/client/render/RenderLayer$MultiPhaseParameters texture Lnet/minecraft/client/render/RenderPhase$TextureBase;
accessible method net/minecraft/block/entity/SkullBlockEntity fetchProfile (Ljava/lang/String;)Ljava/util/concurrent/CompletableFuture;

View file

@ -12,6 +12,7 @@
"MixinSkullBlockEntityRenderer",
"MixinHeldItemRenderer",
"MixinClientPlayerEntity",
"MixinLivingEntity",
"MixinPlayerMoveC2SPacket",
"MixinPlayerPositionLookS2CPacket",
"MixinVertextConsumers",