Skip to content

Commit

Permalink
Merge pull request #44 from mineblock11/fixes-etc
Browse files Browse the repository at this point in the history
  • Loading branch information
IMB11 authored Aug 22, 2023
2 parents 0df93fb + af76767 commit 5f10eae
Show file tree
Hide file tree
Showing 30 changed files with 29 additions and 543 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ The carousel is where all your skins will be stored for future use! You can crea

You can customize every preset to your own desire in the edit screen.
<br><br>
<center><img width="50%" src="https://cdn.modrinth.com/data/3s19I5jr/images/2146f756a3c5ef7e916e8f3d02e36a1bfa8d19ad.png"></center>
<center><img width="50%" src="https://cdn.modrinth.com/data/3s19I5jr/images/ced596ec493eff53b3be5139fc991cf1e4d18d16.png"><img width="50%" src="https://cdn.modrinth.com/data/3s19I5jr/images/fea4801fa0923716a06982652c23c9a5c3fc72cf.png"></center>

<h3 id="edit-screen">Edit Screen</h2>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,39 +20,16 @@

package com.mineblock11.skinshuffle.client;

import com.mineblock11.skinshuffle.SkinShuffle;
import com.mineblock11.skinshuffle.client.config.SkinPresetManager;
import com.mineblock11.skinshuffle.client.config.SkinShuffleConfig;
import com.mineblock11.skinshuffle.networking.ClientSkinHandling;
import com.mineblock11.skinshuffle.util.CapeCacheRegistry;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.resource.ResourceManagerHelper;
import net.fabricmc.fabric.api.resource.SimpleSynchronousResourceReloadListener;
import net.minecraft.client.MinecraftClient;
import net.minecraft.resource.ResourceManager;
import net.minecraft.resource.ResourceType;
import net.minecraft.util.Identifier;
import org.jsoup.Connection;
import org.jsoup.Jsoup;

