mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2024-11-22 04:27:59 +01:00
Move SkinsProxy to the api package and decouple from the implementations a little better
This commit is contained in:
parent
b538174933
commit
9f280f79eb
10 changed files with 29 additions and 36 deletions
|
@ -2,7 +2,6 @@ package com.minelittlepony.api.model;
|
|||
|
||||
import com.minelittlepony.api.config.PonyConfig;
|
||||
import com.minelittlepony.api.pony.*;
|
||||
import com.minelittlepony.client.*;
|
||||
import com.minelittlepony.common.util.animation.Interpolator;
|
||||
import com.minelittlepony.util.MathUtil;
|
||||
|
||||
|
|
|
@ -11,6 +11,8 @@ import java.util.*;
|
|||
public final class DefaultPonySkinHelper {
|
||||
public static final Identifier STEVE = new Identifier("minelittlepony", "textures/entity/player/wide/steve_pony.png");
|
||||
|
||||
public static final Identifier SEAPONY_SKIN_TYPE_ID = new Identifier("minelp", "seapony");
|
||||
|
||||
private static final Map<SkinTextures, SkinTextures> SKINS = new HashMap<>();
|
||||
|
||||
public static SkinTextures getTextures(SkinTextures original) {
|
||||
|
|
|
@ -2,8 +2,6 @@ package com.minelittlepony.api.pony;
|
|||
|
||||
import com.minelittlepony.api.pony.meta.Race;
|
||||
import com.minelittlepony.api.model.PreviewModel;
|
||||
import com.minelittlepony.client.SkinsProxy;
|
||||
import com.minelittlepony.client.render.entity.AquaticPlayerPonyRenderer;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
|
@ -101,7 +99,7 @@ public final class PonyPosture {
|
|||
}
|
||||
return Pony.getManager().getPony(entity).filter(pony -> {
|
||||
return (pony.race() == Race.SEAPONY
|
||||
|| (entity instanceof AbstractClientPlayerEntity player && SkinsProxy.instance.getSkin(AquaticPlayerPonyRenderer.SKIN_TYPE_ID, player).isPresent())
|
||||
|| (entity instanceof AbstractClientPlayerEntity player && SkinsProxy.instance.getSkin(DefaultPonySkinHelper.SEAPONY_SKIN_TYPE_ID, player).isPresent())
|
||||
);
|
||||
}).isPresent();
|
||||
}
|
||||
|
|
|
@ -1,24 +1,20 @@
|
|||
package com.minelittlepony.client;
|
||||
package com.minelittlepony.api.pony;
|
||||
|
||||
import com.minelittlepony.common.client.gui.ScrollContainer;
|
||||
import com.minelittlepony.common.client.gui.Tooltip;
|
||||
import com.minelittlepony.common.client.gui.element.Button;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.network.AbstractClientPlayerEntity;
|
||||
import net.minecraft.client.texture.PlayerSkinProvider;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Proxy handler for getting player skin data from HDSkins
|
||||
*/
|
||||
public class SkinsProxy {
|
||||
|
||||
public static SkinsProxy instance = new SkinsProxy();
|
||||
|
||||
public Identifier getSkinTexture(GameProfile profile) {
|
||||
|
@ -26,14 +22,6 @@ public class SkinsProxy {
|
|||
return skins.getSkinTextures(profile).texture();
|
||||
}
|
||||
|
||||
public void renderOption(Screen screen, @Nullable Screen parent, int row, int RIGHT, ScrollContainer content) {
|
||||
content.addButton(new Button(RIGHT, row += 20, 150, 20))
|
||||
.setEnabled(false)
|
||||
.getStyle()
|
||||
.setTooltip(Tooltip.of("minelp.options.skins.hdskins.disabled", 200))
|
||||
.setText("minelp.options.skins.hdskins.open");
|
||||
}
|
||||
|
||||
public Optional<Identifier> getSkin(Identifier skinTypeId, AbstractClientPlayerEntity player) {
|
||||
return Optional.empty();
|
||||
}
|
|
@ -35,6 +35,14 @@ public class PonySettingsScreen extends GameGui {
|
|||
public static final Text SCALE_SHOW = Text.translatable("minelp.debug.scale.sa");
|
||||
public static final Text SCALE_MIN = Text.translatable("minelp.debug.scale.min");
|
||||
|
||||
public static HorseButtonFactory buttonFactory = (screen, parent, row, RIGHT, content) -> {
|
||||
content.addButton(new Button(RIGHT, row += 20, 150, 20))
|
||||
.setEnabled(false)
|
||||
.getStyle()
|
||||
.setTooltip(Tooltip.of("minelp.options.skins.hdskins.disabled", 200))
|
||||
.setText("minelp.options.skins.hdskins.open");
|
||||
};
|
||||
|
||||
private final PonyConfig config = PonyConfig.getInstance();
|
||||
|
||||
private final ScrollContainer content = new ScrollContainer();
|
||||
|
@ -156,7 +164,7 @@ public class PonySettingsScreen extends GameGui {
|
|||
row += 15;
|
||||
|
||||
content.addButton(new Label(RIGHT, row)).getStyle().setText("minelp.options.skins");
|
||||
SkinsProxy.instance.renderOption(this, parent, row, RIGHT, content);
|
||||
buttonFactory.renderOption(this, parent, row, RIGHT, content);
|
||||
}
|
||||
|
||||
public Text describeCurrentScale(AbstractSlider<Float> sender) {
|
||||
|
@ -194,4 +202,8 @@ public class PonySettingsScreen extends GameGui {
|
|||
public void removed() {
|
||||
config.save();
|
||||
}
|
||||
|
||||
public interface HorseButtonFactory {
|
||||
void renderOption(Screen screen, @Nullable Screen parent, int row, int RIGHT, ScrollContainer content);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,8 +2,7 @@ package com.minelittlepony.client.compat.hdskins;
|
|||
|
||||
import com.minelittlepony.api.config.PonyConfig;
|
||||
import com.minelittlepony.api.config.PonyLevel;
|
||||
import com.minelittlepony.api.pony.Pony;
|
||||
import com.minelittlepony.api.pony.PonyData;
|
||||
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;
|
||||
|
@ -29,7 +28,6 @@ import net.minecraft.item.Items;
|
|||
import net.minecraft.util.Identifier;
|
||||
|
||||
import com.minelittlepony.client.*;
|
||||
import com.minelittlepony.client.render.entity.AquaticPlayerPonyRenderer;
|
||||
|
||||
/**
|
||||
* All the interactions with HD Skins.
|
||||
|
@ -43,8 +41,9 @@ public class MineLPHDSkins extends SkinsProxy implements ClientModInitializer {
|
|||
@Override
|
||||
public void onInitializeClient() {
|
||||
SkinsProxy.instance = this;
|
||||
PonySettingsScreen.buttonFactory = this::renderOption;
|
||||
|
||||
seaponySkinType = SkinType.register(AquaticPlayerPonyRenderer.SKIN_TYPE_ID, Items.COD_BUCKET.getDefaultStack());
|
||||
seaponySkinType = SkinType.register(DefaultPonySkinHelper.SEAPONY_SKIN_TYPE_ID, Items.COD_BUCKET.getDefaultStack());
|
||||
Wearable.REGISTRY.values().forEach(wearable -> {
|
||||
if (wearable != Wearable.NONE) {
|
||||
wearableTypes.put(SkinType.register(wearable.getId(), Items.BUNDLE.getDefaultStack()), wearable);
|
||||
|
@ -80,8 +79,7 @@ public class MineLPHDSkins extends SkinsProxy implements ClientModInitializer {
|
|||
.map(Pony.getManager()::getPony);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderOption(Screen screen, @Nullable Screen parent, int row, int RIGHT, ScrollContainer content) {
|
||||
private void renderOption(Screen screen, @Nullable Screen parent, int row, int RIGHT, ScrollContainer content) {
|
||||
content.addButton(new Button(RIGHT, row += 20, 150, 20))
|
||||
.onClick(button -> MinecraftClient.getInstance().setScreen(
|
||||
parent instanceof GuiSkins ? parent : GuiSkins.create(screen, HDSkins.getInstance().getSkinServerList())
|
||||
|
|
|
@ -3,8 +3,8 @@ package com.minelittlepony.client.render.blockentity.skull;
|
|||
import com.minelittlepony.api.config.PonyConfig;
|
||||
import com.minelittlepony.api.config.PonyLevel;
|
||||
import com.minelittlepony.api.pony.Pony;
|
||||
import com.minelittlepony.api.pony.SkinsProxy;
|
||||
import com.minelittlepony.api.pony.meta.Race;
|
||||
import com.minelittlepony.client.SkinsProxy;
|
||||
import com.minelittlepony.client.model.*;
|
||||
import com.minelittlepony.client.render.blockentity.skull.PonySkullRenderer.ISkull;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
package com.minelittlepony.client.render.entity;
|
||||
|
||||
import com.minelittlepony.api.model.PreviewModel;
|
||||
import com.minelittlepony.api.pony.Pony;
|
||||
import com.minelittlepony.api.pony.PonyPosture;
|
||||
import com.minelittlepony.api.pony.*;
|
||||
import com.minelittlepony.api.pony.meta.Race;
|
||||
import com.minelittlepony.client.SkinsProxy;
|
||||
import com.minelittlepony.util.MathUtil;
|
||||
|
||||
import net.minecraft.client.network.AbstractClientPlayerEntity;
|
||||
|
@ -16,8 +14,6 @@ import net.minecraft.util.Arm;
|
|||
import net.minecraft.util.Identifier;
|
||||
|
||||
public class AquaticPlayerPonyRenderer extends PlayerPonyRenderer {
|
||||
public static final Identifier SKIN_TYPE_ID = new Identifier("minelp", "seapony");
|
||||
|
||||
private boolean wet;
|
||||
|
||||
public AquaticPlayerPonyRenderer(EntityRendererFactory.Context context, boolean slim) {
|
||||
|
@ -27,7 +23,7 @@ public class AquaticPlayerPonyRenderer extends PlayerPonyRenderer {
|
|||
@Override
|
||||
public Identifier getTexture(AbstractClientPlayerEntity player) {
|
||||
if (wet) {
|
||||
return SkinsProxy.instance.getSkin(SKIN_TYPE_ID, player).orElseGet(() -> super.getTexture(player));
|
||||
return SkinsProxy.instance.getSkin(DefaultPonySkinHelper.SEAPONY_SKIN_TYPE_ID, player).orElseGet(() -> super.getTexture(player));
|
||||
}
|
||||
return super.getTexture(player);
|
||||
}
|
||||
|
|
|
@ -3,9 +3,9 @@ package com.minelittlepony.client.render.entity;
|
|||
import com.minelittlepony.api.model.ModelAttributes;
|
||||
import com.minelittlepony.api.model.ModelWrapper;
|
||||
import com.minelittlepony.api.pony.Pony;
|
||||
import com.minelittlepony.api.pony.SkinsProxy;
|
||||
import com.minelittlepony.api.pony.meta.Race;
|
||||
import com.minelittlepony.api.pony.meta.Wearable;
|
||||
import com.minelittlepony.client.SkinsProxy;
|
||||
import com.minelittlepony.client.model.*;
|
||||
import com.minelittlepony.client.render.DebugBoundingBoxRenderer;
|
||||
import com.minelittlepony.client.render.PonyRenderContext;
|
||||
|
|
|
@ -6,7 +6,7 @@ import net.minecraft.util.Identifier;
|
|||
import net.minecraft.util.Util;
|
||||
|
||||
import com.minelittlepony.api.pony.Pony;
|
||||
import com.minelittlepony.client.SkinsProxy;
|
||||
import com.minelittlepony.api.pony.SkinsProxy;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.function.Function;
|
||||
|
|
Loading…
Reference in a new issue