Skip to content

Commit

Permalink
Merge branch '1.20.1' into 1.20.2
Browse files Browse the repository at this point in the history
# Conflicts:
#	gradle.properties
  • Loading branch information
Sollace committed Mar 11, 2024
2 parents 6f3dfb2 + 3609ff5 commit 90b306f
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 27 deletions.
6 changes: 4 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,10 @@ modrinth {
gameVersions.add ver
}
dependencies {
required.project 'P7dR8mSH'
optional.project 'JBjInUXM'
required.project 'P7dR8mSH' //fabric-api
optional.project 'JBjInUXM' //minelp
optional.project 'FzE9gshV' //hdskins
embedded.project '9aNz8Zqn' //kirin
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ private void rebuildContent() {
bigPony.setVisual(!v);
if (v) {
visual.setEnabled(false);
PresetDetector.getInstance().detectPreset(client.getGameProfile(), bigPony).handle((skin, ex) -> {
PresetDetector.getInstance().detectPreset(client.getSession().getProfile(), bigPony).handle((skin, ex) -> {
visual.setEnabled(true);
xSize.setValue(bigPony.getScale().x);
ySize.setValue(bigPony.getScale().y);
Expand Down Expand Up @@ -172,6 +172,7 @@ static Function<AbstractSlider<Float>, Text> format(String key) {

@Override
public void render(DrawContext context, int mouseX, int mouseY, float partialTicks) {
renderBackground(context);
super.render(context, mouseX, mouseY, partialTicks);
content.render(context, mouseX, mouseY, partialTicks);
}
Expand Down
15 changes: 8 additions & 7 deletions src/main/java/com/minelittlepony/bigpony/hdskins/Main.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.minelittlepony.bigpony.hdskins;

import java.util.Optional;
import java.util.concurrent.CompletableFuture;

import com.minelittlepony.bigpony.util.FutureUtils;
Expand All @@ -9,6 +8,7 @@
import com.mojang.authlib.GameProfile;

import net.fabricmc.api.ClientModInitializer;
import net.minecraft.client.MinecraftClient;
import net.minecraft.util.Identifier;

public class Main extends SkinDetecter implements ClientModInitializer {
Expand All @@ -20,11 +20,12 @@ public void onInitializeClient() {

@Override
public CompletableFuture<Identifier> loadSkin(GameProfile profile) {
return FutureUtils.<Optional<Identifier>>either(
HDSkins.getInstance().getProfileRepository().load(profile).thenApply(skins -> {
return skins.getSkin(SkinType.SKIN);
}),
Optional::empty
).thenCompose(value -> value.map(CompletableFuture::completedFuture).orElseGet(() -> super.loadSkin(profile)));
return FutureUtils.<Identifier>waitFor(callback -> {
HDSkins.getInstance().getProfileRepository().fetchSkins(profile, (type, texture, payload) -> {
if (type == SkinType.SKIN) {
MinecraftClient.getInstance().executeTask(() -> callback.accept(texture));
}
});
}, () -> null).thenCompose(value -> value == null ? super.loadSkin(profile) : CompletableFuture.completedFuture(value));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import com.minelittlepony.bigpony.util.FutureUtils;
import com.mojang.authlib.GameProfile;
import net.minecraft.client.MinecraftClient;
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
import net.minecraft.client.util.DefaultSkinHelper;
import net.minecraft.client.util.SkinTextures;
import net.minecraft.util.Identifier;

public class SkinDetecter {
Expand All @@ -19,9 +19,12 @@ public static SkinDetecter getInstance() {
SkinDetecter() {}

public CompletableFuture<Identifier> loadSkin(GameProfile profile) {
return FutureUtils.either(
MinecraftClient.getInstance().getSkinProvider().fetchSkinTextures(profile),
() -> DefaultSkinHelper.getTexture(profile.getId())
).thenApply(SkinTextures::texture);
return FutureUtils.waitFor(callback -> {
MinecraftClient.getInstance().getSkinProvider().loadSkin(profile, (type, texture, payload) -> {
if (type == MinecraftProfileTexture.Type.SKIN) {
MinecraftClient.getInstance().executeTask(() -> callback.accept(texture));
}
}, false);
}, () -> DefaultSkinHelper.getTexture(profile.getId()));
}
}
24 changes: 12 additions & 12 deletions src/main/java/com/minelittlepony/bigpony/minelittlepony/Main.java
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
package com.minelittlepony.bigpony.minelittlepony;

import com.minelittlepony.api.pony.Pony;
import com.minelittlepony.api.pony.IPony;
import com.minelittlepony.api.pony.meta.Size;
import com.minelittlepony.api.pony.network.fabric.PonyDataCallback;
import com.minelittlepony.bigpony.*;
import com.minelittlepony.bigpony.client.BigPonyClient;
import com.minelittlepony.bigpony.hdskins.SkinDetecter;
import com.mojang.authlib.GameProfile;

import java.util.concurrent.CompletableFuture;

import com.minelittlepony.api.model.PonyModel;
import com.minelittlepony.api.config.PonyConfig;
import com.minelittlepony.api.events.PonyDataCallback;
import com.minelittlepony.api.events.PonyModelPrepareCallback;
import com.minelittlepony.api.model.IModel;
import com.minelittlepony.api.model.ModelAttributes;
import com.minelittlepony.api.model.fabric.PonyModelPrepareCallback;

import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.api.EnvType;
Expand All @@ -29,7 +29,7 @@ public void onInitializeClient() {
INSTANCE = this;

PonyModelPrepareCallback.EVENT.register(this::onPonyModelPrepared);
PonyDataCallback.EVENT.register((sender, data, env) -> {
PonyDataCallback.EVENT.register((sender, data, noSkin, env) -> {
if (!BigPony.getInstance().getScaling().isVisual()
&& env == EnvType.CLIENT
&& BigPonyClient.isClientPlayer(sender)) {
Expand All @@ -38,9 +38,9 @@ public void onInitializeClient() {
});
}

private void onPonyModelPrepared(Entity entity, PonyModel<?> model, ModelAttributes.Mode mode) {
private void onPonyModelPrepared(Entity entity, IModel model, ModelAttributes.Mode mode) {
if (entity instanceof Scaled && !((Scaled)entity).getScaling().isVisual() && isPony((PlayerEntity)entity)) {
model.getAttributes().visualHeight = entity.getHeight() / model.getSize().scaleFactor();
model.getAttributes().visualHeight = entity.getHeight() / model.getSize().getScaleFactor();
}
}

Expand All @@ -51,7 +51,7 @@ public boolean isFillyCam() {

@Override
public boolean isPony(PlayerEntity player) {
return !Pony.getManager().getPony(player).race().isHuman();
return !IPony.getManager().getPony(player).race().isHuman();
}

@Override
Expand All @@ -60,11 +60,11 @@ public CompletableFuture<Identifier> detectPreset(GameProfile profile, Scaling i
// Turn on filly cam so we can get the camera parameters
PonyConfig.getInstance().fillycam.set(true);

Pony pony = Pony.getManager().getPony(skin);
Size size = pony.metadata().size();
IPony pony = IPony.getManager().getPony(skin);
Size size = pony.metadata().getSize();

into.setScale(new Triple(size.scaleFactor()));
into.setCamera(new Cam(size.eyeDistanceFactor(), size.eyeHeightFactor()));
into.setScale(new Triple(size.getScaleFactor()));
into.setCamera(new Cam(size.getEyeDistanceFactor(), size.getEyeHeightFactor()));

// We turn off filly cam because it's not needed and might cause issues with buckets if left enabled
PonyConfig.getInstance().fillycam.set(false);
Expand Down

0 comments on commit 90b306f

Please sign in to comment.