Fix fillycam

This commit is contained in:
Sollace 2024-05-04 19:43:24 +01:00
parent eeea8ee184
commit 85726e8c8d
No known key found for this signature in database
GPG key ID: E52FACE7B5C773DB
3 changed files with 17 additions and 13 deletions

View file

@ -53,8 +53,11 @@ public class PonyManagerImpl implements PonyManager, SimpleSynchronousResourceRe
@Override
public Pony getPony(PlayerEntity player) {
final UUID id = player instanceof ForcedPony ? null : player.getGameProfile() == null ? player.getUuid() : player.getGameProfile().getId();
@Nullable
Identifier skin = getSkin(player);
skin = MoreObjects.firstNonNull(PonySkinResolver.EVENT.invoker().onPonySkinResolving(player, s -> getPony(s, id), skin), skin);
if (skin != null) {
skin = MoreObjects.firstNonNull(PonySkinResolver.EVENT.invoker().onPonySkinResolving(player, s -> getPony(s, id), skin), skin);
}
return getPony(skin, id);
}
@ -63,8 +66,11 @@ public class PonyManagerImpl implements PonyManager, SimpleSynchronousResourceRe
if (entity instanceof PlayerEntity player) {
return Optional.of(getPony(player));
}
@Nullable
Identifier skin = getSkin(entity);
skin = MoreObjects.firstNonNull(PonySkinResolver.EVENT.invoker().onPonySkinResolving(entity, s -> getPony(s, null), skin), skin);
if (skin != null) {
skin = MoreObjects.firstNonNull(PonySkinResolver.EVENT.invoker().onPonySkinResolving(entity, s -> getPony(s, null), skin), skin);
}
return skin == null ? Optional.empty() : Optional.of(getPony(skin, null));
}

View file

@ -10,19 +10,17 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import com.minelittlepony.api.pony.Pony;
@Mixin(LivingEntity.class)
abstract class MixinLivingEntity {
@Mixin(PlayerEntity.class)
abstract class MixinPlayerEntity {
@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);
Pony pony = Pony.getManager().getPony((PlayerEntity)(Object)this);
if (!pony.race().isHuman()) {
float factor = pony.size().eyeHeightFactor();
if (factor != 1) {
EntityDimensions dimensions = info.getReturnValue();
info.setReturnValue(dimensions.withEyeHeight(dimensions.eyeHeight() * factor));
}
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

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