backbone for client API commands with test
This commit is contained in:
1 parent
7f98564122
commit
fff3ccf3f6
4 files changed
+128
No files matched your search
@@ -1,8 +1,13 @@
|
||||
package carpet.network;
|
||||
|
||||
import carpet.CarpetServer;
|
||||
import carpet.CarpetSettings;
|
||||
import carpet.script.utils.ShapesRenderer;
|
||||
import net.minecraft.client.network.ClientPlayerEntity;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
public class CarpetClient
|
||||
@@ -51,4 +56,26 @@ public class CarpetClient
|
||||
{
|
||||
return isServerCarpet;
|
||||
}
|
||||
|
||||
public static boolean sendClientCommand(String command)
|
||||
{
|
||||
if (!isServerCarpet && CarpetServer.minecraft_server == null) return false;
|
||||
ClientNetworkHandler.clientCommand(command);
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void onClientCommand(Tag t)
|
||||
{
|
||||
CarpetSettings.LOG.info("Server Response:");
|
||||
CompoundTag tag = (CompoundTag)t;
|
||||
CarpetSettings.LOG.info(" - id: "+tag.getString("id"));
|
||||
CarpetSettings.LOG.info(" - code: "+tag.getInt("code"));
|
||||
if (tag.contains("error")) CarpetSettings.LOG.warn(" - error: "+tag.getString("error"));
|
||||
if (tag.contains("output"))
|
||||
{
|
||||
ListTag outputTag = (ListTag) tag.get("output");
|
||||
for (int i = 0; i < outputTag.size(); i++)
|
||||
CarpetSettings.LOG.info(" - response: " + Text.Serializer.fromJson(outputTag.getString(i)).getString());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user