public class SkinShuffleClient implements ClientModInitializer {
@Override
public void onInitializeClient() {
SkinPresetManager.setup();
ClientSkinHandling.init();
SkinShuffleConfig.load();

ResourceManagerHelper.get(ResourceType.CLIENT_RESOURCES).registerReloadListener(new SimpleSynchronousResourceReloadListener() {
@Override
public Identifier getFabricId() {
return SkinShuffle.id("skinshuffle");
}

@Override
public void reload(ResourceManager manager) {
CapeCacheRegistry.clearCache();
CapeCacheRegistry.applyFromPreset(SkinPresetManager.getChosenPreset(), MinecraftClient.getInstance().getSession().getUsername());
}
});
}
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@

import com.google.gson.GsonBuilder;
import com.mineblock11.skinshuffle.SkinShuffle;
import com.mineblock11.skinshuffle.client.cape.provider.CapeProvider;
import com.mineblock11.skinshuffle.client.cape.provider.CapeProviders;
import com.mineblock11.skinshuffle.client.config.gson.CapeProviderTypeAdapter;
import dev.isxander.yacl3.api.*;
import dev.isxander.yacl3.api.controller.EnumControllerBuilder;
import dev.isxander.yacl3.api.controller.FloatSliderControllerBuilder;
Expand All @@ -34,19 +31,16 @@
import net.minecraft.text.Text;

import java.nio.file.Path;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import static net.minecraft.text.Text.*;
import static net.minecraft.text.Text.translatable;

public class SkinShuffleConfig {
private static final Path CONFIG_FILE_PATH = SkinShuffle.DATA_DIR.resolve("config.json");
private static final GsonConfigInstance<SkinShuffleConfig> GSON = GsonConfigInstance.createBuilder(SkinShuffleConfig.class)
.overrideGsonBuilder(new GsonBuilder()
.setPrettyPrinting()
.disableHtmlEscaping()
.registerTypeAdapter(CapeProvider.class, new CapeProviderTypeAdapter())
.create())
.setPath(CONFIG_FILE_PATH)
.build();
Expand All @@ -65,12 +59,6 @@ public static void save() {
}

public void postLoad() {
// Add any new cape providers to the config
HashSet<CapeProvider> capeProviders = new HashSet<>(Set.of(CapeProviders.values()));
for (var provider : capeProviders) {
if (this.capeProviders.contains(provider)) continue;
this.capeProviders.add(provider);
}
save();
}

Expand Down Expand Up @@ -189,7 +177,6 @@ public static YetAnotherConfigLib getInstance() {
@ConfigEntry public boolean disableReconnectToast = false;

@ConfigEntry public boolean disableAPIUpload = false;
@ConfigEntry public Set<CapeProvider> capeProviders = new HashSet<>();

@ConfigEntry public boolean displayInPauseMenu = true;
@ConfigEntry public boolean displayInTitleScreen = true;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
import com.mineblock11.skinshuffle.client.config.SkinPresetManager;
import com.mineblock11.skinshuffle.client.config.SkinShuffleConfig;
import com.mineblock11.skinshuffle.client.gui.widgets.ActualSpruceIconButtonWidget;
import com.mineblock11.skinshuffle.client.gui.widgets.preset.AddCardWidget;
import com.mineblock11.skinshuffle.client.gui.widgets.preset.AbstractCardWidget;
import com.mineblock11.skinshuffle.client.gui.widgets.preset.AddCardWidget;
import com.mineblock11.skinshuffle.client.gui.widgets.preset.PresetWidget;
import com.mineblock11.skinshuffle.client.preset.SkinPreset;
import com.mineblock11.skinshuffle.client.skin.Skin;
Expand All @@ -39,7 +39,7 @@
import dev.lambdaurora.spruceui.widget.SpruceIconButtonWidget;
import dev.lambdaurora.spruceui.widget.SpruceWidget;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.*;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.util.GlfwUtil;
import net.minecraft.screen.ScreenTexts;
import net.minecraft.text.Text;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import dev.lambdaurora.spruceui.Position;
import dev.lambdaurora.spruceui.widget.SpruceButtonWidget;
import dev.lambdaurora.spruceui.widget.SpruceIconButtonWidget;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.screen.ScreenTexts;
import net.minecraft.text.Text;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
package com.mineblock11.skinshuffle.client.gui;

import com.mineblock11.skinshuffle.SkinShuffle;
import com.mineblock11.skinshuffle.client.cape.provider.CapeProvider;
import com.mineblock11.skinshuffle.client.cape.provider.CapeProviders;
import com.mineblock11.skinshuffle.client.config.SkinPresetManager;
import com.mineblock11.skinshuffle.client.config.SkinShuffleConfig;
import com.mineblock11.skinshuffle.client.gui.cursed.DummyClientPlayerEntity;
Expand Down Expand Up @@ -388,16 +386,8 @@ public SkinCustomizationTab() {
presetNameField.setChangedListener(preset::setName);
presetNameField.setMaxLength(2048);

var capeProviderSelector = new CyclingButtonWidget.Builder<CapeProvider>(provider -> Text.translatable(provider.getTranslationKey()))
.values(CapeProvider.NONE, CapeProvider.AUTO, CapeProviders.MOJANG, CapeProviders.OPTIFINE, CapeProviders.MC_CAPES)
.initially(preset.getCapeProvider())
.build(0, 0, 192, 20,
Text.translatable("skinshuffle.edit.customize.cape_provider"),
(btn, value) -> preset.setCapeProvider(value));

gridAdder.add(new TextWidget(Text.translatable("skinshuffle.edit.customize.preset_name"), textRenderer));
gridAdder.add(presetNameField);
gridAdder.add(capeProviderSelector);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,19 @@
package com.mineblock11.skinshuffle.client.gui.cursed;

import com.mineblock11.skinshuffle.client.preset.SkinPreset;
import com.mineblock11.skinshuffle.util.CapeCacheRegistry;
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.network.ClientPlayNetworkHandler;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.client.network.PlayerListEntry;
import net.minecraft.client.render.entity.PlayerModelPart;
import net.minecraft.client.render.entity.feature.CapeFeatureRenderer;
import net.minecraft.client.util.DefaultSkinHelper;
import net.minecraft.client.world.ClientWorld;
import net.minecraft.entity.EquipmentSlot;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
import org.jetbrains.annotations.Nullable;

import java.util.UUID;
import java.util.function.Function;
import java.util.function.Supplier;

public class DummyClientPlayerEntity extends ClientPlayerEntity {
private static DummyClientPlayerEntity instance;
Expand All @@ -67,23 +60,6 @@ public boolean hasSkinTexture() {
return true;
}

@Override
public boolean canRenderCapeTexture() {
if(this.skinPreset != null) {
return CapeCacheRegistry.doesPlayerHaveCape(getUserUsername(), this.skinPreset.getCapeProvider(), this.getUuidAsString());
}
return false;
}

@Nullable
@Override
public Identifier getCapeTexture() {
if(this.skinPreset != null) {
return CapeCacheRegistry.getCapeTexture(getUserUsername(), this.skinPreset.getCapeProvider(), null);
}
return null;
}

@Override
public Identifier getSkinTexture() {
@Nullable Identifier presetTexture = skinPreset.getSkin().getTexture();
Expand Down
Loading

0 comments on commit 5f10eae

Please sign in to comment.