Provider
This commit is contained in:
+1
-1
Submodule common updated: 6021cd790e...f139ff5bd3
+84
-2
@@ -1,6 +1,7 @@
|
|||||||
package org.saturnclient.impl.provider;
|
package org.saturnclient.impl.provider;
|
||||||
|
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.saturnclient.common.provider.SaturnProvider;
|
import org.saturnclient.common.provider.SaturnProvider;
|
||||||
import org.saturnclient.common.ref.asset.IdentifierRef;
|
import org.saturnclient.common.ref.asset.IdentifierRef;
|
||||||
@@ -8,6 +9,11 @@ import org.saturnclient.common.ref.game.MinecraftClientRef;
|
|||||||
import org.saturnclient.cosmetics.cloak.utils.IdentifierUtils;
|
import org.saturnclient.cosmetics.cloak.utils.IdentifierUtils;
|
||||||
import org.saturnclient.saturnclient.SaturnClient;
|
import org.saturnclient.saturnclient.SaturnClient;
|
||||||
|
|
||||||
|
import dev.kosmx.playerAnim.api.layered.AnimationStack;
|
||||||
|
import dev.kosmx.playerAnim.minecraftApi.PlayerAnimationAccess;
|
||||||
|
import dev.kosmx.playerAnim.minecraftApi.PlayerAnimationRegistry;
|
||||||
|
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents;
|
||||||
|
import net.minecraft.client.network.AbstractClientPlayerEntity;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
|
|
||||||
public class SaturnProviderImpl implements SaturnProvider {
|
public class SaturnProviderImpl implements SaturnProvider {
|
||||||
@@ -17,12 +23,88 @@ public class SaturnProviderImpl implements SaturnProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerBufferedImageTexture(IdentifierRef i, BufferedImage bi) {
|
public void playEmote(UUID fromPlayerUuid, String emoteIdOrNull) {
|
||||||
IdentifierUtils.registerBufferedImageTextureFast((Identifier) (Object) i, bi);
|
if (SaturnClient.client == null || SaturnClient.client.world == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (AbstractClientPlayerEntity player : SaturnClient.client.world.getPlayers()) {
|
||||||
|
if (!player.getUuid().equals(fromPlayerUuid)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
AnimationStack animationStack = PlayerAnimationAccess.getPlayerAnimLayer(player);
|
||||||
|
|
||||||
|
if (emoteIdOrNull != null && !emoteIdOrNull.isEmpty()) {
|
||||||
|
if (animationStack.isActive() && animationStack.getPriority() == 1000) {
|
||||||
|
animationStack.removeLayer(1000);
|
||||||
|
}
|
||||||
|
animationStack.addAnimLayer(1000,
|
||||||
|
PlayerAnimationRegistry
|
||||||
|
.getAnimation(Identifier.of("saturnclient", emoteIdOrNull))
|
||||||
|
.playAnimation());
|
||||||
|
} else {
|
||||||
|
animationStack.removeLayer(1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getAccessToken() {
|
||||||
|
var session = SaturnClient.client.getSession();
|
||||||
|
if (session == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return session.getAccessToken();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public UUID getUuid() {
|
||||||
|
var session = SaturnClient.client.getSession();
|
||||||
|
if (session == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return session.getUuidOrNull();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getUsername() {
|
||||||
|
var session = SaturnClient.client.getSession();
|
||||||
|
if (session == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return session.getUsername();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClientStopping(Runnable handler) {
|
||||||
|
ClientLifecycleEvents.CLIENT_STOPPING.register(_o -> handler.run());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void logInfo(String message) {
|
||||||
|
SaturnClient.LOGGER.info(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void logError(String message) {
|
||||||
|
SaturnClient.LOGGER.error(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void logError(String message, Throwable throwable) {
|
||||||
|
SaturnClient.LOGGER.error(message, throwable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void stop() {
|
public void stop() {
|
||||||
SaturnClient.client.scheduleStop();
|
SaturnClient.client.scheduleStop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void registerBufferedImageTexture(IdentifierRef i, BufferedImage bi) {
|
||||||
|
IdentifierUtils.registerBufferedImageTextureFast((Identifier) (Object) i, bi);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import org.saturnclient.client.ServiceClient;
|
|||||||
import org.saturnclient.cosmetics.Emotes;
|
import org.saturnclient.cosmetics.Emotes;
|
||||||
import org.saturnclient.cosmetics.Hats;
|
import org.saturnclient.cosmetics.Hats;
|
||||||
import org.saturnclient.cosmetics.cloak.Cloaks;
|
import org.saturnclient.cosmetics.cloak.Cloaks;
|
||||||
import org.saturnclient.common.bindings.SaturnClientBindings;
|
|
||||||
import org.saturnclient.common.provider.Providers;
|
import org.saturnclient.common.provider.Providers;
|
||||||
import org.saturnclient.impl.provider.FabricModuleProvider;
|
import org.saturnclient.impl.provider.FabricModuleProvider;
|
||||||
import org.saturnclient.impl.provider.GLFWProviderImpl;
|
import org.saturnclient.impl.provider.GLFWProviderImpl;
|
||||||
@@ -18,8 +17,6 @@ import org.saturnclient.impl.provider.SaturnProviderImpl;
|
|||||||
import org.saturnclient.modules.ModManager;
|
import org.saturnclient.modules.ModManager;
|
||||||
import org.saturnclient.config.Config;
|
import org.saturnclient.config.Config;
|
||||||
import org.saturnclient.config.manager.ConfigManager;
|
import org.saturnclient.config.manager.ConfigManager;
|
||||||
import org.saturnclient.saturnclient.bindings.SaturnEmoteBindingsImpl;
|
|
||||||
import org.saturnclient.saturnclient.bindings.SaturnPlatformBindingsImpl;
|
|
||||||
import org.saturnclient.saturnclient.event.KeyInputHandler;
|
import org.saturnclient.saturnclient.event.KeyInputHandler;
|
||||||
import org.saturnclient.ui.ElementRenderer;
|
import org.saturnclient.ui.ElementRenderer;
|
||||||
import org.saturnclient.ui.EntityDrawerImpl;
|
import org.saturnclient.ui.EntityDrawerImpl;
|
||||||
@@ -58,9 +55,6 @@ public class SaturnClient implements ModInitializer {
|
|||||||
SaturnScreenFabric.preload(client);
|
SaturnScreenFabric.preload(client);
|
||||||
});
|
});
|
||||||
|
|
||||||
SaturnClientBindings.setPlatform(new SaturnPlatformBindingsImpl());
|
|
||||||
SaturnClientBindings.setEmotes(new SaturnEmoteBindingsImpl());
|
|
||||||
|
|
||||||
ClientLifecycleEvents.CLIENT_STOPPING.register(_o -> ConfigManager.save());
|
ClientLifecycleEvents.CLIENT_STOPPING.register(_o -> ConfigManager.save());
|
||||||
|
|
||||||
ClientTickEvents.END_CLIENT_TICK.register(client -> {
|
ClientTickEvents.END_CLIENT_TICK.register(client -> {
|
||||||
|
|||||||
-44
@@ -1,44 +0,0 @@
|
|||||||
package org.saturnclient.saturnclient.bindings;
|
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import org.saturnclient.common.bindings.SaturnEmoteBindings;
|
|
||||||
import org.saturnclient.saturnclient.SaturnClient;
|
|
||||||
|
|
||||||
import dev.kosmx.playerAnim.api.layered.AnimationStack;
|
|
||||||
import dev.kosmx.playerAnim.minecraftApi.PlayerAnimationAccess;
|
|
||||||
import dev.kosmx.playerAnim.minecraftApi.PlayerAnimationRegistry;
|
|
||||||
import net.minecraft.client.network.AbstractClientPlayerEntity;
|
|
||||||
import net.minecraft.util.Identifier;
|
|
||||||
|
|
||||||
public class SaturnEmoteBindingsImpl implements SaturnEmoteBindings {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setEmote(UUID fromPlayerUuid, String emoteIdOrNull) {
|
|
||||||
if (SaturnClient.client == null || SaturnClient.client.world == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (AbstractClientPlayerEntity player : SaturnClient.client.world.getPlayers()) {
|
|
||||||
if (!player.getUuid().equals(fromPlayerUuid)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
AnimationStack animationStack = PlayerAnimationAccess.getPlayerAnimLayer(player);
|
|
||||||
|
|
||||||
if (emoteIdOrNull != null && !emoteIdOrNull.isEmpty()) {
|
|
||||||
if (animationStack.isActive() && animationStack.getPriority() == 1000) {
|
|
||||||
animationStack.removeLayer(1000);
|
|
||||||
}
|
|
||||||
animationStack.addAnimLayer(1000,
|
|
||||||
PlayerAnimationRegistry
|
|
||||||
.getAnimation(Identifier.of("saturnclient", emoteIdOrNull))
|
|
||||||
.playAnimation());
|
|
||||||
} else {
|
|
||||||
animationStack.removeLayer(1000);
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-59
@@ -1,59 +0,0 @@
|
|||||||
package org.saturnclient.saturnclient.bindings;
|
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import org.saturnclient.common.bindings.SaturnPlatformBindings;
|
|
||||||
import org.saturnclient.saturnclient.SaturnClient;
|
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents;
|
|
||||||
import net.minecraft.client.MinecraftClient;
|
|
||||||
|
|
||||||
public class SaturnPlatformBindingsImpl implements SaturnPlatformBindings {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getAccessToken() {
|
|
||||||
var session = MinecraftClient.getInstance().getSession();
|
|
||||||
if (session == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return session.getAccessToken();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public UUID getUuid() {
|
|
||||||
var session = MinecraftClient.getInstance().getSession();
|
|
||||||
if (session == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return session.getUuidOrNull();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getUsername() {
|
|
||||||
var session = MinecraftClient.getInstance().getSession();
|
|
||||||
if (session == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return session.getUsername();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onClientStopping(Runnable handler) {
|
|
||||||
ClientLifecycleEvents.CLIENT_STOPPING.register(_o -> handler.run());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void logInfo(String message) {
|
|
||||||
SaturnClient.LOGGER.info(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void logError(String message) {
|
|
||||||
SaturnClient.LOGGER.error(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void logError(String message, Throwable throwable) {
|
|
||||||
SaturnClient.LOGGER.error(message, throwable);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user