fix: format code

tilera WTF
This commit is contained in:
LordMZTE 2023-11-24 18:52:05 +01:00
parent 809e33e6ac
commit e80123d38f
Signed by: LordMZTE
GPG key ID: B64802DC33A64FF6
24 changed files with 209 additions and 151 deletions

View file

@ -18,5 +18,4 @@ public class AnvilLib {
public static void initializeClient() {
Bus.MAIN.register(new ClientEventHandler());
}
}

View file

@ -15,9 +15,9 @@ import net.minecraft.client.render.entity.PlayerEntityRenderer;
import net.minecraft.entity.player.PlayerEntity;
public class ClientEventHandler implements IEventBusRegisterable {
private void onAddLayers(AddEntityRenderLayersEvent ev) {
for (Entry<String, EntityRenderer<? extends PlayerEntity>> skin : ev.skinMap().entrySet())
for (Entry<String, EntityRenderer<? extends PlayerEntity>> skin :
ev.skinMap().entrySet())
if (skin.getValue() instanceof PlayerEntityRenderer render)
render.addFeature(new CosmeticFeatureRenderer(render, skin.getKey()));
}
@ -28,7 +28,9 @@ public class ClientEventHandler implements IEventBusRegisterable {
URI playerBase = new URI("https://api.tilera.xyz/anvillib/data/players/");
URI cosmeticBase = new URI("https://api.tilera.xyz/anvillib/data/cosmetics/");
URI capeBase = new URI("https://api.tilera.xyz/anvillib/data/capes/");
CosmeticsManager.registerProvider(new RemoteCosmeticProvider(playerBase, cosmeticBase, capeBase, cacheDir));
CosmeticsManager.registerProvider(
new RemoteCosmeticProvider(playerBase, cosmeticBase, capeBase, cacheDir)
);
} catch (Exception e) {
AnvilLib.LOGGER.error(e);
}

View file

@ -113,7 +113,9 @@ public class CosmeticArmorRenderer extends BipedEntityModel<PlayerEntity>
poseStack.scale(-1, -1, 1);
double currentTick = entityLiving.age; // TODO: Custom frametime/animation speed
currentFrame = ((int)(currentTick * 1.0F)) % this.getCurrentCosmetic().getTotalFrames();;
currentFrame
= ((int) (currentTick * 1.0F)) % this.getCurrentCosmetic().getTotalFrames();
;
//this.dispatchedMat = poseStack.last().pose().copy();
this.dispatchedMat = poseStack.peek().getPositionMatrix().copy();
@ -406,20 +408,46 @@ public class CosmeticArmorRenderer extends BipedEntityModel<PlayerEntity>
}
public float calcVOffset(float v) {
float totalFrames = (float)this.getCurrentCosmetic().getTotalFrames();
float currentTextureOffset = (float)currentFrame / totalFrames;
return (v / totalFrames) + currentTextureOffset;
}
float totalFrames = (float) this.getCurrentCosmetic().getTotalFrames();
float currentTextureOffset = (float) currentFrame / totalFrames;
return (v / totalFrames) + currentTextureOffset;
}
@Override
public void createVerticesOfQuad(GeoQuad quad, Matrix4f poseState, Vec3f normal, VertexConsumer buffer,
int packedLight, int packedOverlay, float red, float green, float blue, float alpha) {
for (GeoVertex vertex : quad.vertices) {
Vector4f vector4f = new Vector4f(vertex.position.getX(), vertex.position.getY(), vertex.position.getZ(), 1);
@Override
public void createVerticesOfQuad(
GeoQuad quad,
Matrix4f poseState,
Vec3f normal,
VertexConsumer buffer,
int packedLight,
int packedOverlay,
float red,
float green,
float blue,
float alpha
) {
for (GeoVertex vertex : quad.vertices) {
Vector4f vector4f = new Vector4f(
vertex.position.getX(), vertex.position.getY(), vertex.position.getZ(), 1
);
vector4f.transform(poseState);
buffer.vertex(vector4f.getX(), vector4f.getY(), vector4f.getZ(), red, green, blue, alpha, vertex.textureU,
calcVOffset(vertex.textureV), packedOverlay, packedLight, normal.getX(), normal.getY(), normal.getZ());
}
}
vector4f.transform(poseState);
buffer.vertex(
vector4f.getX(),
vector4f.getY(),
vector4f.getZ(),
red,
green,
blue,
alpha,
vertex.textureU,
calcVOffset(vertex.textureV),
packedOverlay,
packedLight,
normal.getX(),
normal.getY(),
normal.getZ()
);
}
}
}

