fix: cosmetics system
This commit is contained in:
parent
ae42a1a04c
commit
e6ff1536e2
|
@ -64,8 +64,12 @@ public class CosmeticsManager {
|
|||
}
|
||||
|
||||
public static Identifier getCape(UUID player) {
|
||||
loadPlayer(player);
|
||||
return capeCache.getOrDefault(player, null);
|
||||
if (!activePlayers.contains(player)) {
|
||||
activePlayers.add(player);
|
||||
loadPlayer(player);
|
||||
}
|
||||
refresh();
|
||||
return capeCache.get(player);
|
||||
}
|
||||
|
||||
protected static GeoModel getModel(Identifier id) {
|
||||
|
|
|
@ -15,12 +15,12 @@ import com.google.gson.JsonSyntaxException;
|
|||
|
||||
import net.anvilcraft.anvillib.AnvilLib;
|
||||
|
||||
public abstract class FileDownloaderThread implements Runnable {
|
||||
public abstract class AbstractFileDownloaderThread implements Runnable {
|
||||
protected Gson gson = new GsonBuilder().create();
|
||||
protected HttpClient client = HttpClient.newBuilder().build();
|
||||
protected final String version;
|
||||
|
||||
public FileDownloaderThread(String version) {
|
||||
public AbstractFileDownloaderThread(String version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
|
@ -16,7 +16,7 @@ import net.minecraft.client.texture.PlayerSkinTexture;
|
|||
import net.minecraft.client.texture.TextureManager;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
public class CapeLoaderThread extends FileDownloaderThread {
|
||||
public class CapeLoaderThread extends AbstractFileDownloaderThread {
|
||||
private String id;
|
||||
private File cacheDir;
|
||||
private URI url;
|
||||
|
|
|
@ -35,7 +35,7 @@ import software.bernie.geckolib3.geo.render.GeoBuilder;
|
|||
import software.bernie.geckolib3.geo.render.built.GeoModel;
|
||||
import software.bernie.geckolib3.util.json.JsonAnimationUtils;
|
||||
|
||||
public class CosmeticAssetsLoaderThread extends FileDownloaderThread {
|
||||
public class CosmeticAssetsLoaderThread extends AbstractFileDownloaderThread {
|
||||
private RemoteCosmetic cosmetic;
|
||||
private CosmeticData data;
|
||||
private MolangParser parser = new MolangParser();
|
||||
|
|
|
@ -8,7 +8,7 @@ import net.anvilcraft.anvillib.cosmetics.remote.RemoteCosmetic;
|
|||
import net.anvilcraft.anvillib.cosmetics.remote.RemoteCosmeticProvider;
|
||||
import net.anvilcraft.anvillib.cosmetics.remote.model.CosmeticData;
|
||||
|
||||
public class CosmeticLoaderThread extends FileDownloaderThread {
|
||||
public class CosmeticLoaderThread extends AbstractFileDownloaderThread {
|
||||
private URI url;
|
||||
private RemoteCosmeticProvider provider;
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ import java.net.URI;
|
|||
import net.anvilcraft.anvillib.cosmetics.remote.RemoteCosmeticProvider;
|
||||
import net.anvilcraft.anvillib.cosmetics.remote.model.PlayerData;
|
||||
|
||||
public class PlayerCosmeticLoaderThread extends FileDownloaderThread {
|
||||
public class PlayerCosmeticLoaderThread extends AbstractFileDownloaderThread {
|
||||
private URI config;
|
||||
private RemoteCosmeticProvider provider;
|
||||
|
||||
|
@ -30,6 +30,8 @@ public class PlayerCosmeticLoaderThread extends FileDownloaderThread {
|
|||
this.provider.loadCape(player.cape);
|
||||
this.provider.playerCapes.put(player.uuid, player.cape);
|
||||
}
|
||||
|
||||
this.provider.markDirty();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
|
|
@ -1,17 +1,15 @@
|
|||
package net.anvilcraft.anvillib;
|
||||
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
|
||||
@Mod(AnvilLib.MODID)
|
||||
public class AnvilLibForge {
|
||||
public AnvilLibForge() {
|
||||
AnvilLib.initialize();
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onClientInitialize(FMLClientSetupEvent event) {
|
||||
AnvilLib.initializeClient();
|
||||
IEventBus bus = FMLJavaModLoadingContext.get().getModEventBus();
|
||||
bus.<FMLClientSetupEvent>addListener(alec -> AnvilLib.initializeClient());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue