v1.4.0
This commit is contained in:
1 parent
9f1ea674b8
commit
3f09bda1e0
2 files changed
+41
-1
No files matched your search
@@ -10,6 +10,7 @@ import com.lzxnone.terraria.entity.projectile.StaticProjectile;
|
||||
import com.lzxnone.terraria.entity.summon.*;
|
||||
import com.lzxnone.terraria.item.ModItems;
|
||||
import com.lzxnone.terraria.particle.ZenithTrailParticleOptions;
|
||||
import com.lzxnone.terraria.network.SkinFetch;
|
||||
import com.lzxnone.terraria.utils.*;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
@@ -105,7 +106,7 @@ public class FirstFractal extends SwordItem {
|
||||
ItemStack item = summon.getEntityData().get(StaticSummon.ITEM);
|
||||
if(item == ItemStack.EMPTY) return;
|
||||
|
||||
GameProfile profile = new GameProfile(uuid, "");
|
||||
GameProfile profile = SkinFetch.getCachedProfile(uuid);
|
||||
PlayerSkin playerSkin = Minecraft.getInstance().getSkinManager().getInsecureSkin(profile);
|
||||
|
||||
boolean isSlim = playerSkin.model() == PlayerSkin.Model.SLIM;
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.lzxnone.terraria.network;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.minecraft.MinecraftSessionService;
|
||||
import com.mojang.authlib.yggdrasil.ProfileResult;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class SkinFetch {
|
||||
private static final Map<UUID, GameProfile> PROFILE_CACHE = new ConcurrentHashMap<>();
|
||||
|
||||
public static void fetchProfile(UUID uuid) {
|
||||
CompletableFuture.supplyAsync(() -> {
|
||||
try {
|
||||
MinecraftSessionService sessionService = Minecraft.getInstance().getMinecraftSessionService();
|
||||
ProfileResult result = sessionService.fetchProfile(uuid, true);
|
||||
if(result != null) {
|
||||
GameProfile filled = result.profile();
|
||||
PROFILE_CACHE.put(uuid, filled);
|
||||
return filled;
|
||||
}
|
||||
}catch (Exception ignored) {}
|
||||
GameProfile fallback = new GameProfile(uuid, "");
|
||||
PROFILE_CACHE.put(uuid, fallback);
|
||||
return fallback;
|
||||
});
|
||||
}
|
||||
|
||||
public static GameProfile getCachedProfile(UUID uuid) {
|
||||
GameProfile cached = PROFILE_CACHE.get(uuid);
|
||||
if(cached != null) return cached;
|
||||
fetchProfile(uuid);
|
||||
return new GameProfile(uuid, "");
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user