View file

@ -43,7 +43,8 @@ public class CosmeticFeatureRenderer extends ArmorFeatureRenderer<
float netHeadYaw,
float headPitch
) {
if (player.isInvisible()) return;
if (player.isInvisible())
return;
for (ICosmetic c : CosmeticsManager.getCosmeticsForPlayer(player.getUuid())) {
if (c.readyToRender())
this.renderCosmetic(matrix, buffer, player, light, c, partialTicks);

View file

@ -17,7 +17,9 @@ public class CosmeticItem implements IAnimatable {
public CosmeticItem(ICosmetic cosmetic) {
this.cosmetic = cosmetic;
if (cosmetic.getIdleAnimationName() != null) {
this.animationBuilder.addAnimation(cosmetic.getIdleAnimationName(), EDefaultLoopTypes.LOOP);
this.animationBuilder.addAnimation(
cosmetic.getIdleAnimationName(), EDefaultLoopTypes.LOOP
);
}
}

View file

@ -28,20 +28,22 @@ public class CosmeticModel extends AnimatedGeoModel<CosmeticItem> {
}
@Override
public Animation getAnimation(String name, IAnimatable animatable) {
Identifier location = ((CosmeticItem)animatable).getCosmetic().getAnimationFileLocation();
AnimationFile animation = CosmeticsManager.getAnimations(location);
public Animation getAnimation(String name, IAnimatable animatable) {
Identifier location
= ((CosmeticItem) animatable).getCosmetic().getAnimationFileLocation();
AnimationFile animation = CosmeticsManager.getAnimations(location);
if (animation == null) {
animation = GeckoLibCache.getInstance().getAnimations().get(location);
}
if (animation == null) {
throw new GeckoLibException(location,
"Could not find animation file. Please double check name.");
}
return animation.getAnimation(name);
}
if (animation == null) {
throw new GeckoLibException(
location, "Could not find animation file. Please double check name."
);
}
return animation.getAnimation(name);
}
@Override
public GeoModel getModel(Identifier location) {
@ -50,16 +52,16 @@ public class CosmeticModel extends AnimatedGeoModel<CosmeticItem> {
model = GeckoLibCache.getInstance().getGeoModels().get(location);
}
AnimatedGeoModelAccessor accessor = (AnimatedGeoModelAccessor)this;
AnimatedGeoModelAccessor accessor = (AnimatedGeoModelAccessor) this;
if (model != accessor.getCurrentModel()) {
accessor.getAnimationProcessor().clearModelRendererList();
accessor.setCurrentModel(model);
accessor.getAnimationProcessor().clearModelRendererList();
accessor.setCurrentModel(model);
for (GeoBone bone : model.topLevelBones) {
registerBone(bone);
}
}
for (GeoBone bone : model.topLevelBones) {
registerBone(bone);
}
}
return model;
return model;
}
}

View file

@ -20,13 +20,12 @@ public class CosmeticParts {
public final String rightArmName = "arm_right";
public final String rightLegName = "leg_right";
public CosmeticParts() {
}
public CosmeticParts() {}
public CosmeticParts(GeoModel model) {
Optional<GeoBone> maybeRoot = model.getBone("root");
if (maybeRoot.isEmpty()) return;
if (maybeRoot.isEmpty())
return;
GeoBone root = maybeRoot.get();
for (GeoBone bone : root.childBones) {
switch (bone.name) {
@ -51,5 +50,4 @@ public class CosmeticParts {
}
}
}
}

View file

@ -19,7 +19,8 @@ public class CosmeticsManager {
private static Map<UUID, Identifier> capeCache = new HashMap<>();
private static Set<UUID> activePlayers = new HashSet<>();
private static Map<Identifier, GeoModel> cachedModels = new ConcurrentHashMap<>();
private static Map<Identifier, AnimationFile> cachedAnimations = new ConcurrentHashMap<>();
private static Map<Identifier, AnimationFile> cachedAnimations
= new ConcurrentHashMap<>();
private static void refresh() {
boolean doRefresh = false;
@ -43,7 +44,8 @@ public class CosmeticsManager {
provider.addCosmetics(player, (cosmetic) -> cosmetics.add(cosmetic));
if (!capeCache.containsKey(player)) {
Identifier cape = provider.getCape(player);
if (cape != null) capeCache.put(player, cape);
if (cape != null)
capeCache.put(player, cape);
}
}
}
@ -81,5 +83,4 @@ public class CosmeticsManager {
public static void loadAnimations(Identifier id, AnimationFile animations) {
cachedAnimations.put(id, animations);
}
}

View file

@ -46,5 +46,4 @@ public interface ICosmetic {
default int getTotalFrames() {
return 1;
}
}

View file

@ -10,7 +10,6 @@ import software.bernie.geckolib3.file.AnimationFile;
import software.bernie.geckolib3.geo.render.built.GeoModel;
public class RemoteCosmetic implements ICosmetic {
private Identifier id;
private boolean loadedModel = false;
private boolean loadedTexture = false;
@ -24,9 +23,9 @@ public class RemoteCosmetic implements ICosmetic {
public RemoteCosmetic(String id) {
this.id = new Identifier("anvillib", id);
this.modelLocation = new Identifier("anvillib", "models/remote/"+id);
this.textureLocation = new Identifier("anvillib", "textures/remote/"+id);
this.animationsLocation = new Identifier("anvillib", "animations/remote/"+id);
this.modelLocation = new Identifier("anvillib", "models/remote/" + id);
this.textureLocation = new Identifier("anvillib", "textures/remote/" + id);
this.animationsLocation = new Identifier("anvillib", "animations/remote/" + id);
}
@Override
@ -114,5 +113,4 @@ public class RemoteCosmetic implements ICosmetic {
public int getTotalFrames() {
return this.frameCount;
}
}

View file

@ -22,7 +22,6 @@ import net.minecraft.util.Identifier;
import net.minecraft.util.Util;
public class RemoteCosmeticProvider implements ICosmeticProvider {
public static RemoteCosmeticProvider INSTANCE = null;
public final Map<String, RemoteCosmetic> cosmetics = new ConcurrentHashMap<>();
@ -38,7 +37,9 @@ public class RemoteCosmeticProvider implements ICosmeticProvider {
public final URI capeBase;
private final File cacheDir;
public RemoteCosmeticProvider(URI playerBase, URI cosmeticBase, URI capeBase, File cacheDir) {
public RemoteCosmeticProvider(
URI playerBase, URI cosmeticBase, URI capeBase, File cacheDir
) {
this.playerBase = playerBase;
this.cosmeticBase = cosmeticBase;
this.capeBase = capeBase;
@ -55,7 +56,9 @@ public class RemoteCosmeticProvider implements ICosmeticProvider {
this.dirty = false;
if (playerCosmetics.containsKey(player)) {
for (String id : playerCosmetics.get(player)) {
if (!this.cosmetics.containsKey(id) || !this.cosmetics.get(id).readyToRender()) continue;
if (!this.cosmetics.containsKey(id)
|| !this.cosmetics.get(id).readyToRender())
continue;
cosmeticAdder.accept(this.cosmetics.get(id));
}
} else {
@ -69,13 +72,14 @@ public class RemoteCosmeticProvider implements ICosmeticProvider {
@Override
public Identifier getCape(UUID player) {
if (!this.playerCapes.containsKey(player)) return null;
if (!this.playerCapes.containsKey(player))
return null;
String cape = this.playerCapes.get(player);
return this.capes.getOrDefault(cape, null);
}
public void markDirty() {
synchronized(this) {
synchronized (this) {
this.dirty = true;
}
}
@ -87,26 +91,31 @@ public class RemoteCosmeticProvider implements ICosmeticProvider {
}
public void loadCosmetic(String id) throws MalformedURLException {
if (this.cosmetics.containsKey(id) || this.knownCosmetics.containsKey(id)) return;
if (this.cosmetics.containsKey(id) || this.knownCosmetics.containsKey(id))
return;
this.knownCosmetics.put(id, true);
URI url = cosmeticBase.resolve(id);
Util.getMainWorkerExecutor().execute(new CosmeticLoaderThread(url, this));
}
public void loadAssets(CosmeticData data, RemoteCosmetic cosmetic) {
Util.getMainWorkerExecutor().execute(new CosmeticAssetsLoaderThread(cosmetic, data, this.cacheDir, this));
Util.getMainWorkerExecutor().execute(
new CosmeticAssetsLoaderThread(cosmetic, data, this.cacheDir, this)
);
}
public void loadCape(String id) throws MalformedURLException {
if (this.capes.containsKey(id) || this.knownCapes.containsKey(id)) return;
if (this.capes.containsKey(id) || this.knownCapes.containsKey(id))
return;
this.knownCapes.put(id, true);
URI url = capeBase.resolve(id);
Util.getMainWorkerExecutor().execute(new CapeLoaderThread(id, url, this.cacheDir, this));
Util.getMainWorkerExecutor().execute(
new CapeLoaderThread(id, url, this.cacheDir, this)
);
}
public void failCosmeticLoading(String id) {
AnvilLib.LOGGER.error("Cosmetic loading failed: {}", id);
this.cosmetics.remove(id);
}
}

View file

@ -4,11 +4,9 @@ import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
public class AnimationData {
@Expose
public String url;
@Expose
@SerializedName("idle_animation")
public String idleAnimation;
}

View file

@ -4,7 +4,6 @@ import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
public class CosmeticData {
@Expose
public String id;
@Expose
@ -16,5 +15,4 @@ public class CosmeticData {
@Expose
@SerializedName("texture_data")
public TextureData textureData;
}

View file

@ -6,12 +6,10 @@ import java.util.UUID;
import com.google.gson.annotations.Expose;
public class PlayerData {
@Expose
public UUID uuid;
@Expose
public List<String> cosmetics;
@Expose
public String cape;
}

View file

@ -4,11 +4,9 @@ import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
public class TextureData {
@Expose
public String url;
@Expose
@SerializedName("total_frames")
public int frameCount;
}

View file

@ -17,14 +17,16 @@ import net.minecraft.client.texture.TextureManager;
import net.minecraft.util.Identifier;
public class CapeLoaderThread extends FileDownloaderThread {
private String id;
private File cacheDir;
private URI url;
private RemoteCosmeticProvider provider;
private TextureManager textureManager = MinecraftClient.getInstance().getTextureManager();
private TextureManager textureManager
= MinecraftClient.getInstance().getTextureManager();
public CapeLoaderThread(String id, URI url, File cacheDir, RemoteCosmeticProvider provider) {
public CapeLoaderThread(
String id, URI url, File cacheDir, RemoteCosmeticProvider provider
) {
super("0.2.0");
this.id = id;
this.url = url;
@ -42,17 +44,22 @@ public class CapeLoaderThread extends FileDownloaderThread {
AnvilLib.LOGGER.error("Can't load cape: {}", id, e);
return;
}
Identifier location = new Identifier("anvillib", "textures/cape/"+data.id);
Identifier location = new Identifier("anvillib", "textures/cape/" + data.id);
String hash = Hashing.sha1().hashUnencodedChars(data.id).toString();
AbstractTexture texture = this.textureManager.getOrDefault(location, MissingSprite.getMissingSpriteTexture());
AbstractTexture texture = this.textureManager.getOrDefault(
location, MissingSprite.getMissingSpriteTexture()
);
if (texture == MissingSprite.getMissingSpriteTexture()) {
File file = new File(this.cacheDir, hash.length() > 2 ? hash.substring(0, 2) : "xx");
File file = new File(
this.cacheDir, hash.length() > 2 ? hash.substring(0, 2) : "xx"
);
File file2 = new File(file, hash);
texture = new PlayerSkinTexture(file2, data.url, new Identifier("textures/block/dirt.png"), false, null);
texture = new PlayerSkinTexture(
file2, data.url, new Identifier("textures/block/dirt.png"), false, null
);
this.textureManager.registerTexture(location, texture);
}
this.provider.capes.put(data.id, location);
this.provider.markDirty();
}
}

View file

@ -36,15 +36,20 @@ import software.bernie.geckolib3.geo.render.built.GeoModel;
import software.bernie.geckolib3.util.json.JsonAnimationUtils;
public class CosmeticAssetsLoaderThread extends FileDownloaderThread {
private RemoteCosmetic cosmetic;
private CosmeticData data;
private MolangParser parser = new MolangParser();
private TextureManager textureManager = MinecraftClient.getInstance().getTextureManager();
private TextureManager textureManager
= MinecraftClient.getInstance().getTextureManager();
private File cacheDir;
private RemoteCosmeticProvider provider;
public CosmeticAssetsLoaderThread(RemoteCosmetic cosmetic, CosmeticData data, File cacheDir, RemoteCosmeticProvider provider) {
public CosmeticAssetsLoaderThread(
RemoteCosmetic cosmetic,
CosmeticData data,
File cacheDir,
RemoteCosmeticProvider provider
) {
super("0.2.0");
this.cosmetic = cosmetic;
this.data = data;
@ -71,7 +76,9 @@ public class CosmeticAssetsLoaderThread extends FileDownloaderThread {
JsonObject data = this.loadJson(url, JsonObject.class);
animations = this.buildAnimationFile(data);
} catch (IOException | URISyntaxException | NullPointerException e) {
AnvilLib.LOGGER.error("Could not load animation: {}", this.data.animationData.url, e);
AnvilLib.LOGGER.error(
"Could not load animation: {}", this.data.animationData.url, e
);
}
this.cosmetic.loadAnimations(animations, anim);
}
@ -79,12 +86,20 @@ public class CosmeticAssetsLoaderThread extends FileDownloaderThread {
@SuppressWarnings("deprecation")
private void loadTexture(TextureData data) {
String hash = Hashing.sha1().hashUnencodedChars(this.data.id).toString();
AbstractTexture texture = this.textureManager.getOrDefault(this.cosmetic.getTextureLocation(), MissingSprite.getMissingSpriteTexture());
AbstractTexture texture = this.textureManager.getOrDefault(
this.cosmetic.getTextureLocation(), MissingSprite.getMissingSpriteTexture()
);
if (texture == MissingSprite.getMissingSpriteTexture()) {
File file = new File(this.cacheDir, hash.length() > 2 ? hash.substring(0, 2) : "xx");
File file = new File(
this.cacheDir, hash.length() > 2 ? hash.substring(0, 2) : "xx"
);
File file2 = new File(file, hash);
texture = new PlayerSkinTexture(file2, data.url, new Identifier("textures/block/dirt.png"), false, null);
this.textureManager.registerTexture(this.cosmetic.getTextureLocation(), texture);
texture = new PlayerSkinTexture(
file2, data.url, new Identifier("textures/block/dirt.png"), false, null
);
this.textureManager.registerTexture(
this.cosmetic.getTextureLocation(), texture
);
}
this.cosmetic.loadTexture(data);
}
@ -95,7 +110,9 @@ public class CosmeticAssetsLoaderThread extends FileDownloaderThread {
String data = Objects.requireNonNull(this.getStringForURL(uri));
GeoModel model = this.buildModel(data);
this.cosmetic.loadModel(model);
} catch (NullPointerException | URISyntaxException | IOException | GeckoLibException e) {
} catch (
NullPointerException | URISyntaxException | IOException | GeckoLibException e
) {
AnvilLib.LOGGER.error("Can't load remote model: {}", url, e);
this.handleFailure();
}
@ -107,29 +124,33 @@ public class CosmeticAssetsLoaderThread extends FileDownloaderThread {
private AnimationFile buildAnimationFile(JsonObject json) {
AnimationFile animationFile = new AnimationFile();
for (Map.Entry<String, JsonElement> entry : JsonAnimationUtils.getAnimations(json)) {
String animationName = entry.getKey();
Animation animation;
try {
animation = JsonAnimationUtils.deserializeJsonToAnimation(
JsonAnimationUtils.getAnimation(json, animationName), parser);
animationFile.putAnimation(animationName, animation);
} catch (Exception e) {
AnvilLib.LOGGER.error("Could not load animation: {}", animationName, e);
throw new RuntimeException(e);
}
}
return animationFile;
for (Map.Entry<String, JsonElement> entry :
JsonAnimationUtils.getAnimations(json)) {
String animationName = entry.getKey();
Animation animation;
try {
animation = JsonAnimationUtils.deserializeJsonToAnimation(
JsonAnimationUtils.getAnimation(json, animationName), parser
);
animationFile.putAnimation(animationName, animation);
} catch (Exception e) {
AnvilLib.LOGGER.error("Could not load animation: {}", animationName, e);
throw new RuntimeException(e);
}
}
return animationFile;
}
private GeoModel buildModel(String json) throws IOException {
Identifier location = this.cosmetic.getModelLocation();
RawGeoModel rawModel = Converter.fromJsonString(json);
if (rawModel.getFormatVersion() != FormatVersion.VERSION_1_12_0) {
throw new GeckoLibException(location, "Wrong geometry json version, expected 1.12.0");
}
RawGeometryTree rawGeometryTree = RawGeometryTree.parseHierarchy(rawModel);
return GeoBuilder.getGeoBuilder(location.getNamespace()).constructGeoModel(rawGeometryTree);
if (rawModel.getFormatVersion() != FormatVersion.VERSION_1_12_0) {
throw new GeckoLibException(
location, "Wrong geometry json version, expected 1.12.0"
);
}
RawGeometryTree rawGeometryTree = RawGeometryTree.parseHierarchy(rawModel);
return GeoBuilder.getGeoBuilder(location.getNamespace())
.constructGeoModel(rawGeometryTree);
}
}

View file

@ -9,9 +9,8 @@ import net.anvilcraft.anvillib.cosmetics.remote.RemoteCosmeticProvider;
import net.anvilcraft.anvillib.cosmetics.remote.model.CosmeticData;
public class CosmeticLoaderThread extends FileDownloaderThread {
private URI url;
private RemoteCosmeticProvider provider;
private RemoteCosmeticProvider provider;
public CosmeticLoaderThread(URI url, RemoteCosmeticProvider provider) {
super("0.2.0");
@ -23,7 +22,8 @@ public class CosmeticLoaderThread extends FileDownloaderThread {
public void run() {
try {
CosmeticData data = this.loadJson(url, CosmeticData.class);
if (data == null) throw new IOException("Cosmetic not found");
if (data == null)
throw new IOException("Cosmetic not found");
RemoteCosmetic cosmetic = new RemoteCosmetic(data.id);
this.provider.cosmetics.put(data.id, cosmetic);
this.provider.loadAssets(data, cosmetic);
@ -31,5 +31,4 @@ public class CosmeticLoaderThread extends FileDownloaderThread {
AnvilLib.LOGGER.error("Can't load cosmetic", e);
}
}
}

View file

@ -16,7 +16,6 @@ import com.google.gson.JsonSyntaxException;
import net.anvilcraft.anvillib.AnvilLib;
public abstract class FileDownloaderThread implements Runnable {
protected Gson gson = new GsonBuilder().create();
protected HttpClient client = HttpClient.newBuilder().build();
protected final String version;
@ -39,9 +38,10 @@ public abstract class FileDownloaderThread implements Runnable {
HttpRequest req = this.buildRequest(url);
InputStream is = null;
try {
HttpResponse<InputStream> res = client.send(req, HttpResponse.BodyHandlers.ofInputStream());
HttpResponse<InputStream> res
= client.send(req, HttpResponse.BodyHandlers.ofInputStream());
if (res.statusCode() == 200) {
is = res.body();
is = res.body();
} else if (res.statusCode() != 404) {
AnvilLib.LOGGER.error("Unexpected status code: {}", res.statusCode());
}
@ -55,9 +55,10 @@ public abstract class FileDownloaderThread implements Runnable {
HttpRequest req = this.buildRequest(url);
String is = null;
try {
HttpResponse<String> res = client.send(req, HttpResponse.BodyHandlers.ofString());
HttpResponse<String> res
= client.send(req, HttpResponse.BodyHandlers.ofString());
if (res.statusCode() == 200) {
is = res.body();
is = res.body();
} else if (res.statusCode() != 404) {
AnvilLib.LOGGER.error("Unexpected status code: {}", res.statusCode());
}
@ -69,15 +70,15 @@ public abstract class FileDownloaderThread implements Runnable {
public <T> T loadJson(URI url, Class<T> type) throws IOException {
InputStream stream = this.getStreamForURL(url);
if (stream == null) return null;
if (stream == null)
return null;
try {
T json = this.gson.fromJson(new InputStreamReader(stream), type);
return json;
} catch(JsonSyntaxException | JsonIOException e) {
} catch (JsonSyntaxException | JsonIOException e) {
throw new IOException(e);
} finally {
stream.close();
}
}
}

View file

@ -6,8 +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 FileDownloaderThread {
private URI config;
private RemoteCosmeticProvider provider;
@ -21,7 +20,8 @@ public class PlayerCosmeticLoaderThread extends FileDownloaderThread{
public void run() {
try {
PlayerData player = this.loadJson(config, PlayerData.class);
if (player == null) return;
if (player == null)
return;
for (String id : player.cosmetics) {
this.provider.loadCosmetic(id);
this.provider.playerCosmetics.get(player.uuid).add(id);
@ -34,5 +34,4 @@ public class PlayerCosmeticLoaderThread extends FileDownloaderThread{
e.printStackTrace();
}
}
}

View file

@ -9,7 +9,6 @@ import software.bernie.geckolib3.model.AnimatedGeoModel;
@Mixin(AnimatedGeoModel.class)
public interface AnimatedGeoModelAccessor {
@Accessor(remap = false)
AnimationProcessor getAnimationProcessor();
@ -18,5 +17,4 @@ public interface AnimatedGeoModelAccessor {
@Accessor(remap = false)
void setCurrentModel(GeoModel model);
}

View file

@ -14,10 +14,11 @@ import net.minecraft.world.World;
@Mixin(AbstractClientPlayerEntity.class)
public abstract class AbstractClientPlayerEntityMixin extends PlayerEntity {
private static Identifier ELYTRA = new Identifier("textures/entity/elytra.png");
public AbstractClientPlayerEntityMixin(World world, BlockPos pos, float yaw, GameProfile profile) {
public AbstractClientPlayerEntityMixin(
World world, BlockPos pos, float yaw, GameProfile profile
) {
super(world, pos, yaw, profile);
}

View file

@ -12,7 +12,7 @@ import net.minecraft.client.RunArgs;
@Mixin(MinecraftClient.class)
public class MinecraftClientMixin {
@Inject(at = @At("RETURN"), method = "<init>")
public void init(RunArgs args, CallbackInfo info) {
ClientEventHandler.registerRemoteCosmetics(args.directories.assetDir);
}
public void init(RunArgs args, CallbackInfo info) {
ClientEventHandler.registerRemoteCosmetics(args.directories.assetDir);
}
}

View file

@ -8,27 +8,28 @@ import net.minecraft.util.registry.RegistryEntry;
import net.minecraft.world.gen.feature.StructurePoolFeatureConfig;
public class AdvancedStructurePoolFeatureConfig extends StructurePoolFeatureConfig {
public static final Codec<StructurePoolFeatureConfig> CODEC = RecordCodecBuilder.create(
(instance) -> {
return instance
.group(
StructurePool.REGISTRY_CODEC.fieldOf("start_pool")
.forGetter(
(self) -> ((AdvancedStructurePoolFeatureConfig) self).getStartPool()
),
Codec.intRange(0, 7).fieldOf("size").forGetter(
(self) -> ((AdvancedStructurePoolFeatureConfig) self).getSize()
),
Codec.INT.fieldOf("max_distance_from_center")
.forGetter(
(self)
-> ((AdvancedStructurePoolFeatureConfig) self)
.maxDistanceFromCenter
)
)
.apply(instance, AdvancedStructurePoolFeatureConfig::new);
}
);
public static final Codec<StructurePoolFeatureConfig> CODEC
= RecordCodecBuilder.create((instance) -> {
return instance
.group(
StructurePool.REGISTRY_CODEC.fieldOf("start_pool")
.forGetter(
(self)
-> ((AdvancedStructurePoolFeatureConfig) self)
.getStartPool()
),
Codec.intRange(0, 7).fieldOf("size").forGetter(
(self) -> ((AdvancedStructurePoolFeatureConfig) self).getSize()
),
Codec.INT.fieldOf("max_distance_from_center")
.forGetter(
(self)
-> ((AdvancedStructurePoolFeatureConfig) self)
.maxDistanceFromCenter
)
)
.apply(instance, AdvancedStructurePoolFeatureConfig::new);
});
public final int maxDistanceFromCenter;