backbone for client API commands with test

This commit is contained in:
gnembon committed 2020-06-12 22:46:41 -03:00
1 parent 7f98564122
commit fff3ccf3f6
4 files changed
+128

No files matched your search

@@ -44,6 +44,9 @@ public class ClientNetworkHandler
if (CarpetClient.shapes != null)
CarpetClient.shapes.addShapes((ListTag) t);
});
put("clientCommand", (p, t) -> {
CarpetClient.onClientCommand(t);
});
}};
@@ -99,4 +102,17 @@ public class ClientNetworkHandler
CarpetSettings.LOG.error("Unknown carpet data: "+key);
}
}
public static void clientCommand(String command)
{
CompoundTag tag = new CompoundTag();
tag.putString("id", command);
tag.putString("command", command);
CompoundTag outer = new CompoundTag();
outer.put("clientCommand", tag);
CarpetClient.getPlayer().networkHandler.sendPacket(new CustomPayloadC2SPacket(
CarpetClient.CARPET_CHANNEL,
(new PacketByteBuf(Unpooled.buffer())).writeVarInt(CarpetClient.DATA).writeCompoundTag(outer)
));
}
}